Skip to content

Commit

Permalink
fix(toggles): semantic tokens API requires real bufnr
Browse files Browse the repository at this point in the history
  • Loading branch information
mehalter committed May 22, 2024
1 parent b967bde commit af4485f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lua/astrolsp/toggles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@ function M.buffer_semantic_tokens(bufnr, silent)
-- TODO: remove check after dropping support for Neovim v0.9
---@diagnostic disable-next-line: deprecated
for _, client in ipairs((vim.lsp.get_clients or vim.lsp.get_active_clients) { bufnr = bufnr }) do
if client.server_capabilities.semanticTokensProvider then
vim.lsp.semantic_tokens[vim.b[bufnr].semantic_tokens and "start" or "stop"](bufnr, client.id)
if client.supports_method "textDocument/semanticTokens/full" then
-- HACK: `semantic_tokens.start/stop` don't support 0 for current buffer
local real_bufnr = bufnr == 0 and vim.api.nvim_get_current_buf() or bufnr
vim.lsp.semantic_tokens[vim.b[bufnr].semantic_tokens and "start" or "stop"](real_bufnr, client.id)
vim.lsp.semantic_tokens.force_refresh(bufnr)
toggled = true
end
end
Expand Down

0 comments on commit af4485f

Please sign in to comment.