From 98b43ba3a1e0ed83475b077e6ad87726e5803427 Mon Sep 17 00:00:00 2001 From: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com> Date: Fri, 8 Oct 2021 04:18:14 +0600 Subject: [PATCH] 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 %= --- README.md | 4 ++++ doc/lualine.txt | 4 ++++ lua/lualine.lua | 10 +++++++--- lua/lualine/config.lua | 1 + 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 40e5784..cb29986 100644 --- a/README.md +++ b/README.md @@ -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. } ``` diff --git a/doc/lualine.txt b/doc/lualine.txt index d24b487..dc99b7f 100644 --- a/doc/lualine.txt +++ b/doc/lualine.txt @@ -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. } < diff --git a/lua/lualine.lua b/lua/lualine.lua index 732f7e1..048ee84 100644 --- a/lua/lualine.lua +++ b/lua/lualine.lua @@ -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 diff --git a/lua/lualine/config.lua b/lua/lualine/config.lua index fd791db..a09cfba 100644 --- a/lua/lualine/config.lua +++ b/lua/lualine/config.lua @@ -7,6 +7,7 @@ local config = { component_separators = { left = '', right = '' }, section_separators = { left = '', right = '' }, disabled_filetypes = {}, + always_divide_middle = true, }, sections = { lualine_a = { 'mode' },