nvim-cmp
nvim-cmp copied to clipboard
Ctrl-N doesn't work for buffers
FAQ
- [X] I have checked the FAQ and it didn't resolve my problem.
Announcement
- [X] I have checked Breaking change announcement.
Minimal reproducible full config
Here's repro.lua , nvim -u ~/repro.lua
vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()
require("lazy.minit").repro({
spec = {
{
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
},
opts = function(_, opts)
local cmp = require("cmp")
opts.mapping = cmp.mapping.preset.insert({
["<C-Space>"] = cmp.mapping.complete(),
})
opts.sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "path" },
}, {
{ name = "buffer" },
})
end,
},
},
})
Description
Ctrl N doesn't work with new buffers, seems like cmp.mapping.complete(), is the cause?
Steps to reproduce
-
Make a new File, then type anything, eg, apple -
type :sp foo.txt -
Type ap -
Press Ctrl-N
Expected behavior
It should pick up apple on the other buffer as source of completion
Actual behavior
Nothing Happens
Additional context
If you comment this line, it works:
-- opts.mapping = cmp.mapping.preset.insert({
-- ["<C-Space>"] = cmp.mapping.complete(),
-- })
Reference issue filed in LazyVim: https://github.com/LazyVim/LazyVim/issues/4414
I believe this is neither a LazyVim bug nor a nvim-cmp bug. Please see comment here and kindly correct me if I'm somewhere mistaken.