diff options
author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-02-19 19:05:49 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-19 22:05:49 -0500 |
commit | b2fcfc65b7181cfb519ce1f827cb62f1120de5a0 (patch) | |
tree | 40676433b960adc771892cc3b48ee92a55dc6216 /runtime/lua/vim/lsp/diagnostic.lua | |
parent | 4d5dbea4f402c76de4419977f7f89d3dec572510 (diff) | |
download | rneovim-b2fcfc65b7181cfb519ce1f827cb62f1120de5a0.tar.gz rneovim-b2fcfc65b7181cfb519ce1f827cb62f1120de5a0.tar.bz2 rneovim-b2fcfc65b7181cfb519ce1f827cb62f1120de5a0.zip |
lsp: client stop cleanups (#13877)
* lsp: client stop cleanups
* Add diagnostic clearing to client.stop() method used by nvim-lspconfig
* Clear diagnostic cache to prevent stale diagnostics on client restart
* lsp: Add test for vim.lsp.diagnostic.reset
Diffstat (limited to 'runtime/lua/vim/lsp/diagnostic.lua')
-rw-r--r-- | runtime/lua/vim/lsp/diagnostic.lua | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua index a625098bab..df25943ecd 100644 --- a/runtime/lua/vim/lsp/diagnostic.lua +++ b/runtime/lua/vim/lsp/diagnostic.lua @@ -1158,6 +1158,24 @@ local loclist_type_map = { [DiagnosticSeverity.Hint] = 'I', } + +--- Clear diagnotics and diagnostic cache +--- +--- Handles saving diagnostics from multiple clients in the same buffer. +---@param client_id number +---@param buffer_client_map table map of buffers to active clients +function M.reset(client_id, buffer_client_map) + buffer_client_map = vim.deepcopy(buffer_client_map) + vim.schedule(function() + for bufnr, client_ids in pairs(buffer_client_map) do + if client_ids[client_id] then + clear_diagnostic_cache(bufnr, client_id) + M.clear(bufnr, client_id) + end + end + end) +end + --- Sets the location list ---@param opts table|nil Configuration table. Keys: --- - {open_loclist}: (boolean, default true) |