Make conditional check top-level

Thanks to Echasnovski (a Reddit comment he made) to avoid having the
conditional inside the function body and be executed every time the
function is called.
This commit is contained in:
Iordanis Petkakis 2025-04-18 10:16:51 +03:00
parent 6e21ac4962
commit 00883a477b

View file

@ -5,10 +5,12 @@ local M = {}
---@param method string
---@param bufnr? integer
local function supports_method(client, method, bufnr)
if vim.fn.has("nvim-0.11") == 0 then
return client:supports_method(method, bufnr)
end
if vim.fn.has("nvim-0.11") == 0 then
function supports_method(client, method, bufnr)
return client.supports_method and client.supports_method(method, { bufnr = bufnr })
end
return client:supports_method(method, bufnr) and client:supports_method(method, bufnr)
end
---@alias lsp.Client.filter {id?: number, bufnr?: number, name?: string, method?: string, filter?:fun(client: lsp.Client):boolean}