Skip to content

Commit 8e3af0e

Browse files
lopi-pySaghen
andauthored
fix: tailwind colors (#306)
Co-authored-by: Liam Dyer <[email protected]>
1 parent 371ad28 commit 8e3af0e

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -430,14 +430,14 @@ MiniDeps.add({
430430
kind_icon = {
431431
ellipsis = false,
432432
text = function(ctx) return ctx.kind_icon end,
433-
highlight = function(ctx) return 'BlinkCmpKind' .. ctx.kind end,
433+
highlight = function(ctx) return utils.get_tailwind_hl(ctx) or 'BlinkCmpKind' .. ctx.kind end,
434434
},
435435

436436
kind = {
437437
ellipsis = false,
438438
width = { fill = true },
439439
text = function(ctx) return ctx.kind end,
440-
highlight = function(ctx) return 'BlinkCmpKind' .. ctx.kind end,
440+
highlight = function(ctx) return utils.get_tailwind_hl(ctx) or 'BlinkCmpKind' .. ctx.kind end,
441441
},
442442

443443
label = {

lua/blink/cmp/config.lua

+4-2
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@
174174
--- @field kind_icons? table<string, string>
175175
--- @field blocked_filetypes? string[]
176176

177+
local utils = require('blink.cmp.utils')
178+
177179
--- @type blink.cmp.Config
178180
local config = {
179181
-- the keymap may be a preset ('default' | 'super-tab' | 'enter') OR a table of keys => command[]
@@ -408,14 +410,14 @@ local config = {
408410
kind_icon = {
409411
ellipsis = false,
410412
text = function(ctx) return ctx.kind_icon end,
411-
highlight = function(ctx) return 'BlinkCmpKind' .. ctx.kind end,
413+
highlight = function(ctx) return utils.get_tailwind_hl(ctx) or 'BlinkCmpKind' .. ctx.kind end,
412414
},
413415

414416
kind = {
415417
ellipsis = false,
416418
width = { fill = true },
417419
text = function(ctx) return ctx.kind end,
418-
highlight = function(ctx) return 'BlinkCmpKind' .. ctx.kind end,
420+
highlight = function(ctx) return utils.get_tailwind_hl(ctx) or 'BlinkCmpKind' .. ctx.kind end,
419421
},
420422

421423
label = {

lua/blink/cmp/utils.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ end
8585

8686
--- @param ctx blink.cmp.DrawItemContext
8787
--- @return string|nil
88-
function utils.try_get_tailwind_hl(ctx)
88+
function utils.get_tailwind_hl(ctx)
8989
local doc = ctx.item.documentation
9090
if ctx.kind == 'Color' and doc then
9191
local content = type(doc) == 'string' and doc or doc.value
92-
if ctx.kind == 'Color' and content and content:match('^#%x%x%x%x%x%x$') then
92+
if content and content:match('^#%x%x%x%x%x%x$') then
9393
local hl_name = 'HexColor' .. content:sub(2)
9494
if #vim.api.nvim_get_hl(0, { name = hl_name }) == 0 then vim.api.nvim_set_hl(0, hl_name, { fg = content }) end
9595
return hl_name

0 commit comments

Comments
 (0)