Skip to content

Commit cbd5f7d

Browse files
committed
modules/lsp/onAttach: fix bufnr and document event arg
`:h event-args`: https://neovim.io/doc/user/api.html#event-args `:h LspAttach`: https://neovim.io/doc/user/lsp.html#LspAttach Fixes #3319
1 parent ff0ccdf commit cbd5f7d

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

modules/lsp/on-attach.nix

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,25 @@ in
2929
{
3030
event = "LspAttach";
3131
group = "nixvim_lsp_on_attach";
32+
# `event` is documented in `:h event-args`:
33+
# • id: (number) autocommand id
34+
# • event: (string) name of the triggered event
35+
# • group: (number|nil) autocommand group id, if any
36+
# • file: (string) <afile> (not expanded to a full path)
37+
# • match: (string) <amatch> (expanded to a full path)
38+
# • buf: (number) <abuf>
39+
# • data: (any) arbitrary data passed from `:h nvim_exec_autocmds()`
40+
# see `:h LspAttach`
41+
#
42+
# `:h event-args`: https://neovim.io/doc/user/api.html#event-args
43+
# `:h LspAttach`: https://neovim.io/doc/user/lsp.html#LspAttach
3244
callback = lib.nixvim.mkRaw ''
33-
function(args)
45+
function(event)
3446
do
3547
-- client and bufnr are supplied to the builtin `on_attach` callback,
3648
-- so make them available in scope for our global `onAttach` impl
37-
local client = vim.lsp.get_client_by_id(args.data.client_id)
38-
local bufnr = args.bufnr
39-
49+
local client = vim.lsp.get_client_by_id(event.data.client_id)
50+
local bufnr = event.buf
4051
${cfg.onAttach}
4152
end
4253
end

0 commit comments

Comments
 (0)