From a7592dcc1d7a2de95437fbdda14edc7052044abc Mon Sep 17 00:00:00 2001 From: Nikita Rudenko Date: Fri, 29 Jul 2022 14:19:41 +0300 Subject: [PATCH] Fix user highlights not updated on theme toggling Lua copies tables by reference, which leads to permanent replacements of named colors to their absolute values in user highlight table. Thus, when theme is toggled or changed, user highlights are not updated, cause they are stuck with absolute values. This commit does two thigs: * Copy user highlight tables by value * Add missing hl_add update in chadlights.lua --- lua/base46/chadlights.lua | 4 +++- lua/base46/init.lua | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lua/base46/chadlights.lua b/lua/base46/chadlights.lua index a77d0fb..78bb8d2 100644 --- a/lua/base46/chadlights.lua +++ b/lua/base46/chadlights.lua @@ -19,7 +19,9 @@ if polish_hl then end -- override user highlights if there are any -local user_highlights = ui.hl_override +local user_hl_override = vim.deepcopy(ui.hl_override) +local user_hl_add = vim.deepcopy(ui.hl_add) +local user_highlights = merge_tb(user_hl_override, user_hl_add) local colors = require("base46").get_theme_tb "base_30" -- fg = "white" set by user becomes fg = colors["white"] diff --git a/lua/base46/init.lua b/lua/base46/init.lua index df8be69..1af73b0 100644 --- a/lua/base46/init.lua +++ b/lua/base46/init.lua @@ -56,7 +56,8 @@ M.load_all_highlights = function() end end -M.turn_str_to_color = function(tb) +M.turn_str_to_color = function(tb_in) + local tb = vim.deepcopy(tb_in) local colors = M.get_theme_tb "base_30" for _, groups in pairs(tb) do