From b03ff434790b42b03a6c34b97ba0c5dd0afe5142 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 9 Dec 2022 06:08:39 +0800 Subject: fix: add new root into the workspace folders (#2298) * fix: add the new root to workspaceFolders * fix: add the new root to workspaceFolders --- lua/lspconfig/util.lua | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'lua/lspconfig/util.lua') diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua index a1f04bec..00f5a7a1 100644 --- a/lua/lspconfig/util.lua +++ b/lua/lspconfig/util.lua @@ -250,12 +250,15 @@ 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 next(clients) ~= nil then - for _, id in pairs(clients) do - local client = lsp.get_client_by_id(id) - if client.name == new_config.name then - return id - end + if clients[1] then + local client = lsp.get_client_by_id(clients[1]) + if 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] end end -- do nothing if the client is not enabled -- cgit v1.2.3-70-g09d2