aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamjan 9000 <damjan.9000@gmail.com>2024-04-22 18:07:12 +0200
committerDamjan 9000 <damjan.9000@gmail.com>2024-04-22 18:07:12 +0200
commitb939e2f5a1e956a972f8af8bd73ff66a19d700f3 (patch)
treec28b60a9f3efda72b3bef9110b1f1405666b2c88
parent74136a1db76a314a7da6ade76189732677aedc52 (diff)
parent81f270a704ffe428ffe221122e0b1604567ae6cd (diff)
Merge 'upstream' Fix highlight errors when lsp crash or stop
-rw-r--r--lua/kickstart/plugins/lspconfig.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/lua/kickstart/plugins/lspconfig.lua b/lua/kickstart/plugins/lspconfig.lua
index 45fb5ed..49be0b4 100644
--- a/lua/kickstart/plugins/lspconfig.lua
+++ b/lua/kickstart/plugins/lspconfig.lua
@@ -105,13 +105,16 @@ return {
-- When you move your cursor, the highlights will be cleared (the second autocommand).
local client = vim.lsp.get_client_by_id(event.data.client_id)
if client and client.server_capabilities.documentHighlightProvider then
+ local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = true })
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
buffer = event.buf,
+ group = highlight_augroup,
callback = vim.lsp.buf.document_highlight,
})
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
buffer = event.buf,
+ group = highlight_augroup,
callback = vim.lsp.buf.clear_references,
})
end
@@ -128,6 +131,14 @@ return {
end,
})
+ vim.api.nvim_create_autocmd('LspDetach', {
+ group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }),
+ callback = function(event)
+ vim.lsp.buf.clear_references()
+ vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event.buf }
+ end,
+ })
+
-- LSP servers and clients are able to communicate to each other what features they support.
-- By default, Neovim doesn't support everything that is in the LSP specification.
-- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities.