From f1dbb2f4a823e732ed766437448a42b443bf2e2b Mon Sep 17 00:00:00 2001 From: "J. Bromley" Date: Thu, 29 Jul 2021 22:47:07 +0600 Subject: [PATCH] Fixed using 'auto' theme with default colorscheme. When setting theme to 'auto' and using the default colorscheme, lualine would report "theme not found, defaulting to gruvbox". Fixed by checking that we get an actual color back when calling utils.extract_highlight_colors before attempting to apply a brightness modifier. * Fix brightness_modifier application. The brightness_modifer() should only be applied when a normal color was found. * Apply brightness modifier when normal color not nil. Moved application of brightness_modifier outside the if statement that negates the brightness modifier. The modifier will now be applied when get_color_brightness returns < 0.5. --- lua/lualine/themes/auto.lua | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lua/lualine/themes/auto.lua b/lua/lualine/themes/auto.lua index 8b7b56b..6a80744 100644 --- a/lua/lualine/themes/auto.lua +++ b/lua/lualine/themes/auto.lua @@ -117,12 +117,14 @@ local colors = { -- Change brightness of colors -- darken incase of light theme lighten incase of dark theme -if get_color_brightness(utils.extract_highlight_colors('Normal', 'bg')) > 0.5 then - brightness_modifier_parameter = -brightness_modifier_parameter -end - -for name, color in pairs(colors) do - colors[name] = brightness_modifier(color, brightness_modifier_parameter) +local normal_color = utils.extract_highlight_colors('Normal', 'bg') +if normal_color ~= nil then + if get_color_brightness(normal_color) > 0.5 then + brightness_modifier_parameter = -brightness_modifier_parameter + end + for name, color in pairs(colors) do + colors[name] = brightness_modifier(color, brightness_modifier_parameter) + end end -- basic theme defination