How to release the Content Completion menu in nvim without pressing Esc?

652 views Asked by At

I'm using hrsh7th/nvim-cmp and some related packages to achieve content completion in nvim

However, in some cases which happen enough times, it becomes very cumbersome to use. Not sure if there's a proper way of doing this or not:

Assume you just typed a word/keyword in your favorite language and you're ready to press ENTER to start a new line. At this time, nvim shows you a dropdown of your choices. I don't want any of those! I'm happy with what I typed.

How can I start my new line without selecting anything from the dropdown menu?

Currently, I have to do either of these two:

  1. press ESC to get rid of the menu. This works but removes me from the Editing mode. Then I have to press o to open a new line and start typing again
  2. press ENTER selecting one of the items in the context menu. Then press ESC to exit editing mode. press X repeatedly to delete what was pasted. Then press o to start a new line!
1

There are 1 answers

0
Jeff Saremi On

Here's how I did it:

-    ["<CR>"] = cmp.mapping.confirm { select = true },
+    ["<CR>"] = cmp.mapping.confirm { select = false },

So now the default item won't be selected by me pressing Enter. If I wanted the top item I'd be doing a Tab prior to pressing Enter.