How to prevent cmp from auto-selecting first entry on <enter> #997
-
|
Hi, I'm trying to prevent nvim-cmp from auto-inserting the first item shown in the completion menu when I press I have nvim-cmp setup like this currently: " In ~/.config/nvim/init.vim
set completeopt=menuone,noselect,noinsert-- Setup nvim-cmp.
local cmp = require'cmp'
cmp.setup({
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 = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' }, -- For luasnip users.
{ name = 'buffer' },
}),
completion = {
completeopt = 'menu,menuone,noinsert'
}
})Please note the part about However, with this setting, if I open a Python file with the contents: def foobar():
y = fooand go the end of the second line I'd greatly appreciate any help fixing this :) Alternatively, is there a good way to configure |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
Please escape your text. Some characters are hidden. And |
Beta Was this translation helpful? Give feedback.
-
|
Please see my minimal init.vim set rtp+=~/src/nvim-cmp
set rtp+=~/src/cmp-buffer
set rtp+=~/src/cmp-nvim-lsp
set rtp+=~/src/vim-vsnip
set rtp+=~/src/cmp-vsnip
set rtp+=~/src/nvim-lspconfig
set rtp+=~/src/cmp-cmdline
set completeopt=menuone,noselect
lua <<EOF
-- Setup nvim-cmp.
local cmp = require'cmp'
cmp.setup({
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
mapping = {
['<CR>'] = cmp.mapping.confirm({ select = false }),
['<tab>'] = cmp.mapping(cmp.mapping.confirm({ select = true }), { 'i', 's', 'c' }),
['<C-n>'] = cmp.mapping({
i = function(fallback)
if cmp.visible() then
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
else
fallback()
end
end
}),
['<C-p>'] = cmp.mapping({
i = function(fallback)
if cmp.visible() then
cmp.select_prev_item({ behavior = cmp.SelectBehavior.Select })
else
fallback()
end
end
}),
},
sources = {
{ name = 'nvim_lsp' },
{ name = 'buffer' },
},
})
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'cmdline' }
}
})
EOF
lua << EOF
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
--require'lspconfig'.sumneko_lua.setup{}
require'lspconfig'.cssls.setup{}
require'lspconfig'.pylsp.setup{}
EOF
runtime! after/plugin/*.lua |
Beta Was this translation helpful? Give feedback.


Please see my minimal init.vim