File tree Expand file tree Collapse file tree
home/dot_config/exact_nvim/exact_plugin Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ vim.api.nvim_create_autocmd('LspAttach', {
2020 --- @type integer
2121 local highlight_group =
2222 vim .api .nvim_create_augroup (' LspDocumentHighlight' , { clear = false })
23+ local highlight_detach_group = vim .api .nvim_create_augroup (
24+ ' LspDocumentHighlightDetach' ,
25+ { clear = true }
26+ )
2327
2428 -- Clear existing highlights for this buffer.
2529 vim .api .nvim_clear_autocmds ({ buffer = args .buf , group = highlight_group })
@@ -35,6 +39,17 @@ vim.api.nvim_create_autocmd('LspAttach', {
3539 buffer = args .buf ,
3640 callback = vim .lsp .buf .clear_references ,
3741 })
42+
43+ vim .api .nvim_create_autocmd (' LspDetach' , {
44+ group = highlight_detach_group ,
45+ callback = function (event )
46+ vim .lsp .buf .clear_references ()
47+ vim .api .nvim_clear_autocmds ({
48+ group = highlight_group ,
49+ buffer = event .buf ,
50+ })
51+ end ,
52+ })
3853 end
3954 end ,
4055})
You can’t perform that action at this time.
0 commit comments