tpope / vim-endwise

endwise.vim: Wisely add
https://www.vim.org/scripts/script.php?script_id=2386
1.11k stars 103 forks source link

Enter conflicts with neocomplcache #22

Open pjg opened 12 years ago

pjg commented 12 years ago

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 commented 12 years ago

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 " Githubissues.

  • Githubissues is a development platform for aggregating issues.