fix: wrong highlights on inactive mode with last commit
This commit is contained in:
parent
7147989f5f
commit
260133ce63
|
@ -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 = '%#' .. modules.highlight.append_mode 'lualine_c' .. '#%=' .. section_data
|
section_data = modules.highlight.format_highlight '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
|
||||||
|
|
|
@ -57,8 +57,7 @@ function FileType:apply_icon()
|
||||||
|
|
||||||
if icon and self.options.colored then
|
if icon and self.options.colored then
|
||||||
local highlight_color = modules.utils.extract_highlight_colors(icon_highlight_group, 'fg')
|
local highlight_color = modules.utils.extract_highlight_colors(icon_highlight_group, 'fg')
|
||||||
local is_focused = modules.utils.is_focused()
|
local default_highlight = modules.highlight.format_highlight(self.options.self.section)
|
||||||
local default_highlight = modules.highlight.format_highlight(is_focused, self.options.self.section)
|
|
||||||
local icon_highlight = self.options.self.section .. '_' .. icon_highlight_group
|
local icon_highlight = self.options.self.section .. '_' .. icon_highlight_group
|
||||||
if not modules.highlight.highlight_exists(icon_highlight .. '_normal') then
|
if not modules.highlight.highlight_exists(icon_highlight .. '_normal') then
|
||||||
icon_highlight = modules.highlight.create_component_highlight_group(
|
icon_highlight = modules.highlight.create_component_highlight_group(
|
||||||
|
|
|
@ -90,7 +90,13 @@ 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
|
||||||
function M.append_mode(highlight_group)
|
function M.append_mode(highlight_group, is_focused)
|
||||||
|
if is_focused == nil then
|
||||||
|
is_focused = modules.utils.is_focused()
|
||||||
|
end
|
||||||
|
if is_focused == false then
|
||||||
|
return highlight_group .. '_inactive'
|
||||||
|
end
|
||||||
local mode = require('lualine.utils.mode').get_mode()
|
local mode = require('lualine.utils.mode').get_mode()
|
||||||
if
|
if
|
||||||
mode == 'VISUAL'
|
mode == 'VISUAL'
|
||||||
|
@ -217,11 +223,7 @@ function M.component_format_highlight(highlight_name)
|
||||||
if highlight_name:find 'no_mode' == #highlight_name - #'no_mode' + 1 then
|
if highlight_name:find 'no_mode' == #highlight_name - #'no_mode' + 1 then
|
||||||
return '%#' .. highlight_group .. '#'
|
return '%#' .. highlight_group .. '#'
|
||||||
end
|
end
|
||||||
if modules.utils.is_focused() then
|
highlight_group = M.append_mode(highlight_group)
|
||||||
highlight_group = M.append_mode(highlight_group)
|
|
||||||
else
|
|
||||||
highlight_group = highlight_group .. '_inactive'
|
|
||||||
end
|
|
||||||
if M.highlight_exists(highlight_group) then
|
if M.highlight_exists(highlight_group) then
|
||||||
return '%#' .. highlight_group .. '#'
|
return '%#' .. highlight_group .. '#'
|
||||||
else
|
else
|
||||||
|
@ -229,16 +231,12 @@ function M.component_format_highlight(highlight_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.format_highlight(is_focused, highlight_group)
|
function M.format_highlight(highlight_group, is_focused)
|
||||||
if highlight_group > 'lualine_c' and not M.highlight_exists(highlight_group .. '_normal') then
|
if highlight_group > 'lualine_c' and not M.highlight_exists(highlight_group .. '_normal') then
|
||||||
highlight_group = 'lualine_' .. section_highlight_map[highlight_group:match 'lualine_(.)']
|
highlight_group = 'lualine_' .. section_highlight_map[highlight_group:match 'lualine_(.)']
|
||||||
end
|
end
|
||||||
local highlight_name
|
local highlight_name
|
||||||
if not is_focused then
|
highlight_name = M.append_mode(highlight_group, is_focused)
|
||||||
highlight_name = highlight_group .. [[_inactive]]
|
|
||||||
else
|
|
||||||
highlight_name = M.append_mode(highlight_group)
|
|
||||||
end
|
|
||||||
if M.highlight_exists(highlight_name) then
|
if M.highlight_exists(highlight_name) then
|
||||||
return '%#' .. highlight_name .. '#'
|
return '%#' .. highlight_name .. '#'
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,7 @@ local utils = require 'lualine.utils.utils'
|
||||||
local highlight = require 'lualine.highlight'
|
local highlight = require 'lualine.highlight'
|
||||||
-- Returns formated string for a section
|
-- Returns formated string for a section
|
||||||
function M.draw_section(section, section_name, is_focused)
|
function M.draw_section(section, section_name, is_focused)
|
||||||
local highlight_name = highlight.format_highlight(is_focused, 'lualine_' .. section_name)
|
local highlight_name = highlight.format_highlight('lualine_' .. section_name, is_focused)
|
||||||
|
|
||||||
local status = {}
|
local status = {}
|
||||||
for _, component in pairs(section) do
|
for _, component in pairs(section) do
|
||||||
|
|
Loading…
Reference in New Issue