mirror of
https://github.com/neovim/neovim.git
synced 2026-05-23 21:30:11 +00:00
fix(lsp): handle self-mapped methods in supports_method #39383
Problem: The LSP client incorrectly checks for server capabilities when determining support for self-mapped methods (e.g., 'shutdown'), which do not have corresponding capabilities in the server's response. This leads to false negatives when checking if such methods are supported. This was handled correctly for dynamic registrations, but not for static. Methods such as 'shutdown', do not have a related server capability and should be assumed to be supported. Solution: Update the `supports_method` logic to always return true for self-mapped methods.
This commit is contained in:
@@ -1219,7 +1219,15 @@ function Client:supports_method(method, bufnr)
|
||||
bufnr = bufnr.bufnr
|
||||
end
|
||||
local required_capability = lsp.protocol._request_name_to_server_capability[method]
|
||||
if required_capability and vim.tbl_get(self.server_capabilities, unpack(required_capability)) then
|
||||
local is_self_mapping = required_capability
|
||||
and #required_capability == 1
|
||||
and required_capability[1] == method
|
||||
|
||||
if
|
||||
not is_self_mapping
|
||||
and required_capability
|
||||
and vim.tbl_get(self.server_capabilities, unpack(required_capability))
|
||||
then
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -1244,9 +1252,10 @@ function Client:supports_method(method, bufnr)
|
||||
return false
|
||||
end
|
||||
|
||||
-- if we don't know about the method, assume that the client supports it.
|
||||
-- This needs to be at the end, so that dynamic_capabilities are checked first
|
||||
return required_capability == nil
|
||||
-- If we don't know about the method, or if it is a self-mapping(method=required_capability)
|
||||
-- assume that the client supports it.
|
||||
-- This needs to be at the end, so that dynamic_capabilities are checked first.
|
||||
return required_capability == nil or is_self_mapping
|
||||
end
|
||||
|
||||
--- Executes callback fn for all registrations for a given LSP method.
|
||||
|
||||
Reference in New Issue
Block a user