mirror of
https://github.com/neovim/neovim.git
synced 2025-10-22 17:11:49 +00:00
LSP: differentiate diagnostic underline by severity
This commit is contained in:

committed by
Justin M. Keyes

parent
831fa45ad8
commit
e616ec4394
@@ -547,7 +547,10 @@ do
|
|||||||
local diagnostic_ns = api.nvim_create_namespace("vim_lsp_diagnostics")
|
local diagnostic_ns = api.nvim_create_namespace("vim_lsp_diagnostics")
|
||||||
|
|
||||||
local underline_highlight_name = "LspDiagnosticsUnderline"
|
local underline_highlight_name = "LspDiagnosticsUnderline"
|
||||||
api.nvim_command(string.format("highlight default %s gui=underline cterm=underline", underline_highlight_name))
|
vim.cmd(string.format("highlight default %s gui=underline cterm=underline", underline_highlight_name))
|
||||||
|
for kind, _ in pairs(protocol.DiagnosticSeverity) do
|
||||||
|
vim.cmd(string.format("highlight default link %s%s %s", underline_highlight_name, kind, underline_highlight_name))
|
||||||
|
end
|
||||||
|
|
||||||
local severity_highlights = {}
|
local severity_highlights = {}
|
||||||
|
|
||||||
@@ -657,11 +660,19 @@ do
|
|||||||
|
|
||||||
function M.buf_diagnostics_underline(bufnr, diagnostics)
|
function M.buf_diagnostics_underline(bufnr, diagnostics)
|
||||||
for _, diagnostic in ipairs(diagnostics) do
|
for _, diagnostic in ipairs(diagnostics) do
|
||||||
local start = diagnostic.range.start
|
local start = diagnostic.range["start"]
|
||||||
local finish = diagnostic.range["end"]
|
local finish = diagnostic.range["end"]
|
||||||
|
|
||||||
|
local hlmap = {
|
||||||
|
[protocol.DiagnosticSeverity.Error]='Error',
|
||||||
|
[protocol.DiagnosticSeverity.Warning]='Warning',
|
||||||
|
[protocol.DiagnosticSeverity.Information]='Information',
|
||||||
|
[protocol.DiagnosticSeverity.Hint]='Hint',
|
||||||
|
}
|
||||||
|
|
||||||
-- TODO care about encoding here since this is in byte index?
|
-- TODO care about encoding here since this is in byte index?
|
||||||
highlight_range(bufnr, diagnostic_ns, underline_highlight_name,
|
highlight_range(bufnr, diagnostic_ns,
|
||||||
|
underline_highlight_name..hlmap[diagnostic.severity],
|
||||||
{start.line, start.character},
|
{start.line, start.character},
|
||||||
{finish.line, finish.character}
|
{finish.line, finish.character}
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user