Skip to content

Commit a1bddd2

Browse files
committed
feat(nvim): 0.11 configuration updates
1 parent cee12c7 commit a1bddd2

File tree

7 files changed

+31
-52
lines changed

7 files changed

+31
-52
lines changed

modules/neovim/config/after/ftplugin/fugitive.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ local opts = {
88

99
-- Runs a git command async.
1010
--
11-
---@param args table: git command arguments.
11+
---@param args string[]: git command arguments.
1212
---@param success_msg string: notification message when the command succeeds.
1313
---@param error_msg string: notification message when the command fails.
1414
local function async_git(args, success_msg, error_msg)
15+
---@diagnostic disable-next-line: missing-fields
1516
Job:new({
1617
command = "git",
1718
args = args,

modules/neovim/config/after/ftplugin/go.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ local keymap = function(lhs, rhs)
1717
end
1818

1919
-- get the gopls server from the given buffer, or nil.
20-
---@param bufnr integer
20+
---@param bufnr number
2121
---@return vim.lsp.Client
2222
local get_gopls = function(bufnr)
2323
local clients = vim.lsp.get_clients({ bufnr = bufnr })

modules/neovim/config/lua/lsp_autocommands.lua

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ local group = vim.api.nvim_create_augroup("LSP", { clear = true })
44
-- Format code and organize imports (if supported) (async).
55
--
66
---@async
7-
---@type lsp.Apply
7+
---@param client vim.lsp.Client
8+
---@param bufnr number
9+
---@type fun(client: vim.lsp.Client, bufnr: number)
810
local organize_imports = function(client, bufnr)
911
---@type lsp.Handler
1012
---@diagnostic disable-next-line: unused-local
@@ -18,7 +20,7 @@ local organize_imports = function(client, bufnr)
1820
local enc = client.offset_encoding or "utf-16"
1921
vim.lsp.util.apply_workspace_edit(r.edit, enc)
2022
elseif r.command and r.command.command then
21-
vim.lsp.buf.execute_command(r.command)
23+
client:exec_cmd(r.command, { bufnr = bufnr })
2224
end
2325
end
2426
vim.cmd([[noautocmd write]])
@@ -27,7 +29,7 @@ local organize_imports = function(client, bufnr)
2729
local win = vim.api.nvim_get_current_win()
2830
local params = vim.lsp.util.make_range_params(win, client.offset_encoding or "utf-16")
2931
params.context = { only = { "source.organizeImports" } }
30-
client.request(ms.textDocument_codeAction, params, handler, bufnr)
32+
client:request(ms.textDocument_codeAction, params, handler, bufnr)
3133
end
3234

3335
-- Checks if the given buffer has any lsp clients that support the given method.
@@ -42,8 +44,8 @@ end
4244

4345
---@param bufnr number
4446
---@param method string
45-
---@param apply lsp.Apply
46-
---@param filter? lsp.Filter
47+
---@param apply fun(client: vim.lsp.Client, bufnr: number)
48+
---@param filter? fun(client: vim.lsp.Client): boolean?
4749
local on_clients = function(bufnr, method, apply, filter)
4850
local clients = vim.lsp.get_clients({ bufnr = bufnr, method = method })
4951
if not filter then
@@ -67,7 +69,7 @@ M.setup = function()
6769
if client == nil then
6870
return
6971
end
70-
if client.supports_method(ms.textDocument_codeLens) then
72+
if client:supports_method(ms.textDocument_codeLens, vim.api.nvim_get_current_buf()) then
7173
vim.lsp.inlay_hint.enable(true)
7274
end
7375
end,
@@ -78,7 +80,7 @@ M.setup = function()
7880
if client == nil then
7981
return
8082
end
81-
if client.supports_method(ms.textDocument_codeLens) then
83+
if client:supports_method(ms.textDocument_codeLens, vim.api.nvim_get_current_buf()) then
8284
vim.lsp.codelens.clear(client.id)
8385
end
8486
end,
@@ -87,7 +89,7 @@ M.setup = function()
8789

8890
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
8991
callback = function()
90-
---@type lsp.Apply
92+
---@type fun(client: vim.lsp.Client, bufnr: number)
9193
local format = function(client, bufnr)
9294
if client.server_capabilities.documentFormattingProvider then
9395
vim.lsp.buf.format({
@@ -106,7 +108,7 @@ M.setup = function()
106108
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
107109
callback = function()
108110
local bufnr = vim.api.nvim_get_current_buf()
109-
---@type lsp.Filter
111+
---@type fun(client: vim.lsp.Client): boolean?
110112
local filter = function(client)
111113
-- lua_ls freaks out when you ask it to organize imports.
112114
return client.name ~= "lua_ls"

modules/neovim/config/lua/lsp_keymaps.lua

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,6 @@ local keymap = function(lhs, rhs, bufnr)
1212
})
1313
end
1414

15-
--- Add an insert keymap.
16-
---@param lhs string Keymap
17-
---@param rhs function Action
18-
---@param bufnr number Buffer number
19-
local ikeymap = function(lhs, rhs, bufnr)
20-
vim.keymap.set("i", lhs, rhs, {
21-
noremap = true,
22-
silent = true,
23-
buffer = bufnr,
24-
})
25-
end
26-
27-
local is_v10 = vim.fn.has("nvim-0.10") == 1
28-
2915
local telescope = function(action)
3016
return function()
3117
local ivy = require("telescope.themes").get_ivy()
@@ -38,39 +24,35 @@ end
3824
M.on_attach = function(bufnr)
3925
keymap("gd", telescope("definitions"), bufnr)
4026
keymap("grr", telescope("references"), bufnr)
41-
keymap("<leader>ls", telescope("document_symbols"), bufnr)
42-
keymap("<leader>lS", telescope("workspace_symbols"), bufnr)
43-
keymap("<C-s>", vim.lsp.buf.signature_help, bufnr)
44-
ikeymap("<C-s>", vim.lsp.buf.signature_help, bufnr)
45-
keymap("gi", telescope("implementations"), bufnr)
27+
keymap("gO", telescope("document_symbols"), bufnr)
28+
keymap("gri", telescope("implementations"), bufnr)
4629
keymap("gD", vim.lsp.buf.declaration, bufnr)
4730
keymap("K", vim.lsp.buf.hover, bufnr)
4831
keymap("<leader>D", telescope("type_definitions"), bufnr)
49-
keymap("grn", vim.lsp.buf.rename, bufnr)
50-
keymap("gra", vim.lsp.buf.code_action, bufnr)
5132
keymap("grl", vim.lsp.codelens.run, bufnr)
5233
keymap("gl", vim.diagnostic.open_float, bufnr)
5334
keymap("[d", function()
54-
if is_v10 then
55-
vim.diagnostic.goto_prev()
56-
else
57-
vim.diagnostic.jump({ count = -1 })
58-
end
35+
vim.diagnostic.jump({ count = -1 })
5936
vim.cmd("norm zz")
6037
end, bufnr)
6138
keymap("]d", function()
62-
if is_v10 then
63-
vim.diagnostic.goto_next()
64-
else
65-
vim.diagnostic.jump({ count = 1 })
66-
end
39+
vim.diagnostic.jump({ count = 1 })
6740
vim.cmd("norm zz")
6841
end, bufnr)
6942

7043
keymap("<leader>v", function()
7144
vim.cmd("vsplit | lua vim.lsp.buf.definition()")
7245
vim.cmd("norm zz")
7346
end, bufnr)
47+
48+
keymap("<leader>ls", function()
49+
-- XXX: remove soon
50+
vim.notify("Use gO instead")
51+
end, bufnr)
52+
keymap("gi", function()
53+
-- XXX: remove soon
54+
vim.notify("Use gri instead")
55+
end, bufnr)
7456
end
7557

7658
return M

modules/neovim/config/lua/user/keymaps.lua

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ keymap("n", "<leader>n", ":enew<CR>", opts)
1818
-- quicklists
1919
keymap("n", "<leader>co", ":copen<CR>", opts)
2020
keymap("n", "<leader>cc", ":cclose<CR>", opts)
21-
keymap("n", "[q", ":cprevious<CR>zz", opts)
22-
keymap("n", "]q", ":cnext<CR>zz", opts)
2321

2422
-- Resize with arrows
2523
keymap("n", "<A-Up>", ":resize +2<CR>", opts)
@@ -28,7 +26,7 @@ keymap("n", "<A-Left>", ":vertical resize -2<CR>", opts)
2826
keymap("n", "<A-Right>", ":vertical resize +2<CR>", opts)
2927

3028
-- buffer killing
31-
keymap("n", "<leader>q", ":Bdelete<CR>", opts) -- delete current buffer
29+
keymap("n", "<leader>q", ":Bdelete<CR>", opts) -- delete current buffer
3230
keymap("n", "<leader>bad", ":%bd!<cr>:intro<cr>", opts) -- delete all buffers
3331
-- delete surrounding buffers, make sure to keep the cursor position
3432
keymap("n", "<leader>bsd", function()
@@ -61,10 +59,6 @@ keymap("n", "<C-i>", "<C-i>zz", opts)
6159
keymap("n", "Q", "q", opts)
6260
keymap("n", "q", "<Nop>", opts)
6361

64-
-- Insert empty blank line above/bellow
65-
keymap("n", "]<Space>", "m`o<Esc>``", opts)
66-
keymap("n", "[<Space>", "m`O<Esc>``", opts)
67-
6862
-- system clipboard integration
6963
keymap("n", "<leader>y", '"+y', opts)
7064
keymap("n", "<leader>Y", '"+Y', opts)

modules/neovim/config/lua/user/lsp.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
local ms = require("vim.lsp.protocol").Methods
21
local keymaps = require("lsp_keymaps")
32
require("lsp_autocommands").setup()
43

@@ -181,8 +180,8 @@ vim.diagnostic.config({
181180
float = float_config,
182181
})
183182

184-
vim.lsp.handlers[ms.textDocument_hover] = vim.lsp.with(vim.lsp.handlers.hover, float_config)
185-
vim.lsp.handlers[ms.textDocument_signatureHelp] = vim.lsp.with(vim.lsp.handlers.signature_help, float_config)
183+
vim.lsp.buf.hover(float_config)
184+
vim.lsp.buf.signature_help(float_config)
186185
vim.highlight.priorities.semantic_tokens = 95
187186

188187
-- set up diagnostic signs

modules/neovim/config/lua/user/notify.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
local notify = require("notify")
2+
---@diagnostic disable-next-line: missing-fields
23
notify.setup({
34
render = "compact",
45
stages = "static",

0 commit comments

Comments
 (0)