diff options
author | TJ DeVries <devries.timothyj@gmail.com> | 2020-06-04 19:37:38 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-04 19:37:38 -0400 |
commit | dd4018947c9f9b39b4e473c21ebf0e27f1e7ddc5 (patch) | |
tree | b0526f90f094e420a7a1f81189c53c483d4e9bba /runtime/lua/vim/lsp/callbacks.lua | |
parent | b7f3f11049c6847a2b0c4bbd89e8339036e00da6 (diff) | |
download | rneovim-dd4018947c9f9b39b4e473c21ebf0e27f1e7ddc5.tar.gz rneovim-dd4018947c9f9b39b4e473c21ebf0e27f1e7ddc5.tar.bz2 rneovim-dd4018947c9f9b39b4e473c21ebf0e27f1e7ddc5.zip |
lsp: do not process diagnostics for unloaded buffers (#12440)
Diffstat (limited to 'runtime/lua/vim/lsp/callbacks.lua')
-rw-r--r-- | runtime/lua/vim/lsp/callbacks.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/runtime/lua/vim/lsp/callbacks.lua b/runtime/lua/vim/lsp/callbacks.lua index 7c51fc2cc2..4b14f0132d 100644 --- a/runtime/lua/vim/lsp/callbacks.lua +++ b/runtime/lua/vim/lsp/callbacks.lua @@ -72,6 +72,17 @@ M['textDocument/publishDiagnostics'] = function(_, _, result) err_message("LSP.publishDiagnostics: Couldn't find buffer for ", uri) return end + + -- Unloaded buffers should not handle diagnostics. + -- When the buffer is loaded, we'll call on_attach, which sends textDocument/didOpen. + -- This should trigger another publish of the diagnostics. + -- + -- In particular, this stops a ton of spam when first starting a server for current + -- unloaded buffers. + if not api.nvim_buf_is_loaded(bufnr) then + return + end + util.buf_clear_diagnostics(bufnr) -- https://microsoft.github.io/language-server-protocol/specifications/specification-current/#diagnostic |