Skip to content

Commit 4d67474

Browse files
committed
refactor(nvim): migrate to lazy.nvim and modernize plugin/config setup
1 parent 08a2a21 commit 4d67474

23 files changed

Lines changed: 333 additions & 110 deletions

config/nvim/init.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
vim.g.mapleader = " "
2+
vim.g.maplocalleader = " "
3+
14
-- Set up some high level options
25
vim.opt.encoding = "utf-8"
36
vim.opt.fileencoding = "utf-8"
@@ -6,6 +9,4 @@ vim.opt.spelllang = "en"
69

710
require("settings")
811
require("plugins")
9-
require("lsp")
1012
require("mappings")
11-
require("theme")

config/nvim/lazy-lock.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" },
3+
"cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" },
4+
"cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" },
5+
"cmp-nvim-lsp-document-symbol": { "branch": "main", "commit": "f94f7ba948e32cd302caba1c2ca3f7c697fb4fcf" },
6+
"cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "fd3e882e56956675c620898bf1ffcf4fcbe7ec84" },
7+
"cmp-nvim-lua": { "branch": "main", "commit": "e3a22cb071eb9d6508a156306b102c45cd2d573d" },
8+
"cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" },
9+
"cmp-vsnip": { "branch": "main", "commit": "989a8a73c44e926199bfd05fa7a516d51f2d2752" },
10+
"conform.nvim": { "branch": "master", "commit": "086a40dc7ed8242c03be9f47fbcee68699cc2395" },
11+
"copilot-cmp": { "branch": "master", "commit": "15fc12af3d0109fa76b60b5cffa1373697e261d1" },
12+
"copilot.lua": { "branch": "master", "commit": "0552b44fceedf0c4cba2cd4953d3976633b2509a" },
13+
"github-nvim-theme": { "branch": "main", "commit": "c106c9472154d6b2c74b74565616b877ae8ed31d" },
14+
"gitsigns.nvim": { "branch": "main", "commit": "7c4faa3540d0781a28588cafbd4dd187a28ac6e3" },
15+
"kotlin-vim": { "branch": "master", "commit": "53fe045906df8eeb07cb77b078fc93acda6c90b8" },
16+
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
17+
"lazydev.nvim": { "branch": "main", "commit": "ff2cbcba459b637ec3fd165a2be59b7bbaeedf0d" },
18+
"mason-lspconfig.nvim": { "branch": "main", "commit": "a979821a975897b88493843301950c456a725982" },
19+
"mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" },
20+
"nvim-cmp": { "branch": "main", "commit": "da88697d7f45d16852c6b2769dc52387d1ddc45f" },
21+
"nvim-lspconfig": { "branch": "master", "commit": "841c6d4139aedb8a3f2baf30cef5327371385b93" },
22+
"nvim-treesitter": { "branch": "main", "commit": "0e0db770f2a3691fae478798342f4ac431accefd" },
23+
"nvim-treesitter-textobjects": { "branch": "main", "commit": "93d60a475f0b08a8eceb99255863977d3a25f310" },
24+
"nvim-web-devicons": { "branch": "master", "commit": "d7462543c9e366c0d196c7f67a945eaaf5d99414" },
25+
"oil.nvim": { "branch": "master", "commit": "0fcc83805ad11cf714a949c98c605ed717e0b83e" },
26+
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
27+
"render-markdown.nvim": { "branch": "main", "commit": "e3c18ddd27a853f85a6f513a864cf4f2982b9f26" },
28+
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" },
29+
"telescope.nvim": { "branch": "master", "commit": "5255aa27c422de944791318024167ad5d40aad20" },
30+
"vim-tmux-navigator": { "branch": "master", "commit": "e41c431a0c7b7388ae7ba341f01a0d217eb3a432" },
31+
"vim-vsnip": { "branch": "master", "commit": "9bcfabea653abdcdac584283b5097c3f8760abaa" }
32+
}

config/nvim/lua/lsp/init.lua

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ end
3636
vim.lsp.enable(servers)
3737

