Skip to content

Commit c9cab9e

Browse files
committed
Better plugin to highlight colors
1 parent 470588b commit c9cab9e

File tree

6 files changed

+64
-28
lines changed

6 files changed

+64
-28
lines changed

lua/custom/plugins/nvim-cmp.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ return { -- Autocompletion
2323
'hrsh7th/cmp-nvim-lsp',
2424
'hrsh7th/cmp-path',
2525
'Exafunction/codeium.vim',
26-
"roobert/tailwindcss-colorizer-cmp.nvim",
26+
'brenoprata10/nvim-highlight-colors',
2727

2828
-- If you want to add a bunch of pre-configured snippets,
2929
-- you can use this plugin to help you. It even has snippets
@@ -36,14 +36,15 @@ return { -- Autocompletion
3636
local cmp = require 'cmp'
3737
local luasnip = require 'luasnip'
3838
luasnip.config.setup {}
39-
local tailwindcss_colors = require('tailwindcss-colorizer-cmp')
39+
local nvim_highlight_colors = require("nvim-highlight-colors")
4040

4141
-- Controls how the completion items appear
4242
-- Prefix items by type
4343
-- Display tailwindcss colors as a square
4444
local cmp_formatter = function(entry, vim_item)
4545
-- vim_item as processed by tailwindcss-colorizer-cmp
46-
vim_item = tailwindcss_colors.formatter(entry, vim_item)
46+
vim_item = nvim_highlight_colors.format(entry, vim_item)
47+
4748
-- change menu (name of source)
4849
vim_item.menu = ({
4950
nvim_lsp = "[LSP]",

lua/custom/plugins/nvim-colorizer.lua

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
return {
2+
'brenoprata10/nvim-highlight-colors',
3+
lazy = true,
4+
config = function()
5+
require("nvim-highlight-colors").setup {
6+
---Render style
7+
---@usage 'background'|'foreground'|'virtual'
8+
render = 'virtual',
9+
10+
---Set virtual symbol (requires render to be set to 'virtual')
11+
virtual_symbol = '',
12+
13+
---Set virtual symbol suffix (defaults to '')
14+
virtual_symbol_prefix = '',
15+
16+
---Set virtual symbol suffix (defaults to ' ')
17+
virtual_symbol_suffix = ' ',
18+
19+
---Set virtual symbol position()
20+
---@usage 'inline'|'eol'|'eow'
21+
---inline mimics VS Code style
22+
---eol stands for `end of column` - Recommended to set `virtual_symbol_suffix = ''` when used.
23+
---eow stands for `end of word` - Recommended to set `virtual_symbol_prefix = ' ' and virtual_symbol_suffix = ''` when used.
24+
virtual_symbol_position = 'inline',
25+
26+
---Highlight hex colors, e.g. '#FFFFFF'
27+
enable_hex = true,
28+
29+
---Highlight short hex colors e.g. '#fff'
30+
enable_short_hex = true,
31+
32+
---Highlight rgb colors, e.g. 'rgb(0 0 0)'
33+
enable_rgb = true,
34+
35+
---Highlight hsl colors, e.g. 'hsl(150deg 30% 40%)'
36+
enable_hsl = true,
37+
38+
---Highlight CSS variables, e.g. 'var(--testing-color)'
39+
enable_var_usage = true,
40+
41+
---Highlight named colors, e.g. 'green'
42+
enable_named_colors = true,
43+
44+
---Highlight tailwind colors, e.g. 'bg-blue-500'
45+
enable_tailwind = false,
46+
47+
---Set custom colors
48+
---Label must be properly escaped with '%' to adhere to `string.gmatch`
49+
--- :help string.gmatch
50+
custom_colors = {
51+
{ label = '%-%-theme%-primary%-color', color = '#0f1219' },
52+
{ label = '%-%-theme%-secondary%-color', color = '#5a5d64' },
53+
},
54+
55+
-- Exclude filetypes or buftypes from highlighting e.g. 'exclude_buftypes = {'text'}'
56+
exclude_filetypes = {},
57+
exclude_buftypes = {}
58+
}
59+
end
60+
}

lua/custom/plugins/nvim-lspconfig.lua

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ return { -- LSP Configuration & Plugins
55
'williamboman/mason.nvim',
66
'williamboman/mason-lspconfig.nvim',
77
'WhoIsSethDaniel/mason-tool-installer.nvim',
8-
'themaxmarchuk/tailwindcss-colors.nvim',
98

109
-- Useful status updates for LSP.
1110
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
@@ -151,12 +150,6 @@ return { -- LSP Configuration & Plugins
151150
tsserver = {},
152151
--
153152

154-
tailwindcss = {
155-
on_attach = function(client, bufnr)
156-
require("tailwindcss-colors").buf_attach(bufnr)
157-
end
158-
},
159-
160153
lua_ls = {
161154
-- cmd = {...},
162155
-- filetypes { ...},

lua/custom/plugins/tailwindcss-colorizer-cmp.lua

Lines changed: 0 additions & 10 deletions
This file was deleted.

lua/custom/plugins/tailwindcss-colors.lua

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)