add nifty styling to completion menu

added source name to completion menu
kind-specific colorizing in the completion menu
This commit is contained in:
2024-11-05 20:12:35 -05:00
parent a4f022fdee
commit d20485daf5
+26 -3
View File
@@ -22,6 +22,10 @@ return {
require("luasnip.loaders.from_vscode").lazy_load() require("luasnip.loaders.from_vscode").lazy_load()
cmp.setup { cmp.setup {
view = {
entries = "custom",
selection_order = "near_cursor",
},
completion = { completion = {
completeopt = "menu,menuone,preview,noselect", completeopt = "menu,menuone,preview,noselect",
}, },
@@ -47,13 +51,32 @@ return {
}, },
formatting = { formatting = {
format = lspkind.cmp_format { format = lspkind.cmp_format {
mode = "text", mode = "symbol_text",
preset = "codeicons",
maxwidth = 50, maxwidth = 50,
ellipsis_char = "...", ellipsis_char = "...",
show_labelDetails = false, show_labelDetails = true,
menu = {
-- add name of source to the menu
nvim_lsp = "[LSP]",
nvim_lua = "[Lua]",
luasnip = "[LuaSnip]",
buffer = "[Buffer]",
path = "[Path]",
},
}, },
}, },
-- VSCode-like, kind specific highlights
vim.api.nvim_set_hl(0, "CmpItemAbbrDeprecated", { bg = "NONE", strikethrough = true, fg = "#808080" }),
vim.api.nvim_set_hl(0, "CmpItemAbbrMatch", { bg = "NONE", fg = "#569CD6" }),
vim.api.nvim_set_hl(0, "CmpItemAbbrMatchFuzzy", { link = "CmpIntemAbbrMatch" }),
vim.api.nvim_set_hl(0, "CmpItemKindVariable", { bg = "NONE", fg = "#9CDCFE" }),
vim.api.nvim_set_hl(0, "CmpItemKindInterface", { link = "CmpItemKindVariable" }),
vim.api.nvim_set_hl(0, "CmpItemKindText", { link = "CmpItemKindVariable" }),
vim.api.nvim_set_hl(0, "CmpItemKindFunction", { bg = "NONE", fg = "#C586C0" }),
vim.api.nvim_set_hl(0, "CmpItemKindMethod", { link = "CmpItemKindFunction" }),
vim.api.nvim_set_hl(0, "CmpItemKindKeyword", { bg = "NONE", fg = "#D4D4D4" }),
vim.api.nvim_set_hl(0, "CmpItemKindProperty", { link = "CmpItemKindKeyword" }),
vim.api.nvim_set_hl(0, "CmpItemKindUnit", { link = "CmpItemKindKeyword" }),
} }
end, end,
} }