Skip to content

Commit 979c024

Browse files
committed
fix(toggles): only toggle language server semantic tokens in current buffer
1 parent efcc935 commit 979c024

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lua/astrolsp/toggles.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,17 @@ end
4141
function M.buffer_semantic_tokens(bufnr, silent)
4242
bufnr = bufnr or 0
4343
vim.b[bufnr].semantic_tokens = not vim.b[bufnr].semantic_tokens
44-
for _, client in ipairs(vim.lsp.get_clients()) do
44+
local toggled = false
45+
for _, client in ipairs(vim.lsp.get_clients { bufnr = bufnr }) do
4546
if client.server_capabilities.semanticTokensProvider then
4647
vim.lsp.semantic_tokens[vim.b[bufnr].semantic_tokens and "start" or "stop"](bufnr, client.id)
47-
ui_notify(silent, string.format("Buffer lsp semantic highlighting %s", bool2str(vim.b[bufnr].semantic_tokens)))
48+
toggled = true
4849
end
4950
end
51+
ui_notify(
52+
not toggled or silent,
53+
string.format("Buffer lsp semantic highlighting %s", bool2str(vim.b[bufnr].semantic_tokens))
54+
)
5055
end
5156

5257
--- Toggle codelens

0 commit comments

Comments
 (0)