Compare commits

..

2 Commits

Author SHA1 Message Date
5373af76f8 chore(main): release 4.1.0 (#828)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-05-25 23:34:31 +02:00
c526ea338b feat(hipatterns): better tailwind fg colors 2023-05-25 23:32:55 +02:00
2 changed files with 22 additions and 6 deletions

View File

@ -1,5 +1,12 @@
# Changelog
## [4.1.0](https://github.com/LazyVim/LazyVim/compare/v4.0.0...v4.1.0) (2023-05-25)
### Features
* **hipatterns:** better tailwind fg colors ([c526ea3](https://github.com/LazyVim/LazyVim/commit/c526ea338b415a51fa78936b7044ec67d78528b2))
## [4.0.0](https://github.com/LazyVim/LazyVim/compare/v3.7.2...v4.0.0) (2023-05-25)

View File

@ -1,5 +1,8 @@
local M = {}
---@type table<string,true>
M.hl = {}
M.plugin = {
"echasnovski/mini.hipatterns",
event = "BufReadPre",
@ -9,14 +12,12 @@ M.plugin = {
-- custom LazyVim option to enable the tailwind integration
tailwind = true,
highlighters = {
hex_color = hi.gen_highlighter.hex_color({ priority = 5000 }),
hex_color = hi.gen_highlighter.hex_color({ priority = 2000 }),
},
}
end,
config = function(_, opts)
local hi = require("mini.hipatterns")
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" }
opts.highlighters.tailwind = {
pattern = function()
@ -26,12 +27,20 @@ M.plugin = {
return "%f[%w:-]()[%w:-]+%-[a-z%-]+%-%d+()%f[^%w:-]"
end,
group = function(_, match)
---@type string,string
local color, shade = match:match("[%w-]+%-([a-z%-]+)%-(%d+)")
local hex = vim.tbl_get(M.colors, color, tonumber(shade))
if hex then
return hex_color.group(nil, nil, { full_match = "#" .. hex })
local bg = vim.tbl_get(M.colors, color, tonumber(shade))
if bg then
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,
priotity = 5000,
}
end
require("mini.hipatterns").setup(opts)