2024-02-25 17:12:48 +00:00
|
|
|
return {
|
|
|
|
{
|
2024-04-13 08:49:11 +00:00
|
|
|
"hrsh7th/nvim-cmp",
|
2024-02-25 17:12:48 +00:00
|
|
|
dependencies = {
|
|
|
|
-- extra completion plugins
|
2024-04-13 08:49:11 +00:00
|
|
|
"hrsh7th/cmp-cmdline",
|
|
|
|
"hrsh7th/cmp-path",
|
|
|
|
"hrsh7th/cmp-buffer",
|
|
|
|
"hrsh7th/cmp-nvim-lsp",
|
|
|
|
"hrsh7th/cmp-calc",
|
|
|
|
"hrsh7th/cmp-emoji",
|
|
|
|
"kdheepak/cmp-latex-symbols",
|
2024-02-25 17:12:48 +00:00
|
|
|
-- snippets
|
2024-04-13 08:49:11 +00:00
|
|
|
"saadparwaiz1/cmp_luasnip",
|
|
|
|
"L3MON4D3/LuaSnip",
|
|
|
|
"onsails/lspkind.nvim",
|
2024-02-25 17:12:48 +00:00
|
|
|
},
|
2024-03-01 17:57:06 +00:00
|
|
|
config = function(_, _)
|
2024-04-13 08:49:11 +00:00
|
|
|
local cmp = require("cmp")
|
2024-02-25 17:12:48 +00:00
|
|
|
cmp.setup({
|
2024-03-01 17:57:06 +00:00
|
|
|
window = {
|
|
|
|
completion = {
|
2024-05-12 17:38:26 +00:00
|
|
|
border = "none",
|
2024-03-01 17:57:06 +00:00
|
|
|
scrollbar = false,
|
2024-05-12 17:38:26 +00:00
|
|
|
winhighlight = "Normal:Pmenu,FloatBorder:FloatBorder,Search:None",
|
2024-03-01 17:57:06 +00:00
|
|
|
},
|
|
|
|
documentation = {
|
2024-05-12 17:38:26 +00:00
|
|
|
border = "none",
|
2024-03-01 17:57:06 +00:00
|
|
|
scrollbar = false,
|
2024-05-12 17:38:26 +00:00
|
|
|
winhighlight = "Normal:Pmenu,FloatBorder:FloatBorder,Search:None",
|
2024-03-01 17:57:06 +00:00
|
|
|
},
|
|
|
|
},
|
2024-02-25 17:12:48 +00:00
|
|
|
snippet = {
|
|
|
|
expand = function(args)
|
2024-04-13 08:49:11 +00:00
|
|
|
require("luasnip").lsp_expand(args.body)
|
2024-02-25 17:12:48 +00:00
|
|
|
end,
|
|
|
|
},
|
|
|
|
completion = {
|
2024-05-12 17:38:26 +00:00
|
|
|
completeopt = "longest,menuone,noinsert,noselect",
|
2024-02-25 17:12:48 +00:00
|
|
|
},
|
|
|
|
sources = cmp.config.sources({
|
2024-04-13 08:49:11 +00:00
|
|
|
{ name = "nvim_lsp" },
|
|
|
|
{ name = "nvim_lsp_signature_help" },
|
2024-05-12 17:38:26 +00:00
|
|
|
{ name = "luasnip" },
|
2024-04-13 08:49:11 +00:00
|
|
|
{ name = "buffer" },
|
2024-03-01 17:57:06 +00:00
|
|
|
{ name = "path" },
|
|
|
|
}, {
|
2024-05-12 17:38:26 +00:00
|
|
|
{ name = "calc" },
|
2024-04-13 08:49:11 +00:00
|
|
|
{ name = "emoji" },
|
2024-02-25 17:12:48 +00:00
|
|
|
{ name = "cmdline" },
|
2024-04-13 08:49:11 +00:00
|
|
|
{ name = "latex_symbols" },
|
2024-02-25 17:12:48 +00:00
|
|
|
}),
|
|
|
|
mapping = cmp.mapping.preset.insert({
|
2024-04-13 08:49:11 +00:00
|
|
|
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
|
|
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
|
|
|
["<C-Space>"] = cmp.mapping.complete(),
|
|
|
|
["<C-e>"] = cmp.mapping.abort(),
|
2024-03-01 17:57:06 +00:00
|
|
|
["<CR>"] = cmp.mapping({
|
2024-04-13 08:49:11 +00:00
|
|
|
i = function(fallback)
|
|
|
|
if cmp.visible() and cmp.get_active_entry() then
|
|
|
|
cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
|
|
|
|
else
|
|
|
|
fallback()
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
s = cmp.mapping.confirm({ select = true }),
|
|
|
|
c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
|
|
|
|
}),
|
2024-02-25 17:12:48 +00:00
|
|
|
}),
|
|
|
|
formatting = {
|
2024-04-13 08:26:19 +00:00
|
|
|
fields = { "kind", "abbr", "menu" },
|
2024-02-25 17:12:48 +00:00
|
|
|
format = function(entry, item)
|
2024-04-13 08:49:11 +00:00
|
|
|
local kind = require("lspkind").cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, item)
|
2024-04-13 08:26:19 +00:00
|
|
|
local strings = vim.split(kind.kind, "%s", { trimempty = true })
|
|
|
|
kind.kind = (strings[1] or "") .. " "
|
|
|
|
kind.menu = " (" .. (strings[2] or "") .. ")"
|
|
|
|
|
|
|
|
return kind
|
2024-04-13 08:49:11 +00:00
|
|
|
end,
|
2024-03-01 17:57:06 +00:00
|
|
|
},
|
|
|
|
experimental = {
|
2024-04-13 08:49:11 +00:00
|
|
|
ghost_text = {
|
|
|
|
hl_group = "NonText",
|
|
|
|
},
|
|
|
|
},
|
2024-02-25 17:12:48 +00:00
|
|
|
})
|
2024-04-13 08:49:11 +00:00
|
|
|
end,
|
|
|
|
},
|
2024-02-25 17:12:48 +00:00
|
|
|
}
|