aboutsummaryrefslogtreecommitdiffstats
path: root/lua/alpha/completition/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/alpha/completition/init.lua')
-rw-r--r--lua/alpha/completition/init.lua94
1 files changed, 82 insertions, 12 deletions
diff --git a/lua/alpha/completition/init.lua b/lua/alpha/completition/init.lua
index 9933971..667e30b 100644
--- a/lua/alpha/completition/init.lua
+++ b/lua/alpha/completition/init.lua
@@ -7,6 +7,24 @@ local compare = require "cmp.config.compare"
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done { map_char = { tex = "" } })
cmp.setup {
+ window = {
+ completion = {
+ border = "rounded",
+ -- winhighlight = 'Normal:Pmenu,FloatBorder:Pmenu,CursorLine:PmenuSel,Search:None',
+ -- winblend = vim.o.pumblend,
+ -- scrolloff = 0,
+ -- col_offset = 0,
+ -- side_padding = 1,
+ -- scrollbar = true,
+ },
+ documentation = {
+ -- max_height = math.floor(WIDE_HEIGHT * (WIDE_HEIGHT / vim.o.lines)),
+ -- max_width = math.floor((WIDE_HEIGHT * 2) * (vim.o.columns / (WIDE_HEIGHT * 2 * 16 / 9))),
+ border = "rounded",
+ -- winhighlight = 'FloatBorder:NormalFloat',
+ -- winblend = vim.o.pumblend,
+ },
+ },
mapping = {
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
@@ -68,18 +86,70 @@ cmp.setup {
},
formatting = {
- format = lspkind.cmp_format {
- with_text = true,
- menu = {
- buffer = "[buf]",
- nvim_lsp = "[ ]",
- nvim_lua = "[api]",
- path = "[path]",
- luasnip = "[snip]",
- copilot = "[ﮧ ]",
- ["vim-dadbod-completion"] = "[DB]",
- },
- },
+ format = function (entry, vim_item)
+ lspkind.cmp_format {
+ with_text = true,
+ menu = {
+ buffer = "[buf]",
+ nvim_lsp = "[ ]",
+ nvim_lua = "[api]",
+ path = "[path]",
+ luasnip = "[snip]",
+ copilot = "[ﮧ ]",
+ ["vim-dadbod-completion"] = "[DB]",
+ },
+ }
+ local KIND_ICONS = {
+ Tailwind = '󰹞󰹞󰹞󰹞󰹞󰹞󰹞󰹞',
+ Color = ' ',
+ -- Class = 7,
+ -- Constant = '󰚞',
+ -- Constructor = 4,
+ -- Enum = 13,
+ -- EnumMember = 20,
+ -- Event = 23,
+ -- Field = 5,
+ -- File = 17,
+ -- Folder = 19,
+ -- Function = 3,
+ -- Interface = 8,
+ -- Keyword = 14,
+ -- Method = 2,
+ -- Module = 9,
+ -- Operator = 24,
+ -- Property = 10,
+ -- Reference = 18,
+ Snippet = " ",
+ -- Struct = 22,
+ -- Text = "",
+ -- TypeParameter = 25,
+ -- Unit = 11,
+ -- Value = 12,
+ -- Variable = 6
+ }
+ if vim_item.kind == 'Color' and entry.completion_item.documentation then
+ local _, _, r, g, b =
+ ---@diagnostic disable-next-line: param-type-mismatch
+ string.find(entry.completion_item.documentation, '^rgb%((%d+), (%d+), (%d+)')
+
+ if r and g and b then
+ local color = string.format('%02x', r) .. string.format('%02x', g) .. string.format('%02x', b)
+ local group = 'Tw_' .. color
+
+ if vim.api.nvim_call_function('hlID', { group }) < 1 then
+ vim.api.nvim_command('highlight' .. ' ' .. group .. ' ' .. 'guifg=#' .. color)
+ end
+
+ vim_item.kind = KIND_ICONS.Tailwind
+ vim_item.kind_hl_group = group
+
+ return vim_item
+ end
+ end
+
+ vim_item.kind = KIND_ICONS[vim_item.kind] or vim_item.kind
+ return vim_item
+ end
},
sorting = {