Skip to content

Commit

Permalink
utils: Refactor apply_syntax for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
judaew committed Sep 7, 2023
1 parent af8edf5 commit e022629
Showing 1 changed file with 10 additions and 62 deletions.
72 changes: 10 additions & 62 deletions lua/ronny/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,68 +6,16 @@ function M.apply_syntax(table)
for group, style in pairs(table) do
local hl_group = {}

if style.fg then
hl_group.foreground = style.fg
end

if style.bg then
hl_group.background = style.bg
end

if style.sp then
hl_group.special = style.sp
end

if style.blend then
hl_group.blend = style.blend
end

if style.bold then
hl_group.bold = style.bold
end

if style.standout then
hl_group.standout = style.standout
end

if style.underline then
hl_group.underline = style.underline
end

if style.undercurl then
hl_group.undercurl = style.undercurl
end

if style.underdouble then
hl_group.underdouble = style.underdouble
end

if style.underdotted then
hl_group.underdotted = style.underdotted
end

if style.underdashed then
hl_group.underdashed = style.underdashed
end

if style.strikethrough then
hl_group.strikethrough = style.strikethrough
end

if style.italic then
hl_group.italic = style.italic
end

if style.reverse then
hl_group.reverse = style.reverse
end

if style.nocombine then
hl_group.nocombine = style.nocombine
end

if style.link then
hl_group.link = style.link
local style_props = {
"fg", "bg", "sp", "blend", "bold", "standout", "underline",
"undercurl", "underdouble", "underdotted", "underdashed",
"strikethrough", "italic", "reverse", "nocombine", "link"
}

for _, prop in ipairs(style_props) do
if style[prop] then
hl_group[prop] = style[prop]
end
end

hl(0, group, hl_group)
Expand Down

0 comments on commit e022629

Please sign in to comment.