From 634959f0e9e0f30028a9066f157cd349eb57463b Mon Sep 17 00:00:00 2001 From: Shadman Date: Thu, 13 May 2021 22:39:30 +0600 Subject: [PATCH] feat: allow x,y,z sections to be themed independently (#238) If theme for x,y,z is unspecified the defaukt to c,b,a respectively --- CONTRIBUTING.md | 5 ++++- lua/lualine/highlight.lua | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 43762d5..2033df6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,8 +24,11 @@ lualine theme at lua/lualine/themes/{your_colorscheme}.lua in you repo. To create a custom theme you need to define a colorscheme for each of vim's modes. Each mode has a `fg` and `bg` field for every lualine section. You can add special effects with `gui`. -Adding theme is really easy in lua. Here is and example of a gruvbox theme. +Though the example shows a,b,c being set you can specify theme for x, y, z too. +But if unspecified then they default to c, b, a sections theme respectively . + Also all modes theme defaults to normal modes theme. +Adding theme is really easy in lua. Here is and example of a gruvbox theme. ```lua local gruvbox = { } diff --git a/lua/lualine/highlight.lua b/lua/lualine/highlight.lua index 0139484..3d63a9f 100644 --- a/lua/lualine/highlight.lua +++ b/lua/lualine/highlight.lua @@ -95,7 +95,8 @@ function M.create_component_highlight_group(color, highlight_tag, options) local normal_hl -- convert lualine_a -> a before setting section local section = options.self.section:match('lualine_(.*)') - if section > 'c' then section = section_highlight_map[section] end + if section > 'c' and not active_theme.normal[section] then + section = section_highlight_map[section] end for _, mode in ipairs(modes) do local highlight_group_name = {options.self.section, highlight_tag, mode} local default_color_table = active_theme[mode] and @@ -139,7 +140,8 @@ function M.component_format_highlight(highlight_name) end function M.format_highlight(is_focused, highlight_group) - if highlight_group > 'lualine_c' then + if highlight_group > 'lualine_c' + and not utils.highlight_exists(highlight_group .. '_normal') then highlight_group = 'lualine_' .. section_highlight_map[highlight_group:match( 'lualine_(.)')]