Accepting selection and executing command with a single return #1803
-
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
You can add something like this mapping = cmp.mapping.preset.cmdline({
['<C-y>'] = {
c = function()
if cmp.visible() then
cmp.confirm({ select = true })
end
local cr = vim.api.nvim_replace_termcodes('<CR>', true, true, true)
vim.api.nvim_feedkeys(cr, 'n', true)
end,
},
}) Which makes Ctrl+y select the completion item if any and then sends Enter which executes the command |
Beta Was this translation helpful? Give feedback.
-
Great, this worked! Just two small typos (replact -> replace; ce -> cr):
In the meantime, I found that the desired behavior can also be obtained with |
Beta Was this translation helpful? Give feedback.
-
@cangermueller how did you get your pop up menu to display only the available commands? Mine shows "variable" on the rightside of it: |
Beta Was this translation helpful? Give feedback.
-
Maybe my formatting options are responsible for this? See my config below.
|
Beta Was this translation helpful? Give feedback.
Great, this worked! Just two small typos (replact -> replace; ce -> cr):
In the meantime, I found that the desired behavior can also be obtained with
<c-j>
.<c-y>
accepts the selection and does not execute by default.