fix: use appropriate default color for transitional separators.
This commit is contained in:
parent
f14175e142
commit
7345986fb4
|
@ -41,14 +41,14 @@ end
|
||||||
---@param last_hl string : last applied hl group name before str_checked
|
---@param last_hl string : last applied hl group name before str_checked
|
||||||
---@param reverse boolean : reverse the hl group ( true for right separators )
|
---@param reverse boolean : reverse the hl group ( true for right separators )
|
||||||
---@return string|nil concated separator highlight and transitional separator
|
---@return string|nil concated separator highlight and transitional separator
|
||||||
local function fill_section_separator(status, str_checked, last_hl, sep, reverse)
|
local function fill_section_separator(status, is_focused, str_checked, last_hl, sep, reverse)
|
||||||
-- Inserts transitional separator along with transitional highlight
|
-- Inserts transitional separator along with transitional highlight
|
||||||
local next_hl = find_next_hl(status, str_checked)
|
local next_hl = find_next_hl(status, str_checked)
|
||||||
if last_hl == nil then
|
if last_hl == nil then
|
||||||
last_hl = 'Normal'
|
last_hl = modules.highlight.get_stl_default_hl(is_focused)
|
||||||
end
|
end
|
||||||
if next_hl == nil then
|
if next_hl == nil then
|
||||||
next_hl = 'Normal'
|
next_hl = modules.highlight.get_stl_default_hl(is_focused)
|
||||||
end
|
end
|
||||||
if #next_hl == 0 or #last_hl == 0 then
|
if #next_hl == 0 or #last_hl == 0 then
|
||||||
return
|
return
|
||||||
|
@ -65,7 +65,7 @@ end
|
||||||
--- replaces %s/S{sep} with proper left/right separator highlight + sep
|
--- replaces %s/S{sep} with proper left/right separator highlight + sep
|
||||||
---@param status string : unprossed statusline string
|
---@param status string : unprossed statusline string
|
||||||
---@return string : processed statusline string
|
---@return string : processed statusline string
|
||||||
local function apply_transitional_separators(status)
|
local function apply_transitional_separators(status, is_focused)
|
||||||
local status_applied = {} -- Collects all the pieces for concatation
|
local status_applied = {} -- Collects all the pieces for concatation
|
||||||
local last_hl -- Stores lash highligjt group that we found
|
local last_hl -- Stores lash highligjt group that we found
|
||||||
local last_hl_reseted = false -- Whether last_hl is nil because we reseted
|
local last_hl_reseted = false -- Whether last_hl is nil because we reseted
|
||||||
|
@ -93,7 +93,7 @@ local function apply_transitional_separators(status)
|
||||||
local sep = status:match('^%%s{(.-)}', str_checked)
|
local sep = status:match('^%%s{(.-)}', str_checked)
|
||||||
str_checked = str_checked + #sep + 4 -- 4 = len(%{})
|
str_checked = str_checked + #sep + 4 -- 4 = len(%{})
|
||||||
if not (last_hl == nil and last_hl_reseted) then
|
if not (last_hl == nil and last_hl_reseted) then
|
||||||
local trans_sep = fill_section_separator(status, str_checked, last_hl, sep, false)
|
local trans_sep = fill_section_separator(status, is_focused, str_checked, last_hl, sep, false)
|
||||||
if trans_sep then
|
if trans_sep then
|
||||||
table.insert(status_applied, trans_sep)
|
table.insert(status_applied, trans_sep)
|
||||||
end
|
end
|
||||||
|
@ -111,7 +111,7 @@ local function apply_transitional_separators(status)
|
||||||
-- and in this exact order skip the left sep as we can't draw both.
|
-- and in this exact order skip the left sep as we can't draw both.
|
||||||
str_checked = status:find('}', str_checked) + 1
|
str_checked = status:find('}', str_checked) + 1
|
||||||
end
|
end
|
||||||
local trans_sep = fill_section_separator(status, str_checked, last_hl, sep, true)
|
local trans_sep = fill_section_separator(status, is_focused, str_checked, last_hl, sep, true)
|
||||||
if trans_sep then
|
if trans_sep then
|
||||||
table.insert(status_applied, trans_sep)
|
table.insert(status_applied, trans_sep)
|
||||||
end
|
end
|
||||||
|
@ -171,7 +171,7 @@ local statusline = modules.utils.retry_call_wrap(function(sections, is_focused)
|
||||||
-- When non of section x,y,z is present
|
-- When non of section x,y,z is present
|
||||||
table.insert(status, modules.highlight.format_highlight('c', is_focused) .. '%=')
|
table.insert(status, modules.highlight.format_highlight('c', is_focused) .. '%=')
|
||||||
end
|
end
|
||||||
return apply_transitional_separators(table.concat(status))
|
return apply_transitional_separators(table.concat(status), is_focused)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--- check if any extension matches the filetype and return proper sections
|
--- check if any extension matches the filetype and return proper sections
|
||||||
|
@ -198,7 +198,7 @@ end
|
||||||
|
|
||||||
---@return string statusline string for tabline
|
---@return string statusline string for tabline
|
||||||
local function tabline()
|
local function tabline()
|
||||||
return statusline(config.tabline, true)
|
return statusline(config.tabline, 3)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function notify_theme_error(theme_name)
|
local function notify_theme_error(theme_name)
|
||||||
|
|
|
@ -463,4 +463,14 @@ function M.get_transitional_highlights(left_hl, right_hl)
|
||||||
return '%#' .. highlight_name .. '#'
|
return '%#' .. highlight_name .. '#'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.get_stl_default_hl(focused)
|
||||||
|
if focused == 3 then
|
||||||
|
return 'TabLineFill'
|
||||||
|
elseif not focused then
|
||||||
|
return 'StatusLineNC'
|
||||||
|
else
|
||||||
|
return 'StatusLine'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
Loading…
Reference in New Issue