summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorovikk13 <asmund@vaaland.org>2021-04-03 19:11:38 +0200
committerGitHub <noreply@github.com>2021-04-03 20:11:38 +0300
commit89a6161c81a516c4e2fe80a3365f774961ac9b9d (patch)
treeef8b4a3c51fe67b178540e1a1fc2c51638d85e25 /lua
parent2c4efc2f8af0575526f7b5dcc35fba9e0f1cc944 (diff)
Fix #707: lsp_workspace_symbols add support for multiple clients. (#718)
Diffstat (limited to 'lua')
-rw-r--r--lua/telescope/builtin/lsp.lua20
1 files changed, 9 insertions, 11 deletions
diff --git a/lua/telescope/builtin/lsp.lua b/lua/telescope/builtin/lsp.lua
index 99d5170..741eb36 100644
--- a/lua/telescope/builtin/lsp.lua
+++ b/lua/telescope/builtin/lsp.lua
@@ -184,22 +184,20 @@ lsp.workspace_symbols = function(opts)
local params = {query = opts.query or ''}
local results_lsp = vim.lsp.buf_request_sync(0, "workspace/symbol", params, opts.timeout or 10000)
- -- Clangd returns { { result = {} } } for query=''
- if not results_lsp or vim.tbl_isempty(results_lsp) or
- vim.tbl_isempty(results_lsp[1]) or vim.tbl_isempty(results_lsp[1].result) then
- print("No results from workspace/symbol. Maybe try a different query: " ..
- "Telescope lsp_workspace_symbols query=example")
- return
- end
-
local locations = {}
- for _, server_results in pairs(results_lsp) do
- if server_results.result then
- vim.list_extend(locations, vim.lsp.util.symbols_to_items(server_results.result, 0) or {})
+
+ if results_lsp and not vim.tbl_isempty(results_lsp) then
+ for _, server_results in pairs(results_lsp) do
+ -- Some LSPs (like Clangd and intelephense) might return { { result = {} } }, so make sure we have result
+ if server_results and server_results.result and not vim.tbl_isempty(server_results.result) then
+ vim.list_extend(locations, vim.lsp.util.symbols_to_items(server_results.result, 0) or {})
+ end
end
end
if vim.tbl_isempty(locations) then
+ print("No results from workspace/symbol. Maybe try a different query: " ..
+ "Telescope lsp_workspace_symbols query=example")
return
end