dotfiles/nvim/.config/nvim/after/plugin/cmp.lua
Sanchayan Maity 48d64d6de1 nvim: after/plugin/cmp: Update settings
Seems we missed a few things last time. The formatting.fields thing is
a new feature.
2021-10-12 20:15:57 +05:30

66 lines
1.3 KiB
Lua

local cmp = require 'cmp'
local lspkind = require 'lspkind'
cmp.setup {
preselect = cmp.PreselectMode.None,
completion = {
completeopt = 'menu,menuone,noinsert',
},
formatting = {
fields = { 'kind', 'abbr', 'menu' },
format = function(entry, vim_item)
vim_item.menu = ({
buffer = '[Buffer]',
nvim_lsp = '[Lsp]',
nvim_lua = '[Lua]',
path = '[Path]',
vsnip = '[Snippet]',
})[entry.source.name]
vim_item.kind = lspkind.presets.default[vim_item.kind]
return vim_item
end,
},
snippet = {
expand = function (args)
vim.fn["vsnip#anonymous"](args.body)
end
},
documentation = {
border = 'rounded'
},
mapping = {
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<CR>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = false
}),
},
sources = {
{
name = 'nvim_lsp',
priority = 100
},
{
name = 'vsnip',
priority = 80
},
{
name = 'nvim_lua',
priority = 50
},
{
name = 'buffer',
priority = 20
},
{
name = 'path',
priority = 5
},
},
experimental = {
native_menu = false,
ghost_text = { hl_group = 'Hint' },
}
}