From 38a091986592892d97147663e14d9b4ec56de74c Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Wed, 1 Dec 2021 09:48:53 -0800 Subject: [PATCH] Force theme switch --- neovim/lua/_colors.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/neovim/lua/_colors.lua b/neovim/lua/_colors.lua index f7ff871..5990170 100644 --- a/neovim/lua/_colors.lua +++ b/neovim/lua/_colors.lua @@ -1,10 +1,14 @@ -- Update colors based on environment variables function _G.update_colors() - local function maybe_set(scope, name, val) + local function maybe_set(scope, name, val, force) + force = force or false if vim[scope][name] ~= val then vim[scope][name] = val return true end + if force then + vim[scope][name] = val + end return false end @@ -27,12 +31,12 @@ function _G.update_colors() env_color = utils.env_default("VIM_COLOR_DARK", env_color) env_color = utils.env_default("NVIM_COLOR_DARK", env_color) change = maybe_set("o", "background", "dark") - change = maybe_set("g", "colors_name", env_color) or change + change = maybe_set("g", "colors_name", env_color, true) or change elseif mode == "light" then env_color = utils.env_default("VIM_COLOR_LIGHT", env_color) env_color = utils.env_default("NVIM_COLOR_LIGHT", env_color) change = maybe_set("o", "background", "light") - change = maybe_set("g", "colors_name", env_color) or change + change = maybe_set("g", "colors_name", env_color, true) or change end -- Update status line theme