Deoplete.nvim: How to expand Neosnippet snippets?

Created on 6 Feb 2016  路  2Comments  路  Source: Shougo/deoplete.nvim

Hi @Shougo

How can I add my neosnippet snippets as a source to the sources dictionary so I can also complete and expand together with my other sources (such as from deoplete-go or buffer).

I couldn't find it inside the doc, nor could I see it in the closed issues.

Thanks

Most helpful comment

Ok I've fixed and customized it according to my own needs. If anyone is curious below is the implementation I use tab for expanding both a snippet and also use it to jump to the next item inside a completion menu.

But note that I have disabled neosnippet as a source as I don't want to have any kind of completion for it:

let g:deoplete#ignore_sources = {}
let g:deoplete#ignore_sources._ = ["neosnippet"]

If you want to have snippets in your completion menu you have to change the logic. But it's fairly easy, just change the function below. Here is the function which implements a custom tab mapping for the insert mode:

" I want to use my tab more smarter. If we are inside a completion menu jump
" to the next item. Otherwise check if there is any snippet to expand, if yes
" expand it. Also if inside a snippet and we need to jump tab jumps. If none
" of the above matches we just call our usual 'tab'.
function! s:neosnippet_complete()
  if pumvisible()
    return "\<c-n>"
  else
    if neosnippet#expandable_or_jumpable() 
      return "\<Plug>(neosnippet_expand_or_jump)"
    endif
    return "\<tab>"
  endif
endfunction

imap <expr><TAB> <SID>neosnippet_complete()

All 2 comments

Seem's like it's already included but doesn't expand when I hit enter (<CR>) even though I have this:

inoremap <silent><expr><CR>  pumvisible() ? "\<C-y>" : "\<CR>"

(edit: Changed the title to make it more clear)

Ok I've fixed and customized it according to my own needs. If anyone is curious below is the implementation I use tab for expanding both a snippet and also use it to jump to the next item inside a completion menu.

But note that I have disabled neosnippet as a source as I don't want to have any kind of completion for it:

let g:deoplete#ignore_sources = {}
let g:deoplete#ignore_sources._ = ["neosnippet"]

If you want to have snippets in your completion menu you have to change the logic. But it's fairly easy, just change the function below. Here is the function which implements a custom tab mapping for the insert mode:

" I want to use my tab more smarter. If we are inside a completion menu jump
" to the next item. Otherwise check if there is any snippet to expand, if yes
" expand it. Also if inside a snippet and we need to jump tab jumps. If none
" of the above matches we just call our usual 'tab'.
function! s:neosnippet_complete()
  if pumvisible()
    return "\<c-n>"
  else
    if neosnippet#expandable_or_jumpable() 
      return "\<Plug>(neosnippet_expand_or_jump)"
    endif
    return "\<tab>"
  endif
endfunction

imap <expr><TAB> <SID>neosnippet_complete()
Was this page helpful?
0 / 5 - 0 ratings

Related issues

magicalbanana picture magicalbanana  路  44Comments

SkyLeach picture SkyLeach  路  23Comments

ExpandingMan picture ExpandingMan  路  35Comments

lifepillar picture lifepillar  路  29Comments

puresick picture puresick  路  19Comments