diff options
author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-11-22 09:52:24 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-22 09:52:24 -0500 |
commit | 33ce02ee4d3b8bb8f5432049397cb7976bc3a55e (patch) | |
tree | 319d680260060d8a9f9cf2f2e8fad0d43bff439a /runtime/lua/vim/lsp.lua | |
parent | cfa5d0680107cad253085d8f62f951c25970a508 (diff) | |
download | rneovim-33ce02ee4d3b8bb8f5432049397cb7976bc3a55e.tar.gz rneovim-33ce02ee4d3b8bb8f5432049397cb7976bc3a55e.tar.bz2 rneovim-33ce02ee4d3b8bb8f5432049397cb7976bc3a55e.zip |
fix(lsp): avoid indexing vim.NIL for null workspaceFolders (#16404)
* internally represent no workspaceFolders as nil instead of vim.NIL
* rename workspaceFolders -> workspace_folders for consistency
Diffstat (limited to 'runtime/lua/vim/lsp.lua')
-rw-r--r-- | runtime/lua/vim/lsp.lua | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index 7433e7c04d..a380164a51 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -831,9 +831,9 @@ function lsp.start_client(config) root_uri = workspace_folders[1].uri root_path = vim.uri_to_fname(root_uri) else - workspace_folders = vim.NIL - root_uri = vim.NIL - root_path = vim.NIL + workspace_folders = nil + root_uri = nil + root_path = nil end local initialize_params = { @@ -851,15 +851,15 @@ function lsp.start_client(config) -- The rootPath of the workspace. Is null if no folder is open. -- -- @deprecated in favour of rootUri. - rootPath = root_path; + rootPath = root_path or vim.NIL; -- The rootUri of the workspace. Is null if no folder is open. If both -- `rootPath` and `rootUri` are set `rootUri` wins. - rootUri = root_uri; + rootUri = root_uri or vim.NIL; -- The workspace folders configured in the client when the server starts. -- This property is only available if the client supports workspace folders. -- It can be `null` if the client supports workspace folders but none are -- configured. - workspaceFolders = workspace_folders; + workspaceFolders = workspace_folders or vim.NIL; -- User provided initialization options. initializationOptions = config.init_options; -- The capabilities provided by the client (editor or tool) @@ -879,7 +879,9 @@ function lsp.start_client(config) rpc.notify('initialized', vim.empty_dict()) client.initialized = true uninitialized_clients[client_id] = nil - client.workspaceFolders = initialize_params.workspaceFolders + client.workspace_folders = workspace_folders + -- TODO(mjlbach): Backwards compatbility, to be removed in 0.7 + client.workspaceFolders = client.workspace_folders client.server_capabilities = assert(result.capabilities, "initialize result doesn't contain capabilities") -- These are the cleaned up capabilities we use for dynamically deciding -- when to send certain events to clients. |