Skip to content

Commit c6add8c

Browse files
dam9000Matthew Lemon
authored andcommitted
Move LspDetach handler near kickstart-lsp-highlight group (nvim-lua#900)
Moved to make sure the kickstart-lsp-highlight group exists when the LspDetach handler is invoked. The LspDetach handler is used to clean up any lsp highlights that were enabled by CursorHold if the LSP is stopped or crashed.
1 parent f489c7f commit c6add8c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

init.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,14 @@ require('lazy').setup({
818818
group = highlight_augroup,
819819
callback = vim.lsp.buf.clear_references,
820820
})
821+
822+
vim.api.nvim_create_autocmd('LspDetach', {
823+
group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }),
824+
callback = function(event2)
825+
vim.lsp.buf.clear_references()
826+
vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf }
827+
end,
828+
})
821829
end
822830

823831
-- The following autocommand is used to enable inlay hints in your
@@ -832,14 +840,6 @@ require('lazy').setup({
832840
end,
833841
})
834842

835-
vim.api.nvim_create_autocmd('LspDetach', {
836-
group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }),
837-
callback = function(event)
838-
vim.lsp.buf.clear_references()
839-
vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event.buf }
840-
end,
841-
})
842-
843843
-- LSP servers and clients are able to communicate to each other what features they support.
844844
-- By default, Neovim doesn't support everything that is in the LSP specification.
845845
-- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities.

0 commit comments

Comments
 (0)