aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/callbacks.lua
diff options
context:
space:
mode:
authorGhjuvan Lacambre <code@lacamb.re>2020-04-18 18:21:08 +0200
committerGitHub <noreply@github.com>2020-04-18 18:21:08 +0200
commit7d4451c65785ef7e781bf5029da059fb77b728b7 (patch)
tree7926c36529104c900aa7e6fb55b6f10d95960caa /runtime/lua/vim/lsp/callbacks.lua
parent9ac5bc4b0b2621b9173e69699fdc6af61a0c0bd9 (diff)
downloadrneovim-7d4451c65785ef7e781bf5029da059fb77b728b7.tar.gz
rneovim-7d4451c65785ef7e781bf5029da059fb77b728b7.tar.bz2
rneovim-7d4451c65785ef7e781bf5029da059fb77b728b7.zip
LSP: fix breakage when severity isn't specified (#12027)
Before this commit, the LSP client would throw errors when messages without severity would be sent by the server. We make severity default to `Error` as a kludge before proper heuristics to discover the severity of a message are found.
Diffstat (limited to 'runtime/lua/vim/lsp/callbacks.lua')
-rw-r--r--runtime/lua/vim/lsp/callbacks.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/runtime/lua/vim/lsp/callbacks.lua b/runtime/lua/vim/lsp/callbacks.lua
index 644c12f98c..c403a3fd51 100644
--- a/runtime/lua/vim/lsp/callbacks.lua
+++ b/runtime/lua/vim/lsp/callbacks.lua
@@ -29,6 +29,17 @@ M['textDocument/publishDiagnostics'] = function(_, _, result)
return
end
util.buf_clear_diagnostics(bufnr)
+
+ -- https://microsoft.github.io/language-server-protocol/specifications/specification-current/#diagnostic
+ -- The diagnostic's severity. Can be omitted. If omitted it is up to the
+ -- client to interpret diagnostics as error, warning, info or hint.
+ -- TODO: Replace this with server-specific heuristics to infer severity.
+ for _, diagnostic in ipairs(result.diagnostics) do
+ if diagnostic.severity == nil then
+ diagnostic.severity = protocol.DiagnosticSeverity.Error
+ end
+ end
+
util.buf_diagnostics_save_positions(bufnr, result.diagnostics)
util.buf_diagnostics_underline(bufnr, result.diagnostics)
util.buf_diagnostics_virtual_text(bufnr, result.diagnostics)