3838
-- Diagnostic keymaps
39-
vim.keymap.set("n", "<space>e", vim.diagnostic.open_float, { desc = "Open diagnostic float" })
39+
vim.keymap.set("n", "<leader>de", vim.diagnostic.open_float, { desc = "Open diagnostic float" })
4040
vim.keymap.set("n", "[d", function()
4141
vim.diagnostic.jump({ count = -1 })
4242
end, { desc = "Previous diagnostic" })
4343
vim.keymap.set("n", "]d", function()
4444
vim.diagnostic.jump({ count = 1 })
4545
end, { desc = "Next diagnostic" })
46-
vim.keymap.set("n", "<space>q", vim.diagnostic.setloclist, { desc = "Diagnostic quickfix list" })
46+
vim.keymap.set("n", "<leader>dq", vim.diagnostic.setloclist, { desc = "Diagnostic quickfix list" })
4747

4848
-- LSP keymaps (set when a server attaches to a buffer)
4949
vim.api.nvim_create_autocmd("LspAttach", {
@@ -54,7 +54,7 @@ vim.api.nvim_create_autocmd("LspAttach", {
5454
-- Enable completion triggered by <c-x><c-o>
5555
vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc"
5656

57-
-- Disable formatting for lua_ls (use stylua/neoformat instead)
57+
-- Disable formatting for lua_ls and let conform/stylua handle it.
5858
if client and client.name == "lua_ls" then
5959
client.server_capabilities.documentFormattingProvider = false
6060
client.server_capabilities.documentRangeFormattingProvider = false
@@ -77,35 +77,32 @@ vim.api.nvim_create_autocmd("LspAttach", {
7777
)
7878
vim.keymap.set(
7979
"n",
80-
"<space>wa",
80+
"<leader>wa",
8181
vim.lsp.buf.add_workspace_folder,
8282
vim.tbl_extend("force", opts, { desc = "Add workspace folder" })
8383
)
8484
vim.keymap.set(
8585
"n",
86-
"<space>wr",
86+
"<leader>wr",
8787
vim.lsp.buf.remove_workspace_folder,
8888
vim.tbl_extend("force", opts, { desc = "Remove workspace folder" })
8989
)
90-
vim.keymap.set("n", "<space>wl", function()
90+
vim.keymap.set("n", "<leader>wl", function()
9191
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
9292
end, vim.tbl_extend("force", opts, { desc = "List workspace folders" }))
9393
vim.keymap.set(
9494
"n",
95-
"<space>D",
95+
"<leader>D",
9696
vim.lsp.buf.type_definition,
9797
vim.tbl_extend("force", opts, { desc = "LSP type definition" })
9898
)
99-
vim.keymap.set("n", "<space>rn", vim.lsp.buf.rename, vim.tbl_extend("force", opts, { desc = "LSP rename" }))
99+
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, vim.tbl_extend("force", opts, { desc = "LSP rename" }))
100100
vim.keymap.set(
101101
"n",
102-
"<space>ca",
102+
"<leader>ca",
103103
vim.lsp.buf.code_action,
104104
vim.tbl_extend("force", opts, { desc = "LSP code action" })
105105
)
106106
vim.keymap.set("n", "gr", vim.lsp.buf.references, vim.tbl_extend("force", opts, { desc = "LSP references" }))
107-
vim.keymap.set("n", "<space>f", function()
108-
vim.lsp.buf.format({ async = true })
109-
end, vim.tbl_extend("force", opts, { desc = "Format buffer" }))
110107
end,
111108
})

config/nvim/lua/mappings.lua

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,13 @@ vim.keymap.set("x", "<", "<gv", { desc = "Indent left and keep selection" })
22
vim.keymap.set("x", ">", ">gv", { desc = "Indent right and keep selection" })
33

44
vim.keymap.set("n", "<C-p>", "<cmd>Telescope find_files<cr>", { desc = "Find files" })
5-
vim.keymap.set("n", "<C-o>", "<cmd>NERDTreeToggle<cr>", { desc = "Toggle NERDTree" })
5+
vim.keymap.set("n", "<leader>ff", "<cmd>Telescope find_files<cr>", { desc = "Find files" })
6+
vim.keymap.set("n", "<leader>fg", "<cmd>Telescope live_grep<cr>", { desc = "Live grep" })
7+
vim.keymap.set("n", "<leader>e", "<cmd>Oil<cr>", { desc = "Open file explorer" })
8+
vim.keymap.set("n", "-", "<cmd>Oil<cr>", { desc = "Open parent directory" })
9+
vim.keymap.set("n", "<leader>f", function()
10+
require("conform").format({
11+
async = true,
12+
lsp_format = "fallback",
13+
})
14+
end, { desc = "Format buffer" })

config/nvim/lua/plugins/configs/cmp.lua

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ if not ok then
55
end
66

77
local icons = {
8+
Copilot = "",
89
Text = "",
910
Method = "",
1011
Function = "",
@@ -51,7 +52,7 @@ cmp.setup({
5152
fields = { "kind", "abbr", "menu" },
5253
format = function(_, vim_item)
5354
vim_item.menu = vim_item.kind
54-
vim_item.kind = icons[vim_item.kind]
55+
vim_item.kind = icons[vim_item.kind] or vim_item.kind
5556

5657
return vim_item
5758
end,
@@ -98,16 +99,40 @@ cmp.setup({
9899
}),
99100
},
100101
sources = {
102+
{ name = "copilot", group_index = 2 },
101103
{ name = "nvim_lsp" },
102104
{ name = "nvim_lua" },
103105
{ name = "vsnip" },
104106
{ name = "path" },
105107
{ name = "buffer" },
106108
{ name = "nvim_lsp_signature_help" },
107109
},
110+
sorting = {
111+
priority_weight = 2,
112+
comparators = {
113+
require("copilot_cmp.comparators").prioritize,
114+
cmp.config.compare.offset,
115+
cmp.config.compare.exact,
116+
cmp.config.compare.score,
117+
cmp.config.compare.recently_used,
118+
cmp.config.compare.locality,
119+
cmp.config.compare.kind,
120+
cmp.config.compare.sort_text,
121+
cmp.config.compare.length,
122+
cmp.config.compare.order,
123+
},
124+
},
108125
preselect = cmp.PreselectMode.None,
109126
})
110127

128+
cmp.event:on("menu_opened", function()
129+
vim.b.copilot_suggestion_hidden = true
130+
end)
131+
132+
cmp.event:on("menu_closed", function()
133+
vim.b.copilot_suggestion_hidden = false
134+
end)
135+
111136
cmp.setup.cmdline("/", {
112137
mapping = cmp.mapping.preset.cmdline(),
113138
sources = {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
local ok, conform = pcall(require, "conform")
2+
3+
if not ok then
4+
return
5+
end
6+
7+
conform.setup({
8+
default_format_opts = {
9+
lsp_format = "fallback",
10+
},
11+
formatters_by_ft = {
12+
lua = { "stylua" },
13+
python = { "isort", "ruff_format" },
14+
yaml = { "prettier" },
15+
markdown = { "prettier" },
16+
bzl = { "buildifier" },
17+
starlark = { "buildifier" },
18+
},
19+
})
Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,26 @@
1-
vim.g.copilot_assume_mapped = true
2-
vim.g.copilot_no_tab_map = false
1+
local ok, copilot = pcall(require, "copilot")
2+
3+
if not ok then
4+
return
5+
end
6+
7+
copilot.setup({
8+
panel = {
9+
enabled = false,
10+
},
11+
suggestion = {
12+
enabled = false,
13+
},
14+
filetypes = {
15+
help = true,
16+
markdown = true,
17+
},
18+
})
19+
20+
local cmp_ok, copilot_cmp = pcall(require, "copilot_cmp")
21+
22+
if not cmp_ok then
23+
return
24+
end
25+
26+
copilot_cmp.setup()

config/nvim/lua/plugins/configs/gitgutter.lua

Whitespace-only changes.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
local ok, gitsigns = pcall(require, "gitsigns")
2+
3+
if not ok then
4+
return
5+
end
6+
7+
gitsigns.setup({
8+
current_line_blame = false,
9+
signs = {
10+
add = { text = "|" },
11+
change = { text = "|" },
12+
delete = { text = "_" },
13+
topdelete = { text = "^" },
14+
changedelete = { text = "~" },
15+
untracked = { text = "|" },
16+
},
17+
})

config/nvim/lua/plugins/configs/neoformat.lua

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)