Skip to content

Commit 94edb86

Browse files
committed
fix: use new vim.lsp.codelens api in neovim v0.12
1 parent 4a72ede commit 94edb86

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lua/astrolsp/init.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,12 @@ end
7777
---@param bufnr integer The buffer that the LSP client is attaching to
7878
function M.on_attach(client, bufnr)
7979
if client:supports_method("textDocument/codeLens", bufnr) and M.config.features.codelens then
80-
vim.lsp.codelens.refresh { bufnr = bufnr }
80+
-- TODO: remove check when dropping support for Neovim v0.11
81+
if vim.lsp.codelens.enable then
82+
vim.lsp.codelens.enable(true, { bufnr = bufnr })
83+
else
84+
vim.lsp.codelens.refresh { bufnr = bufnr }
85+
end
8186
end
8287

8388
local formatting_disabled = vim.tbl_get(M.config, "formatting", "disabled")

lua/astrolsp/toggles.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ end
9999
---@param silent? boolean if true then don't sent a notification
100100
function M.codelens(silent)
101101
features.codelens = not features.codelens
102-
if not features.codelens then vim.lsp.codelens.clear() end
102+
-- TODO: remove check when dropping support for Neovim v0.11
103+
if vim.lsp.codelens.enable then
104+
vim.lsp.codelens.enable(features.codelens)
105+
else
106+
if not features.codelens then vim.lsp.codelens.clear() end
107+
end
103108
ui_notify(silent, ("CodeLens %s"):format(bool2str(features.codelens)))
104109
end
105110

0 commit comments

Comments
 (0)