From dfff482efe3b541007f25c9c87f88b9b3769b370 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 19:00:51 +0200 Subject: [PATCH] fix(lsp): remove superfluous on_detach callback from semantic tokens module (#29188) LspDetach is now triggered by the main on_detach callback that is added when an LSP client is attached to a buffer. The semantic_tokens module already includes a LspDetach handler that does the right thing. When the LspDetach trigger was added to the main LSP on_detach, it created a race condition in semantic tokens when a buffer was deleted that would trigger both its own on_detach and the LspDetach handlers. If the former came last, an error was thrown trying to delete a non-existent augroup (destroy() was being called twice). (cherry picked from commit 43581011e41b54473427c2e90450a4f3126b7e66) Co-authored-by: jdrouhard --- runtime/lua/vim/lsp/semantic_tokens.lua | 6 ------ 1 file changed, 6 deletions(-) diff --git a/runtime/lua/vim/lsp/semantic_tokens.lua b/runtime/lua/vim/lsp/semantic_tokens.lua index be2d6ee0ae..97ea499fe7 100644 --- a/runtime/lua/vim/lsp/semantic_tokens.lua +++ b/runtime/lua/vim/lsp/semantic_tokens.lua @@ -197,12 +197,6 @@ function STHighlighter.new(bufnr) highlighter:send_request() end end, - on_detach = function(_, buf) - local highlighter = STHighlighter.active[buf] - if highlighter then - highlighter:destroy() - end - end, }) api.nvim_create_autocmd({ 'BufWinEnter', 'InsertLeave' }, {