feat: add option to always show diagnostics
* rename option and add to default config * combine separate if statements using else if
This commit is contained in:
parent
ad4f4ff751
commit
e909cc3caf
|
@ -460,6 +460,7 @@ sections = {
|
|||
}
|
||||
symbols = {error = 'E', warn = 'W', info = 'I', hint = 'H'}
|
||||
update_in_insert = false, -- Update diagnostics in insert mode
|
||||
always_visible = false, -- Show diagnostics even if count is 0, boolean or function returning boolean
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -440,6 +440,7 @@ will be.
|
|||
}
|
||||
symbols = {error = 'E', warn = 'W', info = 'I', hint = 'H'}
|
||||
update_in_insert = false, -- Update diagnostics in insert mode
|
||||
always_visible = false, -- Show diagnostics even if count is 0, boolean or function returning boolean
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ M.symbols = {
|
|||
M.options = {
|
||||
colored = true,
|
||||
update_in_insert = false,
|
||||
always_visible = false,
|
||||
sources = { 'nvim_lsp', 'coc' },
|
||||
sections = { 'error', 'warn', 'info', 'hint' },
|
||||
diagnostics_color = {
|
||||
|
|
|
@ -83,6 +83,14 @@ function M:update_status()
|
|||
info = info_count,
|
||||
hint = hint_count,
|
||||
}
|
||||
|
||||
local always_visible = false
|
||||
if type(self.options.always_visible) == 'boolean' then
|
||||
always_visible = self.options.always_visible
|
||||
elseif type(self.options.always_visible) == 'function' then
|
||||
always_visible = self.options.always_visible()
|
||||
end
|
||||
|
||||
-- format the counts with symbols and highlights
|
||||
if self.options.colored then
|
||||
local colors = {}
|
||||
|
@ -90,13 +98,13 @@ function M:update_status()
|
|||
colors[name] = modules.highlight.component_format_highlight(hl)
|
||||
end
|
||||
for _, section in ipairs(self.options.sections) do
|
||||
if data[section] ~= nil and data[section] > 0 then
|
||||
if data[section] ~= nil and (always_visible or data[section] > 0) then
|
||||
table.insert(result, colors[section] .. self.symbols[section] .. data[section])
|
||||
end
|
||||
end
|
||||
else
|
||||
for _, section in ipairs(self.options.sections) do
|
||||
if data[section] ~= nil and data[section] > 0 then
|
||||
if data[section] ~= nil and (always_visible or data[section] > 0) then
|
||||
table.insert(result, self.symbols[section] .. data[section])
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue