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.
This commit is contained in:
Ghjuvan Lacambre 2020-04-18 18:21:08 +02:00 committed by GitHub
parent 9ac5bc4b0b
commit 7d4451c657
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)