Skip to content

Commit 470588b

Browse files
committed
Add tailwindcss colors to CMP and buffer
1 parent 5244384 commit 470588b

File tree

7 files changed

+56
-2
lines changed

7 files changed

+56
-2
lines changed

lua/custom/plugins/Comment.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
return {
2+
-- XXX: neovim now has in-built support for commenting
3+
-- consider using it
24
-- use "gc" to comment visual regions/lines
35
'numToStr/Comment.nvim',
4-
dependencies = { 'JoosepAlviste/nvim-ts-context-commentstring' },
6+
dependencies = { 'JoosepAlvist/nvim-ts-context-commentstring' },
57
config = function() require('Comment').setup({
68
pre_hook = require('ts_context_commentstring.integrations.comment_nvim').create_pre_hook(),
79
})

lua/custom/plugins/mini.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ return { -- Collection of various small independent plugins/modules
88
-- - va) - [V]isually select [A]round [)]paren
99
-- - yinq - [Y]ank [I]nside [N]ext [']quote
1010
-- - ci' - [C]hange [I]nside [']quote
11-
require('mini.ai').setup { n_lines = 500 }
11+
-- require('mini.ai').setup { n_lines = 500 }
1212

1313
-- Add/delete/replace surroundings (brackets, quotes, etc.)
1414
--

lua/custom/plugins/nvim-cmp.lua

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ return { -- Autocompletion
2323
'hrsh7th/cmp-nvim-lsp',
2424
'hrsh7th/cmp-path',
2525
'Exafunction/codeium.vim',
26+
"roobert/tailwindcss-colorizer-cmp.nvim",
2627

2728
-- If you want to add a bunch of pre-configured snippets,
2829
-- you can use this plugin to help you. It even has snippets
@@ -35,8 +36,34 @@ return { -- Autocompletion
3536
local cmp = require 'cmp'
3637
local luasnip = require 'luasnip'
3738
luasnip.config.setup {}
39+
local tailwindcss_colors = require('tailwindcss-colorizer-cmp')
40+
41+
-- Controls how the completion items appear
42+
-- Prefix items by type
43+
-- Display tailwindcss colors as a square
44+
local cmp_formatter = function(entry, vim_item)
45+
-- vim_item as processed by tailwindcss-colorizer-cmp
46+
vim_item = tailwindcss_colors.formatter(entry, vim_item)
47+
-- change menu (name of source)
48+
vim_item.menu = ({
49+
nvim_lsp = "[LSP]",
50+
buffer = "[Buf]",
51+
path = "[Path]",
52+
emoji = "[Emoji]",
53+
luasnip = "[LuaSnip]",
54+
vsnip = "[VSCode Snippet]",
55+
calc = "[Calc]",
56+
spell = "[Spell]",
57+
})[entry.source.name]
58+
return vim_item
59+
end
3860

3961
cmp.setup {
62+
formatting = {
63+
-- changing the order of fields so the icon is the first
64+
fields = { "menu", "abbr", "kind" },
65+
format = cmp_formatter,
66+
},
4067
snippet = {
4168
expand = function(args)
4269
luasnip.lsp_expand(args.body)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
return {
2+
'NvChad/nvim-colorizer.lua'
3+
}

lua/custom/plugins/nvim-lspconfig.lua

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

910
-- Useful status updates for LSP.
1011
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
@@ -150,6 +151,12 @@ return { -- LSP Configuration & Plugins
150151
tsserver = {},
151152
--
152153

154+
tailwindcss = {
155+
on_attach = function(client, bufnr)
156+
require("tailwindcss-colors").buf_attach(bufnr)
157+
end
158+
},
159+
153160
lua_ls = {
154161
-- cmd = {...},
155162
-- filetypes { ...},
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
return {
2+
"roobert/tailwindcss-colorizer-cmp.nvim",
3+
lazy = true,
4+
-- optionally, override the default options:
5+
config = function()
6+
require("tailwindcss-colorizer-cmp").setup({
7+
color_square_width = 2,
8+
})
9+
end
10+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
return {
2+
'themaxmarchuk/tailwindcss-colors.nvim',
3+
lazy = true
4+
}
5+

0 commit comments

Comments
 (0)