diff options
author | crwebb85 <51029315+crwebb85@users.noreply.github.com> | 2024-05-30 02:59:23 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-30 08:59:23 +0200 |
commit | 025c87441502cf570bad7b71f40bc6fe88989297 (patch) | |
tree | e6d204e8866343a35a78687d55f39c834851f118 /runtime/lua/vim/lsp.lua | |
parent | 40679c764a675d8039d0ae5c72cbde5f0dbe6db5 (diff) | |
download | rneovim-025c87441502cf570bad7b71f40bc6fe88989297.tar.gz rneovim-025c87441502cf570bad7b71f40bc6fe88989297.tar.bz2 rneovim-025c87441502cf570bad7b71f40bc6fe88989297.zip |
fix(lsp): clear lsp client diagnostics (#29050)
Problem: When an lsp client is stopped, the client will
only clear the diagnostics for the attached buffers but
not the unattached buffers.
Solution: Reset the diagnostics for the whole namespace rather than
for only the attached buffers.
Diffstat (limited to 'runtime/lua/vim/lsp.lua')
-rw-r--r-- | runtime/lua/vim/lsp.lua | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index 94c31359da..96dbf97146 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -391,8 +391,8 @@ end local function on_client_exit(code, signal, client_id) local client = all_clients[client_id] - for bufnr in pairs(client.attached_buffers) do - vim.schedule(function() + vim.schedule(function() + for bufnr in pairs(client.attached_buffers) do if client and client.attached_buffers[bufnr] then api.nvim_exec_autocmds('LspDetach', { buffer = bufnr, @@ -401,15 +401,16 @@ local function on_client_exit(code, signal, client_id) }) end - local namespace = vim.lsp.diagnostic.get_namespace(client_id) - vim.diagnostic.reset(namespace, bufnr) client.attached_buffers[bufnr] = nil if #lsp.get_clients({ bufnr = bufnr, _uninitialized = true }) == 0 then reset_defaults(bufnr) end - end) - end + end + + local namespace = vim.lsp.diagnostic.get_namespace(client_id) + vim.diagnostic.reset(namespace) + end) local name = client.name or 'unknown' |