enhance: color middle of left and right statusline with lualine_c color even when section c and x are absent

This commit is contained in:
shadmansaleh 2021-09-19 11:50:15 +06:00
parent ebea516ac7
commit 7147989f5f
7 changed files with 4 additions and 39 deletions

View File

@ -139,7 +139,7 @@ local function statusline(sections, is_focused)
if #section_data > 0 then if #section_data > 0 then
if not applied_midsection_devider and section_name > 'c' then if not applied_midsection_devider and section_name > 'c' then
applied_midsection_devider = true applied_midsection_devider = true
section_data = '%=' .. section_data section_data = '%#' .. modules.highlight.append_mode 'lualine_c' .. '#%=' .. section_data
end end
if not applied_trunc and section_name > 'b' then if not applied_trunc and section_name > 'b' then
applied_trunc = true applied_trunc = true

View File

@ -6,16 +6,9 @@ local function fugitive_branch()
local icon = '' -- e0a0 local icon = '' -- e0a0
return icon .. ' ' .. vim.fn.FugitiveHead() return icon .. ' ' .. vim.fn.FugitiveHead()
end end
local empty = {
function()
return ' '
end,
padding = 0,
}
M.sections = { M.sections = {
lualine_a = { fugitive_branch }, lualine_a = { fugitive_branch },
lualine_c = { empty },
lualine_z = { 'location' }, lualine_z = { 'location' },
} }

View File

@ -3,18 +3,11 @@
local function fzf_statusline() local function fzf_statusline()
return 'FZF' return 'FZF'
end end
local empty = {
function()
return ' '
end,
padding = 0,
}
local M = {} local M = {}
M.sections = { M.sections = {
lualine_a = { fzf_statusline }, lualine_a = { fzf_statusline },
lualine_c = { empty },
} }
M.filetypes = { 'fzf' } M.filetypes = { 'fzf' }

View File

@ -3,18 +3,11 @@
local function get_short_cwd() local function get_short_cwd()
return vim.fn.fnamemodify(vim.fn.getcwd(), ':~') return vim.fn.fnamemodify(vim.fn.getcwd(), ':~')
end end
local empty = {
function()
return ' '
end,
padding = 0,
}
local M = {} local M = {}
M.sections = { M.sections = {
lualine_a = { get_short_cwd }, lualine_a = { get_short_cwd },
lualine_c = { empty },
} }
M.filetypes = { 'nerdtree' } M.filetypes = { 'nerdtree' }

View File

@ -15,12 +15,6 @@ local function title()
end end
return vim.fn.getqflist({ title = 0 }).title return vim.fn.getqflist({ title = 0 }).title
end end
local empty = {
function()
return ' '
end,
padding = 0,
}
local M = {} local M = {}
@ -32,7 +26,6 @@ end
M.sections = { M.sections = {
lualine_a = { label }, lualine_a = { label },
lualine_b = { title }, lualine_b = { title },
lualine_c = { empty },
lualine_z = { 'location' }, lualine_z = { 'location' },
} }

View File

@ -4,18 +4,11 @@
local function toggleterm_statusline() local function toggleterm_statusline()
return 'ToggleTerm #' .. vim.b.toggle_number return 'ToggleTerm #' .. vim.b.toggle_number
end end
local empty = {
function()
return ' '
end,
padding = 0,
}
local M = {} local M = {}
M.sections = { M.sections = {
lualine_a = { toggleterm_statusline }, lualine_a = { toggleterm_statusline },
lualine_c = { empty },
} }
M.filetypes = { 'toggleterm' } M.filetypes = { 'toggleterm' }

View File

@ -90,7 +90,7 @@ end
-- @description: adds '_mode' at end of highlight_group -- @description: adds '_mode' at end of highlight_group
-- @param highlight_group:(string) name of highlight group -- @param highlight_group:(string) name of highlight group
-- @return: (string) highlight group name with mode -- @return: (string) highlight group name with mode
local function append_mode(highlight_group) function M.append_mode(highlight_group)
local mode = require('lualine.utils.mode').get_mode() local mode = require('lualine.utils.mode').get_mode()
if if
mode == 'VISUAL' mode == 'VISUAL'
@ -218,7 +218,7 @@ function M.component_format_highlight(highlight_name)
return '%#' .. highlight_group .. '#' return '%#' .. highlight_group .. '#'
end end
if modules.utils.is_focused() then if modules.utils.is_focused() then
highlight_group = append_mode(highlight_group) highlight_group = M.append_mode(highlight_group)
else else
highlight_group = highlight_group .. '_inactive' highlight_group = highlight_group .. '_inactive'
end end
@ -237,7 +237,7 @@ function M.format_highlight(is_focused, highlight_group)
if not is_focused then if not is_focused then
highlight_name = highlight_group .. [[_inactive]] highlight_name = highlight_group .. [[_inactive]]
else else
highlight_name = append_mode(highlight_group) highlight_name = M.append_mode(highlight_group)
end end
if M.highlight_exists(highlight_name) then if M.highlight_exists(highlight_name) then
return '%#' .. highlight_name .. '#' return '%#' .. highlight_name .. '#'