nvim: lsp: Fix error in LspDetach
Some language servers like HLS take longer to attach and if we exit soon before LSP attach had a chance to finish (may be?), server capabilities field does not seem to be valid in client object and we get the below error. Check if it valid first. Error detected while processing LspDetach Autocommands for "*": Error executing lua callback: /home/core/.config/nvim/lua/lsp.lua:215: attempt to index field 'server_capabilities' (a nil value) stack traceback: /home/core/.config/nvim/lua/lsp.lua:215: in function </home/core/.config/nvim/lua/lsp.lua:209> [C]: in function 'nvim_exec_autocmds' /usr/local/share/nvim/runtime/lua/vim/lsp.lua:1140: in function </usr/local/share/nvim/runtime/lua/vim/lsp.lua:1139> Error executing lua callback: /home/core/.config/nvim/lua/lsp.lua:215: attempt to index field 'server_capabilities' (a nil value) stack traceback: /home/core/.config/nvim/lua/lsp.lua:215: in function </home/core/.config/nvim/lua/lsp.lua:209> [C]: in function 'nvim_exec_autocmds' /usr/local/share/nvim/runtime/lua/vim/lsp.lua:1140: in function </usr/local/share/nvim/runtime/lua/vim/lsp.lua:1139>
This commit is contained in:
parent
b752f2241f
commit
4d970ce70c
1 changed files with 1 additions and 1 deletions
|
@ -212,7 +212,7 @@ vim.api.nvim_create_autocmd("LspDetach", {
|
|||
|
||||
for _, mappings in pairs(lsp_key_mappings) do
|
||||
local capability, mode, lhs, _ = unpack(mappings)
|
||||
if client.server_capabilities[capability] then
|
||||
if client.server_capabilities and client.server_capabilities[capability] then
|
||||
vim.api.nvim_buf_del_keymap(bufnr, mode, lhs)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue