Enter conflicts with neocomplcache #22

Open
pjg opened this Issue Aug 5, 2012 · 8 comments

3 participants

@pjg
pjg commented Aug 5, 2012

This is cross-posting from neocomplcache issues as recommended by @Shougo.

Note that I'm also using vim-endwise. Using the recommended snippet from doc/neocomplcache.txt (see 351a2f102460):

  inoremap <expr><silent> <CR> <SID>my_cr_function()
  function! s:my_cr_function()
    return pumvisible() ? neocomplcache#close_popup() . "\<CR>" : "\<CR>"
  endfunction

when pressing enter when choosing autocompletion from the menu it selects this autocompletion and also moves you to the next line (i.e. <CR> is literally inserted), while using the previous snippet for <CR> mapping in insert mode (inoremap <expr><CR> neocomplcache#smart_close_popup() . "\<CR>") without the vim-endwise plugin when pressing <cr> in insert mode on autocomplete menu item it would only select the item from the autocompletion menu and would not insert a <cr> in the code.

Also note that using this snippet: inoremap <expr><CR> neocomplcache#smart_close_popup() . "\<CR>" conflicts with vim-endwise, which is issue #88.

@blueyed

There is a test in endwise.vim which invokes/includes the previously defined mapping:

elseif maparg('<CR>','i') =~ '<CR>'
  exe "imap <script> <C-X><CR> ".maparg('<CR>','i')."<SID>AlwaysEnd"
  exe "imap <script> <CR>      ".maparg('<CR>','i')."<SID>DiscretionaryEnd"

Considering the recommended mapping of inoremap <expr><CR> neocomplcache#smart_close_popup() . "\<CR>" this will result in the text itself being inserted.

This could maybe be solved by endwise checking for the mapping to be a script (e.g. via maparg's dict option/mode) and acting accordingly (if that is possible), by using another mapping method with neocomplcache (e.g. without "

@blueyed

See also ervandew/supertab@c6d704c for inspiration.

@pjg

@blueyed that is a good pointer! I was using supertab previously with vim-endwise without any problems.

@blueyed blueyed added a commit to blueyed/vim-endwise that referenced this issue Sep 19, 2012
@blueyed blueyed Add `g:endwise_add_maps` to allow skipping maps
This allows to work around issues like issue #22
(tpope#22)
6dd9a1e
@tpope tpope added a commit that referenced this issue Sep 19, 2012
@blueyed blueyed Add `g:endwise_no_mappings` to allow skipping maps
This allows to work around issues like issue #22
(#22)
33f9ee0
@blueyed

@pjg
Did you get this resolved back then?

You might want to check out my pull request, which improves the mapping setup: #50

@pjg

Appreciate your effort! I have moved on to YouCompleteMe+Eclim for my tab-completion needs, though (cannot beat java parsing my ruby code and presenting me the best tab-completions possible).

@blueyed

Great.
This issue might get closed then probably.

YouCompleteMe+Eclim
👍

@tpope tpope added a commit that referenced this issue Apr 11, 2014
@tpope Experimental abbreviations
Potentially a partial replacement for remapping <CR>.

References #10, #14, #19, #22.
38541f3
@chrisnicola

Seem to have this same problem with YouCompleteMe actually

@blueyed

@chrisnicola
What is your mapping for :imap <cr>?

(I am using a custom function, where I chain multiple plugins:)

fun! My_CR_map()
  " "<CR>" via delimitMateCR
  let r = "\<Plug>delimitMateCR"
  if maparg('<Plug>CursorCrossCR', 'i')
    " requires vim 704
    let r .= "\<Plug>CursorCrossCR"
  endif
  let r .= "\<Plug>DiscretionaryEnd"
  return r
endfun
imap <expr> <CR> My_CR_map()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment