fix(lsp): fix deprecated warnings related to lsp client

This commit is contained in:
Folke Lemaitre 2025-09-15 07:42:46 +02:00
parent bc0630e43b
commit 07fefd2a99
No known key found for this signature in database
GPG key ID: 9B52594D560070AB
2 changed files with 12 additions and 5 deletions

View file

@ -43,7 +43,7 @@ local function wrap(client)
if client.wrapped then
return client
end
local methods = { "request", "supports_method", "cancel_request" }
local methods = { "request", "supports_method", "cancel_request", "notify" }
-- old style
return setmetatable({ wrapped = true }, {
__index = function(_, k)

View file

@ -106,10 +106,17 @@ function M.is_enabled(opts)
if not config.filter(buf) then
return false
end
local clients = (vim.lsp.get_clients or vim.lsp.get_active_clients)({ bufnr = buf })
clients = vim.tbl_filter(function(client)
return client.supports_method("textDocument/documentHighlight", { bufnr = buf })
end, clients)
local clients = {} ---@type vim.lsp.Client[]
if vim.fn.has("nvim-0.11") == 1 then
clients = vim.lsp.get_clients({ bufnr = buf, method = "textDocument/documentHighlight" })
else
clients = (vim.lsp.get_clients or vim.lsp.get_active_clients)({ bufnr = buf })
clients = vim.tbl_filter(function(client)
return client.supports_method("textDocument/documentHighlight", { bufnr = buf })
end, clients)
end
return #clients > 0
end