Replies: 1 comment
-
In your lazy.nvim configuration, you are using opts as a function. I assume this is a function because the cmp variable can be declared. In order for this to work, you have to return a lua table in the opts config. Here's an example: opts = function()
-- Set up nvim-cmp.
local cmp = require("cmp")
return {
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
require("luasnip").lsp_expand(args.body) -- For `luasnip` users.
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(),
["<CR>"] = cmp.mapping.confirm({select = true}) -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}
),
sources = cmp.config.sources(
{
{name = "luasnip"}, -- For luasnip users.
{name = "nvim_lsp"}
},
{
{name = "buffer"}
}
)
}
end, |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello! I'm trying to set up nvim-cmp with its default autocompletion options, but I'm running into some trouble.
I've been following the nvim-cmp documentation on GitHub, which provides the following default configuration using vim-plug:
I've translated this configuration to use with Lazy.nvim, specifically opting for luasnip as my snippet engine. Here's my current lazy.nvim configuration for nvim-cmp:
The issue is that this configuration isn't working but doesn't show any error. My understanding from the lazy.nvim documentation is that if an opts key is present, lazy.nvim will automatically call the setup function for the plugin with the provided opts table, so I suppose that it is not necessary to write require("plugin").setup({opts}) but maybe I am wrong.

Any idea what I am missing?
Beta Was this translation helpful? Give feedback.
All reactions