简体   繁体   中英

Make neocomplete work like AutoComplPop

After getting many crashes with AutoComplPop, I switched to neocomplete. I have already found the let g:neocomplete#enable_auto_select = 1 option which selects neocomplete's first suggestion when you hit return, as AutoComplPop does.

But I can't figure out how to do the following:

  1. Let's say I want to select the 3rd suggestion, so I <Cn> twice to get it highlighted. With AutoComplPop, I could now hit return and the currently highlight suggestion would be selected, and the suggestion window closed, without inserting a newline. With neocomplete, a newline is inserted. I realize I can just hit space and keep typing, but I want the <CR> behavior to be consistent whether I'm selecting the first suggestion or another. Otherwise muscle memory leads to mistakes.

  2. How can I get suggestions from all buffers, rather than just the current one?

  3. Can I use neocomplete with intelli-sense plugins like vim-ruby, so that the completions for, say, a String object show only string methods?

  4. I'd like each completion to be added as a separate entry in the undo history, so that I can u to undo a completion. Is this possible?

I believe what you want for question #1 is this:

function! s:close_popup_and_complete()
  return pumvisible() ? neocomplete#close_popup() : "\<CR>"
endfunction

" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>close_popup_and_complete()<CR>

For question #2 I believe that behavior was a bug and has since been fixed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM