diff options
author | Mathias Fußenegger <mfussenegger@users.noreply.github.com> | 2023-03-05 08:42:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-05 08:42:15 +0100 |
commit | ed05d38d9fa643c7e562b754c6cfed8b9da5c4d8 (patch) | |
tree | cdac4285adbf7903320465878e2e95f50b986e94 | |
parent | ac69ba5fa0081026f2c5e6e29d5788802479b7b9 (diff) | |
download | rneovim-ed05d38d9fa643c7e562b754c6cfed8b9da5c4d8.tar.gz rneovim-ed05d38d9fa643c7e562b754c6cfed8b9da5c4d8.tar.bz2 rneovim-ed05d38d9fa643c7e562b754c6cfed8b9da5c4d8.zip |
fix(lsp): don't monitor files if workspace_folders is nil (#22531)
Fixes:
Error SERVER_REQUEST_HANDLER_ERROR: "...di/dev/neovim/neovim/runtime/lua/vim/lsp/_watchfiles.lua
:200: bad argument #1 to 'ipairs' (table expected, got nil)"
Language servers can be started without root_dir or workspace_folders.
-rw-r--r-- | runtime/lua/vim/lsp/_watchfiles.lua | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/runtime/lua/vim/lsp/_watchfiles.lua b/runtime/lua/vim/lsp/_watchfiles.lua index 96d7fa1d35..533a955925 100644 --- a/runtime/lua/vim/lsp/_watchfiles.lua +++ b/runtime/lua/vim/lsp/_watchfiles.lua @@ -168,11 +168,11 @@ end M._watchfunc = (vim.fn.has('win32') == 1 or vim.fn.has('mac') == 1) and watch.watch or watch.poll ----@type table<number, table<number, function()>> client id -> registration id -> cancel function +---@type table<number, table<number, function[]>> client id -> registration id -> cancel function local cancels = vim.defaulttable() local queue_timeout_ms = 100 ----@type table<number, uv_timer_t> client id -> libuv timer which will send queued changes at its timeout +---@type table<number, uv.uv_timer_t> client id -> libuv timer which will send queued changes at its timeout local queue_timers = {} ---@type table<number, lsp.FileEvent[]> client id -> set of queued changes to send in a single LSP notification local change_queues = {} @@ -193,6 +193,9 @@ local to_lsp_change_type = { function M.register(reg, ctx) local client_id = ctx.client_id local client = vim.lsp.get_client_by_id(client_id) + if not client.workspace_folders then + return + end local watch_regs = {} for _, w in ipairs(reg.registerOptions.watchers) do local glob_patterns = {} |