aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp.lua
diff options
context:
space:
mode:
authorGregory Anders <8965202+gpanders@users.noreply.github.com>2021-12-17 13:06:44 -0700
committerGitHub <noreply@github.com>2021-12-17 12:06:44 -0800
commit6a92a53c02c429630c4b961e51dc97f3354ea196 (patch)
tree78b87245cf80b9a8a1a476bc8866be18fd226aed /runtime/lua/vim/lsp.lua
parent51306f98b8e35d056c3d12c7a9973a0fa92f8172 (diff)
downloadrneovim-6a92a53c02c429630c4b961e51dc97f3354ea196.tar.gz
rneovim-6a92a53c02c429630c4b961e51dc97f3354ea196.tar.bz2
rneovim-6a92a53c02c429630c4b961e51dc97f3354ea196.zip
fix(lsp): call config on_exit handler before context is cleared (#16638)
The on_exit handler provided to the client configuration is called after the client's context is cleared (e.g. which buffers the client was attached to). Calling the handler sooner allows these handlers to access the client object and do their own cleanup with the full context.
Diffstat (limited to 'runtime/lua/vim/lsp.lua')
-rw-r--r--runtime/lua/vim/lsp.lua8
1 files changed, 4 insertions, 4 deletions
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index 72a84dcc53..2e530ec17a 100644
--- a/runtime/lua/vim/lsp.lua
+++ b/runtime/lua/vim/lsp.lua
@@ -777,6 +777,10 @@ function lsp.start_client(config)
---@param code (number) exit code of the process
---@param signal (number) the signal used to terminate (if any)
function dispatch.on_exit(code, signal)
+ if config.on_exit then
+ pcall(config.on_exit, code, signal, client_id)
+ end
+
active_clients[client_id] = nil
uninitialized_clients[client_id] = nil
@@ -792,10 +796,6 @@ function lsp.start_client(config)
vim.notify(msg, vim.log.levels.WARN)
end)
end
-
- if config.on_exit then
- pcall(config.on_exit, code, signal, client_id)
- end
end
-- Start the RPC client.