Skip to content

Commit 45f35ad

Browse files
committed
fix: upstrean 0.10 API changes to inlay_hints
1 parent 6bbdb2b commit 45f35ad

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

lua/astrolsp/init.lua

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,6 @@ M.on_attach = function(client, bufnr)
9797
end
9898
end
9999

100-
if client.supports_method "textDocument/inlayHint" then
101-
if vim.b[bufnr].inlay_hints == nil then vim.b[bufnr].inlay_hints = M.config.features.inlay_hints end
102-
-- TODO: remove check after dropping support for Neovim v0.9
103-
if vim.lsp.inlay_hint and vim.b[bufnr].inlay_hints then vim.lsp.inlay_hint.enable(true, { bufnr = bufnr }) end
104-
end
105-
106100
if client.supports_method "textDocument/semanticTokens/full" and vim.lsp.semantic_tokens then
107101
if M.config.features.semantic_tokens then
108102
if vim.b[bufnr].semantic_tokens == nil then vim.b[bufnr].semantic_tokens = true end
@@ -232,6 +226,9 @@ function M.setup(opts)
232226
and not (vim.tbl_contains(disabled, client.name) or (type(filter) == "function" and not filter(client)))
233227
end
234228

229+
-- TODO: remove check when dropping support for Neovim v0.9
230+
if vim.lsp.inlay_hint then vim.lsp.inlay_hint.enable(M.config.features.inlay_hints ~= false) end
231+
235232
vim.api.nvim_create_autocmd("LspDetach", {
236233
group = vim.api.nvim_create_augroup("astrolsp_detach", { clear = true }),
237234
desc = "Clear state when language server is detached like LSP progress messages",

lua/astrolsp/toggles.lua

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,19 @@ end
4141
---@param bufnr? integer the buffer to toggle the clients on
4242
---@param silent? boolean if true then don't sent a notification
4343
function M.buffer_inlay_hints(bufnr, silent)
44-
bufnr = bufnr or 0
45-
vim.b[bufnr].inlay_hints = not vim.b[bufnr].inlay_hints
46-
-- TODO: remove check after dropping support for Neovim v0.9
4744
if vim.lsp.inlay_hint then
48-
vim.lsp.inlay_hint.enable(vim.b[bufnr].inlay_hints, { bufnr = bufnr })
49-
ui_notify(silent, ("Inlay hints %s"):format(bool2str(vim.b[bufnr].inlay_hints)))
45+
local filter = { bufnr = bufnr or 0 }
46+
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled(filter), filter)
47+
ui_notify(silent, ("Buffer inlay hints %s"):format(bool2str(vim.lsp.inlay_hint.is_enabled(filter))))
48+
end
49+
end
50+
51+
--- Toggle global LSP inlay hints
52+
---@param silent? boolean if true then don't sent a notification
53+
function M.inlay_hints(silent)
54+
if vim.lsp.inlay_hint then
55+
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
56+
ui_notify(silent, ("Global inlay hints %s"):format(bool2str(vim.lsp.inlay_hint.is_enabled())))
5057
end
5158
end
5259

0 commit comments

Comments
 (0)