Skip to content

fix(rename): use colon syntax for LSP client methods and update get_clients#2769

Open
lgick wants to merge 2 commits intofolke:mainfrom
lgick:fix-lsp-deprecations
Open

fix(rename): use colon syntax for LSP client methods and update get_clients#2769
lgick wants to merge 2 commits intofolke:mainfrom
lgick:fix-lsp-deprecations

Conversation

@lgick
Copy link

@lgick lgick commented Mar 15, 2026

Description

This PR fixes deprecation warnings appearing in Neovim nightly (0.11+) when renaming files.

Changes:

  • Replaced client.supports_method, client.request_sync, and client.notify with the method call syntax client:method(...).
  • Replaced the deprecated vim.lsp.get_active_clients() with vim.lsp.get_clients().

These changes align with the latest Neovim LSP API requirements.

Related Issue(s)

Fixes deprecation warnings reported by :checkhealth.

Screenshots

N/A (LSP API update)

@github-actions github-actions bot added rename size/m Medium PR (<50 lines changed) labels Mar 15, 2026
@dpetka2001
Copy link
Contributor

This is a breaking change and will drop support for Neovim versions <0.11. No idea until which version maintainer wants to support. Current supported version is 0.9.4 according to README.

But an alternative would be to export

local function wrap(client)
local meta = getmetatable(client)
if meta and meta.request then
return client
end
---@diagnostic disable-next-line: undefined-field
if client.wrapped then
return client
end
local methods = { "request", "supports_method", "cancel_request", "notify" }
-- old style
return setmetatable({ wrapped = true }, {
__index = function(_, k)
if k == "supports_method" then
-- supports_method doesn't support the bufnr argument
return function(_, method)
return client[k](method)
end
end
if vim.tbl_contains(methods, k) then
return function(_, ...)
return client[k](...)
end
end
return client[k]
end,
})
end
into snacks/util/init.lua and then use that. Also I do not get any deprecation warnings about vim.lsp.get_active_clients() in checkhealth. Only inline diagnostics in the file itself, but that should not be really a problem since it depends on the Neovim version you have installed.

@github-actions github-actions bot added picker size/l Large PR (<100 lines changed) labels Mar 16, 2026
@lgick
Copy link
Author

lgick commented Mar 16, 2026

Done! I exported the existing wrap function from picker/source/lsp/init.lua into snacks/util/init.lua as you suggested, and updated both picker and rename to use Snacks.util.wrap. Also reverted the get_clients fallback for Neovim 0.9 compatibility.

@dpetka2001
Copy link
Contributor

Please do note i'm just a simple user and under no circumstances do i make decisions in this project. My previous comment was more like a suggestion/note. Maybe the maintainer would be in favor of dropping support for Neovim <0.11. I've literally no idea.

He's the one with final say and make final decision.

@lgick
Copy link
Author

lgick commented Mar 16, 2026

Thanks for the suggestion, it was helpful 🤝

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

picker rename size/l Large PR (<100 lines changed) size/m Medium PR (<50 lines changed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants