You can try with this setting
require("cmp").setup({
formatting = {
format = function (entry, vim_item)
vim_item.dup = { buffer = 1, path = 1, nvim_lsp = 0 }
end
}
})
Error executing vim.schedule lua callback: ...e/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/entry.lua:290: attempt to index local 'vim_item' (a nil value)
stack traceback:
...e/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/entry.lua:290: in function 'callback'
.../site/pack/packer/start/nvim-cmp/lua/cmp/utils/cache.lua:36: in function 'get_vim_item'
...e/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/entry.lua:205: in function 'get_view'
...cker/start/nvim-cmp/lua/cmp/view/custom_entries_view.lua:121: in function 'open'
...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/view.lua:107: in function 'open'
...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:284: in function 'cb'
vim.lua:285: in function <vim.lua:285>
my config
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
vim.o.completeopt = 'menuone,noselect'
-- luasnip setup
local luasnip = require 'luasnip'
-- nvim-cmp setup
local cmp = require 'cmp'
cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
formatting = {
format = function (entry, vim_item)
vim_item.dup = { buffer = 1, path = 1, nvim_lsp = 0 }
end,
},
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'path' },
{ name = 'buffer', option = {
get_bufnrs = function()
return vim.api.nvim_list_bufs()
end
},
},
},
}