Repository: nvim-lualine/lualine.nvim (lua)

Issue:
(ready to do PR) Feat: add option to draw component even if it's empty, just for the separator
It would be nice if there would be option for unconditionally drawing component even if it's empty just for the separator.

### Motivation

I want be able to include decorative blocks in the statusline like this:
![screenshot_2023_02_11_16_58_29](https://user-images.githubusercontent.com/47556468/218265726-68b384b6-1810-4d03-ad4c-2cbc21a7b5a5.png)
(the one after git branch segment)

I was able to do it however it's not what I exactly wanted because of extra space I had to add.
Ideally I'd like to be able to make it look like that:
![screenshot_2023_02_11_17_06_41](https://user-images.githubusercontent.com/47556468/218265854-48a78636-608d-4e6f-88a0-0f35f40fb768.png)
As you can see it is thinner now because there's no extra space.

<!-- Explain why you think it should be included in lualine.-->
I think it might be useful to other people and it's one line of code to add.

Pull request description:
Closes #963

Patch:
diff --git a/README.md b/README.md
index c96c3013e..21ac8825b 100644
--- a/README.md
+++ b/README.md
@@ -419,6 +419,9 @@ sections = {
 
       cond = nil,           -- Condition function, the component is loaded when the function returns `true`.
 
+      draw_empty = false,   -- Whether to draw component even if it's empty.
+                            -- Might be useful if you want just the separator.
+
       -- Defines a custom color for the component:
       --
       -- 'highlight_group_name' | { fg = '#rrggbb'|cterm_value(0-255)|'color_name(red)', bg= '#rrggbb', gui='style' } | function
diff --git a/lua/lualine/component.lua b/lua/lualine/component.lua
index a4d9d9b1a..8efa1a70f 100644
--- a/lua/lualine/component.lua
+++ b/lua/lualine/component.lua
@@ -274,7 +274,7 @@ function M:draw(default_highlight, is_focused)
   if self.options.fmt then
     status = self.options.fmt(status or '', self)
   end
-  if type(status) == 'string' and #status > 0 then
+  if type(status) == 'string' and (#status > 0 or self.options.draw_empty) then
     self.status = status
     self:apply_icon()
     self:apply_padding()


Test patch:
diff --git a/tests/spec/component_spec.lua b/tests/spec/component_spec.lua
index b5dad639f..d3f2af011 100644
--- a/tests/spec/component_spec.lua
+++ b/tests/spec/component_spec.lua
@@ -211,6 +211,19 @@ describe('Component:', function()
       assert.stub(hl.component_format_highlight).was_called_with(comp2.options.color_highlight)
       hl.component_format_highlight:revert()
     end)
+
+    it('draw_empty', function()
+      local opts = build_component_opts {
+        component_separators = { left = '', right = '' },
+        padding = 0,
+        separator = '>',
+        fmt = function()
+          return ''
+        end,
+        draw_empty = true,
+      }
+      assert_component(nil, opts, '>')
+    end)
   end)
 end)