Befedo
Befedo

Reputation: 139

How to autoexpand neosnippet with deoplete dropdown menu?

Iam looking for an configuration (init.vim) to expand an neosnippet when selected with the deoplete plugin drop down menu.

What i've done so far:

  1. Added all to vim-plug

    call plug#begin ('~/.local/share/nvim/plugged')
    Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
    Plug 'Shougo/neosnippet.vim' | Plug 'Shougo/neosnippet-snippets'
    call plug#end ()
    
  2. configured for autostart

    " Use deoplete.
    let g:deoplete#enable_at_startup = 1
    " Use smartcase.
    let g:deoplete#enable_smart_case = 1
    " Set minimum syntax keyword length.
    let g:deoplete#sources#syntax#min_keyword_length = 2
    

This leads to this screen:deoplug drop down selection

Now I want to expand this snippet, when hitting <Enter> at the selection. Has anyone suggestion how to achiev that?

Thanks for your time and best regards,

Befedo

Upvotes: 4

Views: 2435

Answers (1)

Neosnippets doesn't expand automatically. You need to configure the key mappings. The project suggest the following to expand them using Ctr+k:

" Plugin key-mappings.
" Note: It must be "imap" and "smap".  It uses <Plug> mappings.
imap <C-k>     <Plug>(neosnippet_expand_or_jump)
smap <C-k>     <Plug>(neosnippet_expand_or_jump)
xmap <C-k>     <Plug>(neosnippet_expand_target)

If you want to expand them when using the popup menu use the following:

inoremap <silent><expr><CR> pumvisible() ? deoplete#mappings#close_popup()."\<Plug>(neosnippet_expand_or_jump)" : "\<CR>"

Upvotes: 7

Related Questions