Skip to content

Commit d9ac783

Browse files
authored
fix(util): simplify set_highlights and fix settings being cleared (#63)
fix(util): simplify set_highlight and fix settings being cleared This function was doing too much unnecessary things and was resetting user highlights tables to nil as well as unnecessarily trying to merge tables multiple times this changes should also make this function much more performant.
1 parent a182b19 commit d9ac783

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

lua/astrotheme/lib/util.lua

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

5757
function M.set_highlights(opts, highlights, theme)
58-
local opts_hl_glob = opts.highlights.global
59-
if opts_hl_glob.modify_hl_groups then
60-
opts_hl_glob.modify_hl_groups(highlights, C)
61-
opts_hl_glob.modify_hl_groups = nil
62-
end
63-
64-
highlights = vim.tbl_deep_extend("force", highlights, opts_hl_glob)
58+
pcall(opts.highlights.global.modify_hl_groups, highlights, C)
59+
pcall(opts.highlights[theme].modify_hl_groups, highlights, C)
6560

66-
local opts_hl = opts.highlights[theme]
67-
if opts_hl.modify_hl_groups then
68-
opts_hl.modify_hl_groups(highlights, C)
69-
opts_hl.modify_hl_groups = nil
70-
end
71-
72-
highlights = vim.tbl_deep_extend("force", highlights, opts_hl)
7361
for group, spec in pairs(highlights) do
74-
for key, value in pairs(spec) do
75-
if type(value) == table then spec[key] = value:toHex() end
76-
end
7762
vim.api.nvim_set_hl(0, group, spec)
7863
end
7964
end

0 commit comments

Comments
 (0)