diff --git a/README.md b/README.md index d2ebb98..ff575da 100644 --- a/README.md +++ b/README.md @@ -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 } } } diff --git a/doc/lualine.txt b/doc/lualine.txt index 5d29a15..bc2aae6 100644 --- a/doc/lualine.txt +++ b/doc/lualine.txt @@ -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 } } } diff --git a/lua/lualine/components/diagnostics/config.lua b/lua/lualine/components/diagnostics/config.lua index dfaab80..5eaf1fe 100644 --- a/lua/lualine/components/diagnostics/config.lua +++ b/lua/lualine/components/diagnostics/config.lua @@ -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 = { diff --git a/lua/lualine/components/diagnostics/init.lua b/lua/lualine/components/diagnostics/init.lua index 7ef416f..f0700db 100644 --- a/lua/lualine/components/diagnostics/init.lua +++ b/lua/lualine/components/diagnostics/init.lua @@ -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