@@ -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 )
0 commit comments