tmsvg / pear-tree

A Vim auto-pair plugin that supports multi-character pairs, intelligent matching, and more
MIT License
392 stars 12 forks source link

Please disable the <CR> mapping when the completion menu is visible (pumvisible) #1

Closed char101 closed 5 years ago

char101 commented 5 years ago

Otherwise when I select an entry in the completion menu it will results in a newline.

Thanks.

tmsvg commented 5 years ago

Hi there! I'm not experiencing the behavior you describe. In my testing, pressing \<CR> simply accepts the completion entry without inserting a newline. Are you using an autocompletion plugin, or do you have mappings in your config that affect the completion menu?

Regardless, to disable pair expansion when the completion menu is visible, you can put the following in your vimrc:

imap <expr> <CR> !pumvisible() ? "\<Plug>(PearTreeExpand)" : "\<CR>"
char101 commented 5 years ago

Hi,

Thanks for your reply. I do have this mapping in my vimrc

inoremap <expr> <CR>       pumvisible() ? "\<C-y>" : "\<CR>"

Adding the mapping above seems to do the trick.