Create Lazyvim configs from Lunarvim configs

This commit is contained in:
2026-06-20 16:21:55 +05:30
parent fab64cc52e
commit a82f0372be
13 changed files with 628 additions and 0 deletions
@@ -0,0 +1,101 @@
-- @section commands
-- Custom user commands migrated from LunarVim's config.lua vim.cmd block
--- @section commands-grep
-- Gr: Search with grep and show results in quickfix list
vim.api.nvim_create_user_command("Gr", function(input)
vim.cmd("silent execute 'grep! " .. input.args .. " | copen'")
end, { nargs = "+", desc = "Grep and open quickfix list" })
-- Grc: Raw grep command (no quickfix auto-open)
vim.api.nvim_create_user_command("Grc", function(input)
vim.cmd("grep " .. input.args)
end, { nargs = "*", desc = "Run grep without quickfix" })
--- @section commands-file
-- Header: Add file header via external script
vim.api.nvim_create_user_command("Header", function()
vim.cmd("0r!file-header '%'")
end, { desc = "Add file header from external file-header script" })
-- Termw: Open konsole terminal emulator
vim.api.nvim_create_user_command("Termw", function()
vim.cmd("!konsole -e bash-session &")
end, { desc = "Open konsole terminal" })
-- Term: Open embedded terminal in a horizontal split
vim.api.nvim_create_user_command("Term", function()
vim.cmd("sp | term")
end, { desc = "Open terminal in split window" })
-- EditSnippet: Open LuaSnip snippet files for editing
vim.api.nvim_create_user_command("EditSnippet", function()
require("luasnip.loaders").edit_snippet_files()
end, { desc = "Edit LuaSnip snippet files" })
-- Cwd: Change working directory to current file's directory
vim.api.nvim_create_user_command("Cwd", function()
vim.cmd("cd %:p:h")
end, { desc = "Change directory to current file" })
-- Tcd: Change tab-local working directory to current file's directory
vim.api.nvim_create_user_command("Tcd", function()
vim.cmd(":tcd %:p:h")
end, { desc = "Change tab directory to current file" })
-- Reload: Reload all buffers from disk
vim.api.nvim_create_user_command("Reload", function()
vim.cmd("bufdo execute 'checktime . bufnr('%')'")
end, { desc = "Reload all buffers" })
-- Rm: Delete current file from disk and close buffer
vim.api.nvim_create_user_command("Rm", function()
vim.cmd("!rm % | bd")
end, { desc = "Delete file and close buffer" })
-- CopyFilename: Copy current file path to system clipboard
vim.api.nvim_create_user_command("CopyFilename", function()
vim.fn.setreg("+", vim.fn.expand("%"))
end, { desc = "Copy file path to clipboard" })
-- Code: Open current file in VS Code at current line
vim.api.nvim_create_user_command("Code", function()
vim.cmd("!code ./ -g %:" .. (vim.fn.line(".") + 1))
end, { desc = "Open in VS Code at current line" })
--- @section keymaps-grep (defined as keymap in vim.cmd, moved here for clarity)
-- <C-/>: Search word under cursor with custom Gr command
vim.keymap.set("n", "<C-/>", function()
vim.cmd("Gr " .. vim.fn.expand("<cword>"))
end, { desc = "Grep word under cursor (custom Gr)" })
-- <C-G>: Live grep word under cursor via Snacks picker
vim.keymap.set("n", "<C-G>", function()
LazyVim.pick("live_grep", { default_text = vim.fn.expand("<cword>") })()
end, { desc = "Snacks grep word under cursor" })
-- @section autocmds-filetype
-- Caddyfile: Set filetype for Caddyfile (any path, any name containing "Caddyfile")
vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
pattern = "*Caddyfile",
callback = function()
vim.bo.filetype = "caddy"
end,
desc = "Detect Caddyfile filetype",
})
-- @section autocmds-emmet
-- Emmet: Enable Emmet for web development filetypes (migrated from LunarVim)
-- Disabled by default for all filetypes; enabled only for these specific filetypes.
vim.api.nvim_create_autocmd("FileType", {
pattern = { "html", "css", "vue", "jsx", "php", "javascriptreact" },
callback = function()
vim.cmd("EmmetInstall")
end,
desc = "Enable Emmet for web filetypes",
})
-- @section config-grepprg
-- Set grep program to `ag` (preserved from LunarVim)
-- LazyVim defaults to `rg --vimgrep`. This overrides it.
vim.opt.grepprg = "ag --vimgrep"
@@ -0,0 +1,97 @@
-- @section keymaps
-- Custom keymaps migrated from LunarVim config.
-- LazyVim already defines many keymaps (e.g. <C-s> for save, <S-h/l> for buffer prev/next,
-- <leader>bd for delete buffer). Only keymaps that add to or differ from LazyVim defaults
-- are listed here. Grouped by function with @section markers.
local map = vim.keymap.set
--- @section keymaps-buffers
-- Meta+number: Jump to specific buffer (via BufferLine)
-- LazyVim provides <leader>bj for BufferLinePick (interactive pick).
-- These direct-access keys are preserved from your LunarVim config.
for i = 1, 9 do
map("n", "<M-" .. i .. ">", function()
vim.cmd("BufferLineGoToBuffer " .. i)
end, { desc = "Go to buffer " .. i })
end
--- @section keymaps-picker
-- <C-p>: Quick file find (Snacks picker replaces your Telescope "fd" picker)
map("n", "<C-p>", function()
LazyVim.pick("files")()
end, { desc = "Find Files" })
--- @section keymaps-external
-- Launch external tools from Neovim
map("n", "<Leader><Leader>t", ":!konsole&<CR>", { desc = "Open Konsole terminal" })
map("n", "<Leader><Leader>g", ":!git gui &<CR>", { desc = "Open Git GUI" })
--- @section keymaps-file
-- File-level operations
map("n", "<M-r>", ":e!<CR>", { desc = "Reload current file (discard changes)" })
map("n", "<M-q>", function()
Snacks.bufdelete()
end, { desc = "Delete current buffer (preserves window layout)" })
map("n", "<M-Q>", ":bd!<CR>", { desc = "Force delete buffer and close window" })
--- @section keymaps-visual
-- Visual mode operations
map("v", "<C-h>", '"fy:%s#<C-r>f#', { desc = "Replace all occurrences of selected text" })
map("v", "<C-f>", '"fy/<C-r>f', { desc = "Search for selected word" })
--- @section keymaps-insert
-- Insert mode helpers
map("i", "<C-CR>", "<ESC>A;", { desc = "Append semicolon at end of line" })
map("i", "<C-E>", "<plug>(emmet-expand-abbr)", { desc = "Expand Emmet abbreviation" })
--- @section keymaps-window
-- Window navigation with Alt+arrows (preserved from LunarVim)
-- LazyVim defaults have <C-h/j/k/l> for window nav.
-- These Alt+arrow mappings give you an alternative.
map("n", "<M-Up>", "<C-W>k", { desc = "Move to window above" })
map("n", "<M-Down>", "<C-W>j", { desc = "Move to window below" })
map("n", "<M-Right>", "<C-W>l", { desc = "Move to window right" })
map("n", "<M-Left>", "<C-W>h", { desc = "Move to window left" })
--- @section keymaps-terminal
-- Terminal mode keymaps for window navigation and tab switching
map("t", "<C-PageUp>", "<C-\\><C-N><C-PageUp>", { desc = "Terminal: Previous tab" })
map("t", "<C-PageDown>", "<C-\\><C-N><C-PageDown>", { desc = "Terminal: Next tab" })
map("t", "<M-Up>", "<C-\\><C-N><C-W>k", { desc = "Terminal: Window up" })
map("t", "<M-Down>", "<C-\\><C-N><C-W>j", { desc = "Terminal: Window down" })
map("t", "<M-Right>", "<C-\\><C-N><C-W>l", { desc = "Terminal: Window right" })
map("t", "<M-Left>", "<C-\\><C-N><C-W>h", { desc = "Terminal: Window left" })
--- @section keymaps-buffer-switch
-- Buffer switching keys preserved from LunarVim.
-- NOTE: <C-j> and <C-k> conflict with LazyVim's default window navigation
-- (<C-j>=window down, <C-k>=window up). Since you use <M-Arrows> for windows,
-- these override <C-j/k> to buffer navigation instead.
map("n", "<C-PageUp>", ":BufferLineCyclePrev<CR>", { desc = "Previous buffer" })
map("n", "<C-PageDown>", ":BufferLineCycleNext<CR>", { desc = "Next buffer" })
map("n", "<C-S-PageUp>", ":BufferLineMovePrev<CR>", { desc = "Move buffer left" })
map("n", "<C-S-PageDown>", ":BufferLineMoveNext<CR>", { desc = "Move buffer right" })
map("n", "<C-j>", ":BufferLineCyclePrev<CR>", { desc = "Previous buffer" })
map("n", "<C-k>", ":BufferLineCycleNext<CR>", { desc = "Next buffer" })
map("n", "<C-S-j>", ":BufferLineMovePrev<CR>", { desc = "Move buffer left" })
map("n", "<C-S-k>", ":BufferLineMoveNext<CR>", { desc = "Move buffer right" })
--- @section keymaps-tab
map("n", "<C-S-T>", ":tabedit<CR>", { desc = "Open new tab" })
--- @section keymaps-dap
-- Quick DAP access keys (dap.core extra provides <leader>d prefix mappings)
-- These F-keys provide direct access to the most common debugging actions.
map("n", "<F5>", function()
require("dap").continue()
end, { desc = "DAP: Continue / Start debugging" })
map("n", "<F10>", function()
require("dap").step_over()
end, { desc = "DAP: Step over" })
map("n", "<F11>", function()
require("dap").step_into()
end, { desc = "DAP: Step into" })
map("n", "<F12>", function()
require("dap").step_out()
end, { desc = "DAP: Step out" })
@@ -0,0 +1,36 @@
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.uv.fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
-- Core LazyVim distribution (must be first)
{ "LazyVim/LazyVim", import = "lazyvim.plugins", version = "*" },
-- Extras (use :LazyExtras to browse all available extras)
{ import = "lazyvim.plugins.extras.dap.core" },
-- Import user plugins from lua/plugins/*.lua
{ import = "plugins" },
}, {
defaults = { lazy = true, version = "*" },
install = { colorscheme = { "habamax" } },
checker = { enabled = true },
performance = {
rtp = {
disabled_plugins = {
"gzip",
"matchit",
"matchparen",
"netrwPlugin",
"tarPlugin",
"tohtml",
"tutor",
"zipPlugin",
},
},
},
})
@@ -0,0 +1,12 @@
-- @section vim-options
-- Override LazyVim default vim options to match your previous LunarVim config.
-- LazyVim defaults already include: shiftwidth=2, tabstop=2, number=true, list=true,
-- relativenumber=true.
-- Relativenumber: Your LunarVim config explicitly disabled it.
-- LazyVim defaults to true; this overrides it back to false.
vim.opt.relativenumber = false
-- Grepprg: Your LunarVim config used `ag --vimgrep`.
-- LazyVim defaults to `rg --vimgrep`. Uncomment below to switch to `ag`:
-- vim.opt.grepprg = "ag --vimgrep"