aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorRaphael <glepnir@neovim.pro>2022-12-10 11:00:24 +0800
committerGitHub <noreply@github.com>2022-12-10 11:00:24 +0800
commit3bb0c53b1df74d4b3b70d5939a015b19064a5a06 (patch)
tree3b3e05e2258e463a57b0ba12e8d336c61c22ee76 /lua
parentfix: check workspae folders follow nvim version (#2301) (diff)
downloadnvim-lspconfig-3bb0c53b1df74d4b3b70d5939a015b19064a5a06.tar
nvim-lspconfig-3bb0c53b1df74d4b3b70d5939a015b19064a5a06.tar.gz
nvim-lspconfig-3bb0c53b1df74d4b3b70d5939a015b19064a5a06.tar.bz2
nvim-lspconfig-3bb0c53b1df74d4b3b70d5939a015b19064a5a06.tar.lz
nvim-lspconfig-3bb0c53b1df74d4b3b70d5939a015b19064a5a06.tar.xz
nvim-lspconfig-3bb0c53b1df74d4b3b70d5939a015b19064a5a06.tar.zst
nvim-lspconfig-3bb0c53b1df74d4b3b70d5939a015b19064a5a06.zip
fix: check client is available and get client id from cache (#2303)
Diffstat (limited to 'lua')
-rw-r--r--lua/lspconfig/util.lua9
1 files changed, 5 insertions, 4 deletions
diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua
index 00f5a7a1..d4390e40 100644
--- a/lua/lspconfig/util.lua
+++ b/lua/lspconfig/util.lua
@@ -250,15 +250,16 @@ function M.server_per_root_dir_manager(make_config)
-- Check if we have a client already or start and store it.
if not client_id then
local new_config = make_config(root_dir)
- if clients[1] then
- local client = lsp.get_client_by_id(clients[1])
- if client.name == new_config.name then
+ if vim.tbl_count(clients) == 1 then
+ local id = vim.tbl_values(clients)[1]
+ local client = lsp.get_client_by_id(id)
+ if client and client.name == new_config.name then
local params = lsp.util.make_workspace_params(
{ { uri = vim.uri_from_fname(root_dir), name = root_dir } },
{ {} }
)
table.insert(client.workspace_folders, params.event.added[1])
- return clients[1]
+ return id
end
end
-- do nothing if the client is not enabled