Closed naquad closed 6 years ago
You cannot use it from command.
You need to call neosnippet#expand()
as mapping-<expr>
.
It is invalid usage. Closing.
I don't want to support it from Denite. It is complex.
P. S. I've tried to let g:neosnippet#enable_completed_snippet=1 but that didn't help.
It is different feature.
Ok do you have any ideas on how to invoke neosnippet from outside of mapping? I've tried feedkeys()
and norm
command, but no luck.
I've came up with this:
function! s:InvokeSnippet(snip) abort
exec "nmap <buffer><silent><expr> \\tmp_expand neosnippet#expand('" . escape(a:snip, '\\''') . "')"
norm \tmp_expand
nunmap <buffer> \tmp_expand
call cursor('.', col('.') + 1)
startinsert
endfunction
command! -nargs=1 InvokeSnippet :call <SID>InvokeSnippet(<f-args>)
Super ugly, but works.
Even better:
function! s:InvokeSnippet(trigger) abort
let snippets = neosnippet#helpers#get_snippets()
if ! has_key(snippets, a:trigger)
return
endif
let col = col('.')
let pre = getline('.')[:col - 1]
let snippet = snippets[a:trigger]
call neosnippet#view#_insert(snippet.snip, snippet.options, pre, col + 1)
endfunction
command! -nargs=1 InvokeSnippet :call <SID>InvokeSnippet(<f-args>)
Hi.
I'm trying to implement a command that will expand given snippet (need it for Denite menu). Currently it looks like this:
I try to invoke it as
:ExpandSnippet date_english
and nothing happens. But typing it in manually and pressing tab works fine.Neosnippet is current master NeoVIM is 0.3.0
P. S. I've tried to
let g:neosnippet#enable_completed_snippet=1
but that didn't help.