61 lines
1.6 KiB
Lua
61 lines
1.6 KiB
Lua
return {
|
|
"hrsh7th/nvim-cmp",
|
|
dependencies = {
|
|
"hrsh7th/cmp-nvim-lsp",
|
|
"hrsh7th/cmp-nvim-lua",
|
|
"hrsh7th/cmp-path",
|
|
"hrsh7th/cmp-cmdline",
|
|
"hrsh7th/cmp-buffer",
|
|
"onsails/lspkind.nvim", -- Pictograms
|
|
},
|
|
config = function()
|
|
local cmp = require("cmp")
|
|
vim.cmd("highlight FloatBorder guibg=NONE")
|
|
cmp.setup({
|
|
completion = {
|
|
completeopt = "menu,menuone,noinsert",
|
|
},
|
|
snippet = {
|
|
expand = function(args)
|
|
vim.snippet.expand(args.body)
|
|
end,
|
|
},
|
|
window = {
|
|
completion = cmp.config.window.bordered(),
|
|
documentation = cmp.config.window.bordered(),
|
|
},
|
|
mapping = cmp.mapping.preset.insert({
|
|
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
|
["<C-Space>"] = cmp.mapping.complete(),
|
|
["<C-e>"] = cmp.mapping.abort(),
|
|
["<tab>"] = cmp.mapping.confirm({ select = true }),
|
|
["<C-g>"] = function()
|
|
if cmp.visible_docs() then
|
|
cmp.close_docs()
|
|
else
|
|
cmp.open_docs()
|
|
end
|
|
end,
|
|
}),
|
|
sources = cmp.config.sources({
|
|
{ name = "nvim_lsp" },
|
|
{ name = "path" },
|
|
{ name = "buffer" },
|
|
}),
|
|
formatting = {
|
|
format = require("lspkind").cmp_format({
|
|
mode = "symbol_text",
|
|
maxwidth = {
|
|
-- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
|
|
-- can also be a function to dynamically calculate max width such as
|
|
-- menu = function() return math.floor(0.45 * vim.o.columns) end,
|
|
menu = 50, -- leading text (labelDetails)
|
|
abbr = 50, -- actual suggestion item
|
|
},
|
|
}),
|
|
},
|
|
})
|
|
end,
|
|
}
|