aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorRaphael <glepnir@neovim.pro>2022-12-27 11:59:28 +0800
committerGitHub <noreply@github.com>2022-12-27 11:59:28 +0800
commit95ae63dcefe91dae921dded0adf85343b288c491 (patch)
treeadab4f22eaa0149d05c2d5ad9a8415a01b8ee5a7 /lua
parentfix: check workspace after client initial (#2356) (diff)
downloadnvim-lspconfig-95ae63dcefe91dae921dded0adf85343b288c491.tar
nvim-lspconfig-95ae63dcefe91dae921dded0adf85343b288c491.tar.gz
nvim-lspconfig-95ae63dcefe91dae921dded0adf85343b288c491.tar.bz2
nvim-lspconfig-95ae63dcefe91dae921dded0adf85343b288c491.tar.lz
nvim-lspconfig-95ae63dcefe91dae921dded0adf85343b288c491.tar.xz
nvim-lspconfig-95ae63dcefe91dae921dded0adf85343b288c491.tar.zst
nvim-lspconfig-95ae63dcefe91dae921dded0adf85343b288c491.zip
fix: generate correct workspace didchange request params (#2361)
* fix: generate correct workspace didchange request params * fix: logic rewrite * fix: logic rewrite * fix: spell
Diffstat (limited to 'lua')
-rw-r--r--lua/lspconfig/util.lua135
1 files changed, 67 insertions, 68 deletions
diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua
index 92594077..1426b6b1 100644
--- a/lua/lspconfig/util.lua
+++ b/lua/lspconfig/util.lua
@@ -271,6 +271,56 @@ function M.server_per_root_dir_manager(make_config)
local new_config = make_config(root_dir)
local client = get_client_from_cache(new_config)
+ --TODO(glepnir): do we need check language server support the workspaceFOlders?
+ --some server support it but the it not show in server_capabilities
+ local register_workspace_folders = function(client_instance)
+ local params = {
+ event = {
+ added = { { uri = vim.uri_from_fname(root_dir), name = root_dir } },
+ removed = {},
+ },
+ }
+ for _, schema in ipairs(client_instance.workspace_folders or {}) do
+ if schema.name == root_dir then
+ return
+ end
+ end
+ client_instance.rpc.notify('workspace/didChangeWorkspaceFolders', params)
+ if not client_instance.workspace_folders then
+ client.workspace_folders = {}
+ end
+ table.insert(client_instance.workspace_folders, params.event.added[1])
+ if not clients[root_dir] then
+ clients[root_dir] = {}
+ end
+ table.insert(clients[root_dir], client_instance.id)
+ end
+
+ local attach_after_client_initialized = function(buffer_nr, client_instance)
+ local timer = vim.loop.new_timer()
+ timer:start(
+ 0,
+ 10,
+ vim.schedule_wrap(function()
+ if client_instance.initialized and not timer:is_closing() then
+ lsp.buf_attach_client(buffer_nr, client_instance.id)
+ register_workspace_folders(client_instance)
+ timer:stop()