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
This commit is contained in:
Nikita Rudenko 2022-07-29 14:19:41 +03:00
parent f7340d7245
commit a7592dcc1d
2 changed files with 5 additions and 2 deletions

View file

@ -19,7 +19,9 @@ if polish_hl then
end end
-- override user highlights if there are any -- 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" local colors = require("base46").get_theme_tb "base_30"
-- fg = "white" set by user becomes fg = colors["white"] -- fg = "white" set by user becomes fg = colors["white"]

View file

@ -56,7 +56,8 @@ M.load_all_highlights = function()
end end
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" local colors = M.get_theme_tb "base_30"
for _, groups in pairs(tb) do for _, groups in pairs(tb) do