feat(hipatterns): add shorthand hex color support (#2562)

This commit is contained in:
Daniel Mata
2024-03-07 04:41:34 -06:00
committed by GitHub
parent d9f5e6db16
commit a8eeb1b75d

View File

@ -19,6 +19,18 @@ M.plugin = {
},
highlighters = {
hex_color = hi.gen_highlighter.hex_color({ priority = 2000 }),
shorthand = {
pattern = "#%x%x%x%f[%X]",
group = function(_, _, data)
---@type string
local match = data.full_match
local r, g, b = match:sub(2, 2), match:sub(3, 3), match:sub(4, 4)
local hex_color = "#" .. r .. r .. g .. g .. b .. b
return MiniHipatterns.compute_hex_color_group(hex_color, "bg")
end,
extmark_opts = { priority = 2000 },
},
},
}
end,