Skip to content

Commit 7adf477

Browse files
authored
fix(util): fix set_highlights table merge (#74)
1 parent ec2f980 commit 7adf477

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lua/astrotheme/lib/util.lua

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,17 @@ function M.set_palettes(opts)
5555
end
5656

5757
function M.set_highlights(opts, highlights, theme)
58-
pcall(opts.highlights.global.modify_hl_groups, highlights, C)
59-
pcall(opts.highlights[theme].modify_hl_groups, highlights, C)
58+
local global_hl = opts.highlights.global
59+
local theme_hl = opts.highlights[theme]
6060

61-
for group, spec in pairs(highlights) do
62-
vim.api.nvim_set_hl(0, group, spec)
61+
pcall(global_hl.modify_hl_groups, highlights, C)
62+
pcall(theme_hl.modify_hl_groups, highlights, C)
63+
64+
highlights = vim.tbl_deep_extend("force", highlights, global_hl, theme_hl)
65+
66+
for name, value in pairs(highlights) do
67+
-- TODO: optimise in V3 by removing checks.
68+
if name ~= "modify_hl_groups" then vim.api.nvim_set_hl(0, name, value) end
6369
end
6470
end
6571

0 commit comments

Comments
 (0)