-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lexima.vim causes <CR> to insert newline when insert completion popup menu is in "state 2" #65
Comments
+1 |
Thanks for reporing. In the past, I introduced some codes to hide popup menu forcely because some auto completion plugins (e.g. neocomplete) conflict with lexima.vim. These codes maybe cause this issue. Temporarily you can disable that feature by adding the following code into your vimrc. let g:lexima_no_default_rules = 1
call lexima#set_default_rules()
call lexima#insmode#map_hook('before', '<CR>', '') If you use any auto completion plugin, |
BTW, I don't use cursor keys, so that the completion state is not to be 2. |
@cohama To be fair, I only discovered the different popup menu states yesterday. I was reading the Vim documentation and trying to figure out what was happening. I was confused when I couldn't get state 2 to activate. When I removed all my plugins I found that state 2 would finally activate with the arrow keys, and then I traced the lack of activation of state 2 down to lexima. I also rarely use the arrow keys, and like I said, I did not know about the different popup states until yesterday, but I thought I would report it, since it does mean lexima changes default Vim behavior. I just wanted to make the project aware of this. Thank you for providing lexima! |
There is a similar problem with deoplete in Neovim. Pressing Enter just closes the popup but doesn't insert a newline. This was driving me crazy, but I tracked it down to:
I tried to override it with: inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function() abort
" Combine deoplete's smart close with lexima's expansion.
return pumvisible() ? deoplete#smart_close_popup() . "\<CR>" : lexima#expand('<CR>', 'i')
endfunction But this would still be overridden by the lexima value. Using your code snippet before my remap fixed it, but I'm not sure what it is doing. What features am I losing out on? let g:lexima_no_default_rules = 1
call lexima#set_default_rules()
call lexima#insmode#map_hook('before', '<CR>', '') My workaround. |
lexima and deoplete were fighting each other. I wanted Enter to close the popup and insert a newline; instead it just closed the popup and I would have to press enter a second time. cohama/lexima.vim#65
@docwhat I had the same problem. I'm using this workaround instead: let g:lexima_no_default_rules = 1
call lexima#set_default_rules()
call lexima#insmode#map_hook('before', '<CR>', '')
function! s:my_cr_function() abort
return deoplete#close_popup() . lexima#expand('<CR>', 'i')
endfunction
inoremap <expr> <cr> <sid>my_cr_function() |
Problem Summary
<CR>
both makes a selection and inserts a newline character when the insertion completion popup menu is in "state 2." From:help ins-completion-menu
:To get to state 2. first bring up the insert completion popup menu with
<C-P>
, then use the up or down arrows to select a different entry. If an entry is highlighted but the text in the buffer has not been updated to match that entry, you know you've reached state 2. At this point, a<CR>
is supposed to behave exactly like<C-Y>
, that is the following actions occur:When lexima.vim is present in the runtimepath, a newline is inserted, which is not the expected behavior for state 2.
Example VIMRC
Environment
OS
OS X 10.11 El Capitan
Vim version
MacVim
Plugin version
This is on commit 0aa05cb
Steps to reproduce
Edit a new file with the following contents:
In insert mode, on a new line, type
a
, then activate keyword completion with<C-P>
(state 1.)Push the Up arrow to highlight a different entry (state 2.)
Hit Enter key to issue a
<CR>
Observe that the entry was selected and used, but that a newline was entered and the cursor is now on the line below the completion
Retry the following steps without lexima.vim in the runtimepath and you will observe in step 5 that no newline is inserted and that the cursor remains immediately after the insertion.
The text was updated successfully, but these errors were encountered: