Themes now fallback to normal mode theme (#28)

* Themes now fallback to normal mode theme

* Refactored apply_default function

* refactoring apply defaults
This commit is contained in:
Shadman 2021-01-05 21:08:56 +06:00 committed by GitHub
parent 24db1a62e8
commit 6da4406a5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -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