Set vim.o.background to the correct value when not using 'auto'

This commit is contained in:
Jan Polak 2023-12-07 05:28:13 +01:00
parent d7ab1515c4
commit 28cae122a9

View File

@ -51,6 +51,7 @@ local base_colors = {
local variants = { local variants = {
dark = { dark = {
_name = 'dark', _name = 'dark',
background = 'dark',
['bg'] = base_colors['flexoki-black'], ['bg'] = base_colors['flexoki-black'],
['bg-2'] = base_colors['flexoki-950'], ['bg-2'] = base_colors['flexoki-950'],
['ui'] = base_colors['flexoki-900'], ['ui'] = base_colors['flexoki-900'],
@ -78,6 +79,7 @@ local variants = {
}, },
light = { light = {
_name = 'light', _name = 'light',
background = 'light',
['bg'] = base_colors['flexoki-paper'], ['bg'] = base_colors['flexoki-paper'],
['bg-2'] = base_colors['flexoki-50'], ['bg-2'] = base_colors['flexoki-50'],
['ui'] = base_colors['flexoki-100'], ['ui'] = base_colors['flexoki-100'],
@ -106,15 +108,20 @@ local variants = {
} }
M.palette = function () M.palette = function ()
local variant = {}
if config.options.variant == 'auto' then if config.options.variant == 'auto' then
if vim.o.background == 'dark' then if vim.o.background == 'dark' then
return variants[config.options.dark_variant] variant = variants[config.options.dark_variant]
else else
return variants[config.options.light_variant] variant = variants[config.options.light_variant]
end end
else else
return variants[config.options.variant] variant = variants[config.options.variant]
vim.o.background = variant.background
end end
return variant
end end
return M return M