When Is there a more elegant way to verify the completion selected 'abbr'? Please see my ugly attempt below. This might be related to #492
Expected
Provide a minimal init.vim/vimrc with less than 50 lines (Required!)
" Your minimal init.vim/vimrc
set runtimepath+=~/path/to/deoplete.nvim/
let g:deoplete#enable_at_startup = 1
" --8<--- custom ----
set completeopt=menuone,noselect,noinsert
inoremap <silent><expr><CR> <SID>smart_carriage_return()
augroup user_plugin_deoplete
autocmd!
autocmd CompleteDone * call <SID>smart_complete_done()
augroup END
let g:completed_abbr = ''
function s:smart_complete_done()
" Store the last completed item abbr
let g:completed_abbr = get(v:completed_item, 'abbr', '')
silent! pclose!
endfunction
function s:smart_carriage_return()
" <CR>: If popup menu visible, close popup with selection. But insert CR
" if no selection has been made.
if pumvisible()
call deoplete#handler#_skip_next_completion()
return "\<C-y>\<C-R>=" . '(g:completed_abbr ==# "" ? "\<CR>" : "")' . "\<CR>"
endif
return "\<CR>"
endfunction
How to reproduce the problem from neovim/Vim startup (Required!)
function s:smart_carriage_return()
if !pumvisible() || get(complete_info(), 'selected', -1) < 0
return "\<CR>"
else
return "\<C-y>"
endif
endfunction
Neither the suggested snippet nor the recommendation seem to do anything.
(the snippet in the official docs does work, but breaks lexima.vim - see https://github.com/Shougo/deoplete.nvim/issues/492#issuecomment-641660357)
(the snippet in the official docs does work, but breaks lexima.vim - see #492 (comment))
Yes. Because lexima.vim overwrite <CR> mapping.
It is conflicted.
So I don't use lexima.vim.
Most helpful comment