This commit is contained in:
siduck 2022-11-21 21:06:49 +05:30
parent 8f92334c57
commit 4f789d3406
4 changed files with 54 additions and 12 deletions

View file

@ -8,6 +8,35 @@ loadfile(vim.g.base46_cache .. "cmp")()
vim.o.completeopt = "menu,menuone,noselect"
local cmp_ui = require("core.utils").load_config().ui.cmp
local cmp_style = cmp_ui.style
local field_arrangement = {
atom = { "kind", "abbr", "menu" },
atom_colored = { "kind", "abbr", "menu" },
}
local formatting_style = {
-- default fields order i.e completion word + item.kind + item.kind icons
fields = field_arrangement[cmp_style] or { "abbr", "kind", "menu" },
format = function(_, item)
local icons = require("nvchad_ui.icons").lspkind
local icon = (cmp_ui.icons and icons[item.kind]) or ""
if cmp_style == "atom" or cmp_style == "atom_colored" then
icon = " " .. icon .. " "
item.menu = cmp_ui.lspkind_text and " (" .. item.kind .. ")" or ""
item.kind = icon
else
icon = cmp_ui.lspkind_text and (" " .. icon .. " ") or icon
item.kind = string.format("%s %s", icon, cmp_ui.lspkind_text and item.kind or "")
end
return item
end,
}
local function border(hl_name)
return {
{ "", hl_name },
@ -33,11 +62,12 @@ end
local options = {
window = {
completion = {
border = border "CmpBorder",
winhighlight = "Normal:CmpPmenu,CursorLine:PmenuSel,Search:None",
side_padding = (cmp_style ~= "atom" and cmp_style ~= "atom_colored") and 1 or 0,
winhighlight = "Normal:CmpPmenu,CursorLine:CmpSel,Search:PmenuSel",
},
documentation = {
border = border "CmpDocBorder",
winhighlight = "Normal:CmpDoc",
},
},
snippet = {
@ -45,13 +75,9 @@ local options = {
require("luasnip").lsp_expand(args.body)
end,
},
formatting = {
format = function(_, vim_item)
local icons = require("nvchad_ui.icons").lspkind
vim_item.kind = string.format("%s %s", icons[vim_item.kind], vim_item.kind)
return vim_item
end,
},
formatting = formatting_style,
mapping = {
["<C-p>"] = cmp.mapping.select_prev_item(),
["<C-n>"] = cmp.mapping.select_next_item(),
@ -97,6 +123,10 @@ local options = {
},
}
if cmp_style ~= "atom" and cmp_style ~= "atom_colored" then
options.window.completion.border = border "CmpBorder"
end
-- check for any override
options = require("core.utils").load_override(options, "hrsh7th/nvim-cmp")