Closed adriantrunzo closed 7 months ago
I use a custom <CR> mapping for autopairs like so:
<CR>
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>\<Plug>AutoPairsReturn"
I can't figure out how to get that mapping to work with vimcomplete.
My <CR> mapping is either unmapped or overwritten, depending on the value of noNewlineInCompletion. I think the issue lies here: https://github.com/girishji/vimcomplete/blob/a4c8c4c80af5f481cec4e53a03cd789547188e1c/autoload/vimcomplete/completor.vim#L327
noNewlineInCompletion
No matter what, vimcomplete changes the behavior of <CR>.
The plugin only maps <CR> if I haven't mapped it in my vimrc or provides an option to not modify <CR>.
I tried a workaround by adding an autocommand on the BufNewFile and BufReadPost events like used in VimCompEnable:
autocmd Config BufNewFile,BufReadPost * \ inoremap <expr> <buffer> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>\<Plug>AutoPairsReturn"
That autocmd didn't work though. I guess it's running before the ones set up in VimCompEnable.
Can you try now? <cr> is mapped only when no prior mapping exist.
<cr>
Thanks, this fix works for me.
Issue
I use a custom
<CR>
mapping for autopairs like so:I can't figure out how to get that mapping to work with vimcomplete.
Actual Behavior
My
<CR>
mapping is either unmapped or overwritten, depending on the value ofnoNewlineInCompletion
. I think the issue lies here: https://github.com/girishji/vimcomplete/blob/a4c8c4c80af5f481cec4e53a03cd789547188e1c/autoload/vimcomplete/completor.vim#L327No matter what, vimcomplete changes the behavior of
<CR>
.Expected Behavior
The plugin only maps
<CR>
if I haven't mapped it in my vimrc or provides an option to not modify<CR>
.Discussion
I tried a workaround by adding an autocommand on the BufNewFile and BufReadPost events like used in VimCompEnable:
That autocmd didn't work though. I guess it's running before the ones set up in VimCompEnable.