aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp.lua
diff options
context:
space:
mode:
authorMathias Fußenegger <mfussenegger@users.noreply.github.com>2020-10-22 20:59:17 +0200
committerGitHub <noreply@github.com>2020-10-22 14:59:17 -0400
commitdf726408d7043c618877118909f53a78b85eb2fd (patch)
treee6bfd8dc4e5d602dca00582aaab9ba17de24dc43 /runtime/lua/vim/lsp.lua
parent78cd1b9f5a920ce6845cf275fa8c1fdfbf9400a3 (diff)
downloadrneovim-df726408d7043c618877118909f53a78b85eb2fd.tar.gz
rneovim-df726408d7043c618877118909f53a78b85eb2fd.tar.bz2
rneovim-df726408d7043c618877118909f53a78b85eb2fd.zip
lsp: Fix "client has shut down" errors during initializing (#13103)
Language servers can already send log messages to the client while the server is still being initialized. This currently leads to "client has shut down" messages which are confusing to the user as the server is properly starting. To fix this this changes the `get_client_by_id` method to also return a client if it is still initializing.
Diffstat (limited to 'runtime/lua/vim/lsp.lua')
-rw-r--r--runtime/lua/vim/lsp.lua13
1 files changed, 6 insertions, 7 deletions
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index 585528dd5a..95d9c585ee 100644
--- a/runtime/lua/vim/lsp.lua
+++ b/runtime/lua/vim/lsp.lua
@@ -397,9 +397,8 @@ end
--@param trace: "off" | "messages" | "verbose" | nil passed directly to the language
--- server in the initialize request. Invalid/empty values will default to "off"
---
---@returns Client id. |vim.lsp.get_client_by_id()| Note: client is only
---- available after it has been initialized, which may happen after a small
---- delay (or never if there is an error). Use `on_init` to do any actions once
+--@returns Client id. |vim.lsp.get_client_by_id()| Note: client may not be
+--- fully initialized. Use `on_init` to do any actions once
--- the client has been initialized.
function lsp.start_client(config)
local cleaned_config = validate_client_config(config)
@@ -910,14 +909,14 @@ function lsp.buf_is_attached(bufnr, client_id)
return (all_buffer_active_clients[bufnr] or {})[client_id] == true
end
---- Gets an active client by id, or nil if the id is invalid or the
---- client is not yet initialized.
----
+--- Gets a client by id, or nil if the id is invalid.
+--- The returned client may not yet be fully initialized.
+--
--@param client_id client id number
---
--@returns |vim.lsp.client| object, or nil
function lsp.get_client_by_id(client_id)
- return active_clients[client_id]
+ return active_clients[client_id] or uninitialized_clients[client_id]
end
--- Stops a client(s).