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 not applied_midsection_devider and section_name > 'c' then
applied_midsection_devider = true
section_data = '%=' .. section_data
section_data = '%#' .. modules.highlight.append_mode 'lualine_c' .. '#%=' .. section_data
end
if not applied_trunc and section_name > 'b' then
applied_trunc = true

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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