Skip to content

Commit

Permalink
client: use class methods on nvim-0.11 (fix #209)
Browse files Browse the repository at this point in the history
  • Loading branch information
mochaaP committed Nov 29, 2024
1 parent 6be90f8 commit 94d024e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lua/null-ls/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ local get_root_dir = function(bufnr, cb)
end
end

---@param new_client vim.lsp.Client
local on_init = function(new_client, initialize_result)
local capability_is_disabled = function(method)
-- TODO: extract map to prevent future issues
Expand All @@ -56,7 +57,8 @@ local on_init = function(new_client, initialize_result)
end

-- null-ls broadcasts all capabilities on launch, so this lets us have finer control
new_client.supports_method = function(method)
---@param method string
local supports_method = function(method)
-- allow users to specifically disable capabilities
if capability_is_disabled(method) then
return false
Expand All @@ -72,6 +74,14 @@ local on_init = function(new_client, initialize_result)
return methods.lsp[method] ~= nil
end

if vim.fn.has("nvim-0.11") == 1 then
new_client.supports_method = function(_, method)
return supports_method(method)
end
else
new_client.supports_method = supports_method
end

if c.get().on_init then
c.get().on_init(new_client, initialize_result)
end
Expand Down

0 comments on commit 94d024e

Please sign in to comment.