refactor(lsp): inline on_client_exit

This commit is contained in:
Yi Ming
2025-07-20 22:09:27 +08:00
parent 5400df0f7f
commit 6831c7de65
2 changed files with 22 additions and 34 deletions

View File

@@ -1252,6 +1252,28 @@ function Client:_on_exit(code, signal)
end
end)
-- Schedule the deletion of the client object so that it exists in the execution of LspDetach
-- autocommands
vim.schedule(function()
all_clients[self.id] = nil
-- Client can be absent if executable starts, but initialize fails
-- init/attach won't have happened
if self then
changetracking.reset(self)
end
if code ~= 0 or (signal ~= 0 and signal ~= 15) then
local msg = string.format(
'Client %s quit with exit code %s and signal %s. Check log for errors: %s',
self and self.name or 'unknown',
code,
signal,
lsp.get_log_path()
)
vim.notify(msg, vim.log.levels.WARN)
end
end)
self:_run_callbacks(
self._on_exit_cbs,
lsp.client_errors.ON_EXIT_CALLBACK_ERROR,