-
How to complete and enter at the same time in cmdline mode? When I hit enter, it completes, but I almost always want to hit enter again to run the command (and if i don't, I guess I can just complete and then I have For example, to run |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Logically, in terms of cmdline, ["<CR>"] = cmp.mapping({
i = function(fallback)
if cmp.visible() and cmp.get_selected_entry() then
return cmp.confirm({ select = true })
end
fallback()
end,
c = function(fallback)
if cmp.visible() and cmp.get_selected_entry() then
cmp.confirm({ select = true })
local CR = vim.api.nvim_replace_termcodes("<CR>", true, true, true)
return vim.api.nvim_feedkeys(CR, "n", true)
end
fallback()
end,
}),
Yes |
Beta Was this translation helpful? Give feedback.
-
Interestingly, I have the exact opposite problem. My config is like yours, but for me, it always accepts the completion and then executes the command in one go, but I don't want it to! |
Beta Was this translation helpful? Give feedback.
Logically, in terms of cmdline,
cmp.confirm
only confirms (i.e. select then insert) the selection, and it has nothing to do with executing the command, so you need to confirm it and then feed theCR
to execute the command