TEST CASE:
nvim foofoobarbazfoobarbaz again, a completion for it will be shown.EXPECTED RESULT:
You are on line 3 now.
ACTUAL RESULT:
The pressing of Enter dismisses the completion menu.
This appears to be related to when there's an exact match.
(When this happened to me before, I've experimented with setting completeopt+=noselect,noinsert explicitly, but that does not seem to help now.)
Minimal vimrc:
set runtimepath+=~/.vim/neobundles/deoplete/
let g:deoplete#enable_at_startup = 1
It is Vim's feature.
Please see :help popupmenu-keys
You should remap <CR> key.
" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
return deoplete#mappings#smart_close_popup() . "\<CR>"
endfunction
@Shougo I was also troubled, Thank you for the information :)
It does not seem to work as described though?!
I am not using the cursor keys or some other method to select the entry.
The 2nd state is:
- A cursor key has been used to select another match. The match was not
inserted then, only the entry in the popup menu is highlighted.The behavior of the
key depends on the state you are in:
first state: Use the text as it is and insert a line break.
second state: Insert the currently selected match.
third state: Use the text as it is and insert a line break.In other words: If you used the cursor keys to select another entry in the
list of matches then thekey inserts that match. If you typed
something else theninserts a line break.
@blueyed FYI, I do not understand completely your ideal behavior, but
inoremap <silent><expr><CR> pumvisible() ? deoplete#mappings#close_popup()."\<CR>" : "\<CR>"
It will be
foobarbaz - does not use the completionfoobarbaz - but when insert foob, open popupmenufoobarbaz in popupmenu use <CR>, will be inserted foobarbaz on buffer, and move next lineIf you do not want to move to the next line after the selected word, remove ."\<CR>"
inoremap <silent><expr><CR> pumvisible() ? deoplete#mappings#close_popup() : "\<CR>"
Use this setting sample screencast:
https://asciinema.org/a/30892
@zchee
Thanks. deoplete#mappings#smart_close_popup() works for me.
I was referring to @Shougo statement that this is a (Neo)Vim feature.
It is not working as documented for me.
@blueyed Yes, it is not well documented behavior.
If you input "fo" (just the popup is generated), you can insert new line by <CR>.
But if you input "foobarbaz", it seems narrowing state and same with 2nd state.
- A cursor key has been used to select another match. The match was not
inserted then, only the entry in the popup menu is highlighted.
So, the <CR> just close popup menu. It is same behavior with Vim/neovim. deoplete/neocomplete is just completion plugin. I cannot fix it.
Thanks for your explanation.
A cursor key has been used to select another match.
That's not the case though, but it appears to behave like that.
As said by @zchee, we should use deoplete#mappings#close_popup() instead of deoplete#mappings#smart_close_popup() if we want the completion to occur.
Could the FAQ be updated accordingly, please?
Documentation updated.
I have also
inoremap <expr> <TAB> pumvisible() ? "\<C-y>\<cr>" : "\<TAB>"
along with
" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
return deoplete#mappings#smart_close_popup() . "\<CR>"
endfunction
And now my Enter creates a new line
Most helpful comment
It is Vim's feature.
Please see
:help popupmenu-keysYou should remap
<CR>key.