mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-13 19:04:36 +02:00
feat(hipatterns): better tailwind fg colors
This commit is contained in:
parent
ba0cfbccf3
commit
c526ea338b
1 changed files with 15 additions and 6 deletions
|
@ -1,5 +1,8 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
|
---@type table<string,true>
|
||||||
|
M.hl = {}
|
||||||
|
|
||||||
M.plugin = {
|
M.plugin = {
|
||||||
"echasnovski/mini.hipatterns",
|
"echasnovski/mini.hipatterns",
|
||||||
event = "BufReadPre",
|
event = "BufReadPre",
|
||||||
|
@ -9,14 +12,12 @@ M.plugin = {
|
||||||
-- custom LazyVim option to enable the tailwind integration
|
-- custom LazyVim option to enable the tailwind integration
|
||||||
tailwind = true,
|
tailwind = true,
|
||||||
highlighters = {
|
highlighters = {
|
||||||
hex_color = hi.gen_highlighter.hex_color({ priority = 5000 }),
|
hex_color = hi.gen_highlighter.hex_color({ priority = 2000 }),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
config = function(_, opts)
|
config = function(_, opts)
|
||||||
local hi = require("mini.hipatterns")
|
|
||||||
if opts.tailwind then
|
if opts.tailwind then
|
||||||
local hex_color = opts.highlighters.hex_color or hi.gen_highlighter.hex_color({ priority = 5000 })
|
|
||||||
local tailwind_ft = { "typescriptreact", "javascriptreact", "css", "javascript", "typescript", "html" }
|
local tailwind_ft = { "typescriptreact", "javascriptreact", "css", "javascript", "typescript", "html" }
|
||||||
opts.highlighters.tailwind = {
|
opts.highlighters.tailwind = {
|
||||||
pattern = function()
|
pattern = function()
|
||||||
|
@ -26,12 +27,20 @@ M.plugin = {
|
||||||
return "%f[%w:-]()[%w:-]+%-[a-z%-]+%-%d+()%f[^%w:-]"
|
return "%f[%w:-]()[%w:-]+%-[a-z%-]+%-%d+()%f[^%w:-]"
|
||||||
end,
|
end,
|
||||||
group = function(_, match)
|
group = function(_, match)
|
||||||
|
---@type string,string
|
||||||
local color, shade = match:match("[%w-]+%-([a-z%-]+)%-(%d+)")
|
local color, shade = match:match("[%w-]+%-([a-z%-]+)%-(%d+)")
|
||||||
local hex = vim.tbl_get(M.colors, color, tonumber(shade))
|
local bg = vim.tbl_get(M.colors, color, tonumber(shade))
|
||||||
if hex then
|
if bg then
|
||||||
return hex_color.group(nil, nil, { full_match = "#" .. hex })
|
local hl = "MiniHipatternsTailwind" .. color .. shade
|
||||||
|
if not M.hl[hl] then
|
||||||
|
M.hl[hl] = true
|
||||||
|
local fg = vim.tbl_get(M.colors, color, tonumber(shade) >= 500 and 100 or 900)
|
||||||
|
vim.api.nvim_set_hl(0, hl, { bg = "#" .. bg, fg = "#" .. fg })
|
||||||
|
end
|
||||||
|
return hl
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
priotity = 5000,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
require("mini.hipatterns").setup(opts)
|
require("mini.hipatterns").setup(opts)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue