Skip to content

Commit 43c47eb

Browse files
authored
fix(lsp): support multiple servers for dynamic symbols (#3248)
1 parent 3bb24bb commit 43c47eb

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

lua/telescope/builtin/__lsp.lua

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -421,13 +421,19 @@ local function get_workspace_symbols_requester(bufnr, opts)
421421
return function(prompt)
422422
local tx, rx = channel.oneshot()
423423
cancel()
424-
_, cancel = vim.lsp.buf_request(bufnr, "workspace/symbol", { query = prompt }, tx)
424+
cancel = vim.lsp.buf_request_all(bufnr, "workspace/symbol", { query = prompt }, tx)
425425

426-
-- Handle 0.5 / 0.5.1 handler situation
427-
local err, res = rx()
428-
assert(not err, err)
426+
local results = rx() ---@type table<integer, {error: lsp.ResponseError?, result: lsp.WorkspaceSymbol?}>
427+
local locations = {} ---@type vim.lsp.util.locations_to_items.ret[]
428+
429+
for _, client_res in pairs(results) do
430+
if client_res.error then
431+
vim.api.nvim_err_writeln("Error when executing workspace/symbol : " .. client_res.error.message)
432+
elseif client_res.result ~= nil then
433+
vim.list_extend(locations, vim.lsp.util.symbols_to_items(client_res.result, bufnr))
434+
end
435+
end
429436

430-
local locations = vim.lsp.util.symbols_to_items(res or {}, bufnr) or {}
431437
if not vim.tbl_isempty(locations) then
432438
locations = utils.filter_symbols(locations, opts, symbols_sorter) or {}
433439
end

0 commit comments

Comments
 (0)