Skip to content

Commit c39f215

Browse files
committed
Guard documentSymbol call with checking capability
1 parent 54f48eb commit c39f215

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

lua/lsp-status/current_function.lua

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,25 @@ local function current_function_callback(_, result)
5757
end
5858
end
5959

60+
local function first_capable_client(bufnr, capability)
61+
local clients = vim.lsp.buf_get_clients(bufnr)
62+
for _, client in pairs(clients) do
63+
if client.resolved_capabilities[capability] then
64+
return client
65+
end
66+
end
67+
end
68+
6069
local function update_current_function()
61-
local params = { textDocument = lsp_util.make_text_document_params() }
62-
vim.lsp.buf_request(0, 'textDocument/documentSymbol', params, util.mk_handler(current_function_callback))
70+
local client = first_capable_client(0, "document_symbol")
71+
if client then
72+
local params = { textDocument = lsp_util.make_text_document_params() }
73+
client.request('textDocument/documentSymbol', params, util.mk_handler(current_function_callback), 0)
74+
else
75+
-- clear current function so we don't show stale information
76+
vim.b.lsp_current_function = ''
77+
redraw.redraw()
78+
end
6379
end
6480

6581
local M = {

0 commit comments

Comments
 (0)