mirror of
https://github.com/neovim/neovim.git
synced 2025-12-15 10:55:40 +00:00
feat(diagnostic): highlights in diagnostic.status() #36685
Applies the appropriate `DiagnosticSign*` highlight to each group, resetting the highlights at the end of the expression.
This commit is contained in:
@@ -2876,6 +2876,13 @@ function M.fromqflist(list)
|
||||
return diagnostics
|
||||
end
|
||||
|
||||
local hl_map = {
|
||||
[M.severity.ERROR] = 'DiagnosticSignError',
|
||||
[M.severity.WARN] = 'DiagnosticSignWarn',
|
||||
[M.severity.INFO] = 'DiagnosticSignInfo',
|
||||
[M.severity.HINT] = 'DiagnosticSignHint',
|
||||
}
|
||||
|
||||
--- Returns formatted string with diagnostics for the current buffer.
|
||||
--- The severities with 0 diagnostics are left out.
|
||||
--- Example `E:2 W:3 I:4 H:5`
|
||||
@@ -2899,10 +2906,14 @@ function M.status(bufnr)
|
||||
local result_str = vim
|
||||
.iter(pairs(counts))
|
||||
:map(function(severity, count)
|
||||
return ('%s:%s'):format(signs[severity], count)
|
||||
return ('%%#%s#%s:%s'):format(hl_map[severity], signs[severity], count)
|
||||
end)
|
||||
:join(' ')
|
||||
|
||||
if result_str:len() > 0 then
|
||||
result_str = result_str .. '%##'
|
||||
end
|
||||
|
||||
return result_str
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user