From 6da4406a5a5996038bcb09e46a2824c57b0b1856 Mon Sep 17 00:00:00 2001 From: Shadman Date: Tue, 5 Jan 2021 21:08:56 +0600 Subject: [PATCH] Themes now fallback to normal mode theme (#28) * Themes now fallback to normal mode theme * Refactored apply_default function * refactoring apply defaults --- lua/lualine/highlight.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lua/lualine/highlight.lua b/lua/lualine/highlight.lua index 2f79601..8c31760 100644 --- a/lua/lualine/highlight.lua +++ b/lua/lualine/highlight.lua @@ -10,7 +10,22 @@ local function highlight (name, foreground, background, special) return table.concat(command, ' ') end +local function apply_defaults_to_theme(theme) + local modes = {'insert', 'visual', 'replace', 'command', 'terminal', 'inactive'} + for _, mode in ipairs(modes) do + if not theme[mode] then + theme[mode] = theme['normal'] + else + for section_name, section in pairs(theme['normal']) do + theme[mode][section_name] = (theme[mode][section_name] or section) + end + end + end + return theme +end + function M.create_highlight_groups(theme) + apply_defaults_to_theme(theme) for mode, sections in pairs(theme) do for section, colorscheme in pairs(sections) do local special = nil