fix: left sections taking over entire stl when xyz is absent

- now %= applied even when x,y,z is absent
- newly added always_divide_middle option cal be set to false to avood %=
This commit is contained in:
shadmansaleh 2021-10-08 04:18:14 +06:00
parent 6faaa05ae5
commit 98b43ba3a1
4 changed files with 16 additions and 3 deletions

View File

@ -131,6 +131,7 @@ require'lualine'.setup {
component_separators = { left = '', right = ''},
section_separators = { left = '', right = ''},
disabled_filetypes = {}
always_divide_middle = true,
},
sections = {
lualine_a = {'mode'},
@ -349,6 +350,9 @@ options = {
component_separators = {left = '', right = ''},
section_separators = {left = '', right = ''},
disabled_filetypes = {}, -- filetypes to diable lualine on
always_divide_middle = true, -- When true left_sections (a,b,c) can't
-- take over entiee statusline even
-- when none of section x, y, z is present.
}
```

View File

@ -106,6 +106,7 @@ Default config
component_separators = { left = '', right = ''},
section_separators = { left = '', right = ''},
disabled_filetypes = {}
always_divide_middle = true,
},
sections = {
lualine_a = {'mode'},
@ -332,6 +333,9 @@ in component.
component_separators = {left = '', right = ''},
section_separators = {left = '', right = ''},
disabled_filetypes = {}, -- filetypes to diable lualine on
always_divide_middle = true, -- When true left_sections (a,b,c) can't
-- take over entiee statusline even
-- when none of section x, y, z is present.
}
<

View File

@ -126,7 +126,7 @@ local function statusline(sections, is_focused)
-- The sequence sections should maintain [SECTION_SEQUENCE]
local section_sequence = { 'a', 'b', 'c', 'x', 'y', 'z' }
local status = {}
local applied_midsection_devider = false
local applied_midsection_divider = false
local applied_trunc = false
for _, section_name in ipairs(section_sequence) do
if sections['lualine_' .. section_name] then
@ -137,8 +137,8 @@ local function statusline(sections, is_focused)
is_focused
)
if #section_data > 0 then
if not applied_midsection_devider and section_name > 'c' then
applied_midsection_devider = true
if not applied_midsection_divider and section_name > 'c' then
applied_midsection_divider = true
section_data = modules.highlight.format_highlight 'lualine_c' .. '%=' .. section_data
end
if not applied_trunc and section_name > 'b' then
@ -149,6 +149,10 @@ local function statusline(sections, is_focused)
end
end
end
if applied_midsection_divider == false and config.options.always_divide_middle ~= false then
-- When non of section x,y,z is present
table.insert(status, modules.highlight.format_highlight 'lualine_c' .. '%=')
end
return apply_transitional_separators(table.concat(status))
end

View File

@ -7,6 +7,7 @@ local config = {
component_separators = { left = '', right = '' },
section_separators = { left = '', right = '' },
disabled_filetypes = {},
always_divide_middle = true,
},
sections = {
lualine_a = { 'mode' },