Skip to content

Commit 929bcbe

Browse files
dam9000afunkenbusch
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 ff1bfd5 commit 929bcbe

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
@@ -527,6 +527,14 @@ require('lazy').setup({
527527
group = highlight_augroup,
528528
callback = vim.lsp.buf.clear_references,
529529
})
530+
531+
vim.api.nvim_create_autocmd('LspDetach', {
532+
group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }),
533+
callback = function(event2)
534+
vim.lsp.buf.clear_references()
535+
vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf }
536+
end,
537+
})
530538
end
531539

532540
-- The following autocommand is used to enable inlay hints in your
@@ -541,14 +549,6 @@ require('lazy').setup({
541549
end,
542550
})
543551

544-
vim.api.nvim_create_autocmd('LspDetach', {
545-
group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }),
546-
callback = function(event)
547-
vim.lsp.buf.clear_references()
548-
vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event.buf }
549-
end,
550-
})
551-
552552
-- LSP servers and clients are able to communicate to each other what features they support.
553553
-- By default, Neovim doesn't support everything that is in the LSP specification.
554554
-- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities.

0 commit comments

Comments
 (0)