From a8eeb1b75d9df360f2b63f0f52708f24172990e5 Mon Sep 17 00:00:00 2001 From: Daniel Mata <100956688+matadaniel@users.noreply.github.com> Date: Thu, 7 Mar 2024 04:41:34 -0600 Subject: [PATCH] feat(hipatterns): add shorthand hex color support (#2562) --- lua/lazyvim/plugins/extras/util/mini-hipatterns.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua b/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua index 2add9c2f..c261b14f 100644 --- a/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua +++ b/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua @@ -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,