From cd8f609520616454fca8a52de517c5d268ca761d Mon Sep 17 00:00:00 2001 From: jdrouhard Date: Sat, 27 Jun 2026 09:46:22 -0500 Subject: [PATCH] fix(lsp): process semantic tokens LspNotify callback only when attached #40450 Problem: LspNotify will fire for any attached client. If there's at least two clients where one has semantic tokens enabled and one that doesn't, the disabled one will get the LspNotify requests but won't have a client state. Solution: Only process LspNotify autocmds if there's a client state to act on. Fixes #40448 --- runtime/lua/vim/lsp/semantic_tokens.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/runtime/lua/vim/lsp/semantic_tokens.lua b/runtime/lua/vim/lsp/semantic_tokens.lua index b985a00762..41b99e0321 100644 --- a/runtime/lua/vim/lsp/semantic_tokens.lua +++ b/runtime/lua/vim/lsp/semantic_tokens.lua @@ -213,6 +213,11 @@ function STHighlighter:new(bufnr) nvim_on('LspNotify', self.augroup, { buf = self.bufnr }, function(opts) local client_id = opts.data.client_id ---@type integer + + if not self.client_state[client_id] then + return + end + if opts.data.method == 'textDocument/didClose' then self:reset(client_id) end