Noob here! How to change key mappings for nvim-cmp #2832
-
Hello, When the autocompletion menu pops up, I want to be able to select the next entry with the "down" key instead of "tab", and the previous entry with the "up" key instead of "shift+tab". I spent a couple of hours searching the internet, but I can't find anything... If anybody could help me, that would be great! I just installed everything a couple of days ago from scratch, so everything is pretty much the latest stable version available, with almost no customisation. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
I had a look around in my nvim files, and I could see this in the mapping.preset.insert = function(override)
return merge_keymaps(override or {}, {
['<Down>'] = {
i = mapping.select_next_item({ behavior = types.cmp.SelectBehavior.Select }),
},
['<Up>'] = {
i = mapping.select_prev_item({ behavior = types.cmp.SelectBehavior.Select }),
},
['<C-n>'] = {
i = function()
local cmp = require('cmp')
if cmp.visible() then
cmp.select_next_item({ behavior = types.cmp.SelectBehavior.Insert })
else
cmp.complete()
end
end,
},
['<C-p>'] = {
i = function()
local cmp = require('cmp')
if cmp.visible() then
cmp.select_prev_item({ behavior = types.cmp.SelectBehavior.Insert })
else
cmp.complete()
end
end,
},
['<C-y>'] = {
i = mapping.confirm({ select = false }),
},
['<C-e>'] = {
i = mapping.abort(),
},
})
end Am I correct I thinking that this code enforce Thanks! |
Beta Was this translation helpful? Give feedback.
Oh, I see! Thanks @siduck . So the final solution is: