aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/buf.lua
diff options
context:
space:
mode:
authorMitchell Hanberg <mitch@mitchellhanberg.com>2023-07-24 12:09:53 -0400
committerGitHub <noreply@github.com>2023-07-24 09:09:53 -0700
commita37d568082ad2a6fd479bc0584f1088b51019b7f (patch)
tree6cd9d2dcd6e3400ee75c20e1660bca937ff908ed /runtime/lua/vim/lsp/buf.lua
parentadd7e106d59b8e3822310846a850b3ed3fb5db0e (diff)
downloadrneovim-a37d568082ad2a6fd479bc0584f1088b51019b7f.tar.gz
rneovim-a37d568082ad2a6fd479bc0584f1088b51019b7f.tar.bz2
rneovim-a37d568082ad2a6fd479bc0584f1088b51019b7f.zip
fix(lsp): send empty "added" list when removing workspace folder #24440
When adding `workspace/didChangeWorkspaceFolders` support to my [language server](https://github.com/elixir-tools/next-ls), I noticed that when neovim removes a workspace, it sends an empty table (which is serialized to an empty JSON array) for the value in the `added` field. This does not follow the spec; the `added` table should just be empty. The following error led me to this discovery. Note the payload includes `"added" => [[]]`: ``` 22:46:48.476 [error] LSP Exited. Last message received: handle_notification %{"jsonrpc" => "2.0", "method" => "workspace/didChangeWorkspaceFolders", "params" => %{"event" => %{"added" => [[]], "removed" => [%{"name" => "/Users/mitchell/src/gen_lsp", "uri" => "file:///Users/mitchell/src/gen_lsp"}]}}} ** (MatchError) no match of right hand side value: {:error, %{"params" => %{"event" => %{"added" => [error: "expected a map"]}}}} (gen_lsp 0.4.0) lib/gen_lsp.ex:265: anonymous fn/4 in GenLSP.loop/3 (gen_lsp 0.4.0) lib/gen_lsp.ex:292: GenLSP.attempt/3 (stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3 ```
Diffstat (limited to 'runtime/lua/vim/lsp/buf.lua')
-rw-r--r--runtime/lua/vim/lsp/buf.lua2
1 files changed, 1 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua
index 46f582dc7e..02d8d0fa7b 100644
--- a/runtime/lua/vim/lsp/buf.lua
+++ b/runtime/lua/vim/lsp/buf.lua
@@ -514,7 +514,7 @@ function M.remove_workspace_folder(workspace_folder)
return
end
local params = util.make_workspace_params(
- { {} },
+ {},
{ { uri = vim.uri_from_fname(workspace_folder), name = workspace_folder } }
)
for _, client in pairs(vim.lsp.get_clients({ bufnr = 0 })) do