cohama / lexima.vim

Auto close parentheses and repeat by dot dot dot...
995 stars 46 forks source link

CR inserts new line when deoplete's completion menu is displayed in Neovim. #63

Closed ghost closed 7 years ago

ghost commented 7 years ago

Minimal config:

call plug#begin('~/.config/nvim/minimal-plugged')

Plug 'Shougo/deoplete.nvim'
Plug 'cohama/lexima.vim'

call plug#end()

let g:deoplete#enable_at_startup = 1
let g:deoplete#enable_refresh_always = 1
let g:deoplete#enable_ignore_case = 1
let g:deoplete#enable_smart_case = 1
let g:deoplete#enable_camel_case = 1
let g:deoplete#file#enable_buffer_path = 1
call deoplete#custom#set('_', 'matchers', ['matcher_full_fuzzy'])
set omnifunc=syntaxcomplete#Complete
set completeopt=longest,menuone,preview,noinsert

Steps to reproduce:

  1. Start nvim by nvim -u minimal.init.vim.
  2. Insert couple of string to populate buffer completion for Deoplete.
  3. Attempt word completion, let deoplete preselect first completion candidate.
  4. Press to accept completion.

Outcome: Upon completion accepted by cursor is moved to new line.

Expected outcome: Completion should happen without entering new line.

Both lexima and deoplete are latest versions. Neovim is 0.1.5.

Please see gif demonstrating the issue: lexima_cr_issue

cohama commented 7 years ago

lexima.vim sends <C-y> before pressing <CR> to close complete popup. (See :h omplete_CTRL-Y.)

I think neovim's <C-y> doesn't work correctly.

Please try below.

  1. Delete LINE 4 Plug 'cohama/lexima.vim' for minimal.init.vim.
  2. Repeat 1 to 3 of your steps.
  3. Press <C-y> instead of <CR>.

I tried with normal Vim (version 8.0.23) with neocomplete and nothing happend.

ghost commented 7 years ago

C-y accepts selected completion and closes the popup. That is without lexima installed.

cohama commented 7 years ago

I have found a work around. Please add below in your minimal.init.nvim and please re-try.

let g:lexima_no_default_rules = 1
call lexima#set_default_rules()
call lexima#insmode#map_hook('before', '<CR>', "<C-]><Space><BS>")
cohama commented 7 years ago

If it is good, I will merge that change into the master.

ghost commented 7 years ago

With

let g:lexima_no_default_rules = 1

call plug#begin('~/.config/nvim/minimal-plugged')

Plug 'Shougo/deoplete.nvim'
Plug 'cohama/lexima.vim'

call plug#end()

call lexima#set_default_rules()
call lexima#insmode#map_hook('before', '<CR>', "<C-]><Space><BS>")

let g:deoplete#enable_at_startup = 1
let g:deoplete#enable_refresh_always = 1
let g:deoplete#enable_ignore_case = 1
let g:deoplete#enable_smart_case = 1
let g:deoplete#enable_camel_case = 1
let g:deoplete#file#enable_buffer_path = 1
call deoplete#custom#set('_', 'matchers', ['matcher_full_fuzzy'])
set omnifunc=syntaxcomplete#Complete
set completeopt=longest,menuone,preview,noinsert

CR enters new line without accepting completion at all. It leaves whatever was inserted in the first place.

cohama commented 7 years ago

Is it OK?

ghost commented 7 years ago

Oh, no, sorry, it should accept selected completion, it doesn't with configuration you provided.

cohama commented 7 years ago

Sorry, I misunderstood. What you want is not insert new line but accept completion.

Please try below. (Add to the original min.init.nvim)

let g:lexima_no_default_rules = 1
call lexima#set_default_rules()
imap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>"
ghost commented 7 years ago

This works exactly how I want it. Is it something that should be configured by user or do you want to merge that into lexima?

EDIT: All lines you provided are required in my full init.vim, not for minimal one though.

cohama commented 7 years ago

Ok thanks. I will merge this change for neovim.

These two lines are necessary to override lexima's default mapping. (but it depends on plugin manager you use)

imap is also necessary. If you use inoremap, lexima's <CR> features are no longer available.

ghost commented 7 years ago

Thank you very much for looking into this!