@@ -8,14 +8,6 @@ local make_entry = require "fzf-lua.make_entry"
88
99local M = {}
1010
11- local function handler_capability (handler )
12- if utils .__HAS_NVIM_08 then
13- return handler .server_capability
14- else
15- return handler .resolved_capability
16- end
17- end
18-
1911local function check_capabilities (handler , silent )
2012 local clients = utils .lsp_get_clients ({ bufnr = core .CTX ().bufnr })
2113
@@ -24,25 +16,14 @@ local function check_capabilities(handler, silent)
2416 local num_clients = 0
2517
2618 for _ , client in pairs (clients ) do
27- if utils .__HAS_NVIM_09 then
28- -- https://github.com/neovim/neovim/blob/65738202f8be3ca63b75197d48f2c7a9324c035b/runtime/doc/news.txt#L118-L122
29- -- Dynamic registration of LSP capabilities. An implication of this change is
30- -- that checking a client's `server_capabilities` is no longer a sufficient
31- -- indicator to see if a server supports a feature. Instead use
32- -- `client.supports_method(<method>)`. It considers both the dynamic
33- -- capabilities and static `server_capabilities`.
34- if client :supports_method (handler .prep or handler .method ) then
35- num_clients = num_clients + 1
36- end
37- elseif utils .__HAS_NVIM_08 then
38- if client .server_capabilities [handler .server_capability ] then
39- num_clients = num_clients + 1
40- end
41- else
42- --- @diagnostic disable-next-line : undefined-field
43- if client .resolved_capabilities [handler .resolved_capability ] then
44- num_clients = num_clients + 1
45- end
19+ -- https://github.com/neovim/neovim/blob/65738202f8be3ca63b75197d48f2c7a9324c035b/runtime/doc/news.txt#L118-L122
20+ -- Dynamic registration of LSP capabilities. An implication of this change is
21+ -- that checking a client's `server_capabilities` is no longer a sufficient
22+ -- indicator to see if a server supports a feature. Instead use
23+ -- `client.supports_method(<method>)`. It considers both the dynamic
24+ -- capabilities and static `server_capabilities`.
25+ if client :supports_method (handler .prep or handler .method ) then
26+ num_clients = num_clients + 1
4627 end
4728 end
4829
@@ -318,78 +299,67 @@ end
318299local handlers = {
319300 [" code_actions" ] = {
320301 label = " Code Actions" ,
321- resolved_capability = " code_action" ,
322302 server_capability = " codeActionProvider" ,
323303 method = " textDocument/codeAction" ,
324304 handler = code_action_handler
325305 },
326306 [" references" ] = {
327307 label = " References" ,
328- resolved_capability = " find_references" ,
329308 server_capability = " referencesProvider" ,
330309 method = " textDocument/references" ,
331310 handler = location_handler
332311 },
333312 [" definitions" ] = {
334313 label = " Definitions" ,
335- resolved_capability = " goto_definition" ,
336314 server_capability = " definitionProvider" ,
337315 method = " textDocument/definition" ,
338316 handler = location_handler
339317 },
340318 [" declarations" ] = {
341319 label = " Declarations" ,
342- resolved_capability = " goto_declaration" ,
343320 server_capability = " declarationProvider" ,
344321 method = " textDocument/declaration" ,
345322 handler = location_handler
346323 },
347324 [" typedefs" ] = {
348325 label = " Type Definitions" ,
349- resolved_capability = " type_definition" ,
350326 server_capability = " typeDefinitionProvider" ,
351327 method = " textDocument/typeDefinition" ,
352328 handler = location_handler
353329 },
354330 [" implementations" ] = {
355331 label = " Implementations" ,
356- resolved_capability = " implementation" ,
357332 server_capability = " implementationProvider" ,
358333 method = " textDocument/implementation" ,
359334 handler = location_handler
360335 },
361336 [" document_symbols" ] = {
362337 label = " Document Symbols" ,
363- resolved_capability = " document_symbol" ,
364338 server_capability = " documentSymbolProvider" ,
365339 method = " textDocument/documentSymbol" ,
366340 handler = symbol_handler
367341 },
368342 [" workspace_symbols" ] = {
369343 label = " Workspace Symbols" ,
370- resolved_capability = " workspace_symbol" ,
371344 server_capability = " workspaceSymbolProvider" ,
372345 method = " workspace/symbol" ,
373346 handler = symbol_handler
374347 },
375348 [" live_workspace_symbols" ] = {
376349 label = " Workspace Symbols" ,
377- resolved_capability = " workspace_symbol" ,
378350 server_capability = " workspaceSymbolProvider" ,
379351 method = " workspace/symbol" ,
380352 handler = symbol_handler
381353 },
382354 [" incoming_calls" ] = {
383355 label = " Incoming Calls" ,
384- resolved_capability = " call_hierarchy" ,
385356 server_capability = " callHierarchyProvider" ,
386357 method = " callHierarchy/incomingCalls" ,
387358 prep = " textDocument/prepareCallHierarchy" ,
388359 handler = call_hierarchy_handler
389360 },
390361 [" outgoing_calls" ] = {
391362 label = " Outgoing Calls" ,
392- resolved_capability = " call_hierarchy" ,
393363 server_capability = " callHierarchyProvider" ,
394364 method = " callHierarchy/outgoingCalls" ,
395365 prep = " textDocument/prepareCallHierarchy" ,
@@ -709,7 +679,7 @@ M.finder = function(opts)
709679 opts .silent = opts .silent == nil and true or opts .silent
710680 opts .no_autoclose = true
711681 opts .lsp_handler = handlers [method ]
712- opts .lsp_handler .capability = handler_capability ( opts .lsp_handler )
682+ opts .lsp_handler .capability = opts .lsp_handler . server_capability
713683 opts .lsp_params = lsp_params -- reset previous calls params if existed
714684
715685 -- returns nil for no client attached, false for unsupported capability
@@ -1006,7 +976,7 @@ local function wrap_fn(key, fn)
1006976 return function (opts )
1007977 opts = opts or {}
1008978 opts .lsp_handler = handlers [key ]
1009- opts .lsp_handler .capability = handler_capability ( opts .lsp_handler )
979+ opts .lsp_handler .capability = opts .lsp_handler . server_capability
1010980
1011981 -- check_capabilities will print the appropriate warning
1012982 if not check_capabilities (opts .lsp_handler ) then
0 commit comments