Skip to content

Commit

Permalink
fix(highlighter): only preprocess the attributes before applying high…
Browse files Browse the repository at this point in the history
…lights

This change will allow getting the styles of specific highlight group.
  • Loading branch information
ramojus committed Feb 20, 2024
1 parent a72e8ea commit 9e37bca
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lua/mellifluous/utils/highlighter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,9 @@ local function get_hex(color)
end

function M.set(name, attributes)
if attributes.style then
for style_name, val in pairs(attributes.style) do
attributes[style_name] = val
end
if not attributes.style then
attributes.style = {}
end
attributes.style = nil
attributes.fg = get_hex(attributes.fg)
attributes.bg = get_hex(attributes.bg)

highlights[name] = attributes
end
Expand All @@ -33,6 +28,13 @@ end

function M.apply_all()
for name, attributes in pairs(highlights) do
for style_name, val in pairs(attributes.style) do
attributes[style_name] = val
end
attributes.style = nil
attributes.fg = get_hex(attributes.fg)
attributes.bg = get_hex(attributes.bg)

vim.api.nvim_set_hl(0, name, attributes)
end
end
Expand Down

0 comments on commit 9e37bca

Please sign in to comment.