dotfiles/nvim/.config/nvim/after/plugin/cmp.lua
Sanchayan Maity 1f281f6bd7 nvim: after/plugin/cmp: Update nvim-cmp settings
Support for use of floating windows for completion menus landed
upstream. It introduced a new feature but also broke things. Having
native_menu set completely breaks auto completion.

While at it, add mapping for scrolling docs. Also add support for it
in color scheme.
2021-10-11 13:28:07 +05:30

61 lines
1.2 KiB
Lua

local cmp = require 'cmp'
local lspkind = require 'lspkind'
cmp.setup {
formatting = {
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 = true
}),
},
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' },
}
}