Fix #297 add neosnippet#expand()
This commit is contained in:
parent
5867906757
commit
601f62b620
@ -55,6 +55,9 @@ endfunction"}}}
|
|||||||
function! neosnippet#anonymous(snippet, ...) "{{{
|
function! neosnippet#anonymous(snippet, ...) "{{{
|
||||||
return neosnippet#mappings#_anonymous(a:snippet, get(a:000, 0, {}))
|
return neosnippet#mappings#_anonymous(a:snippet, get(a:000, 0, {}))
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
function! neosnippet#expand(trigger) "{{{
|
||||||
|
return neosnippet#mappings#_expand(a:trigger)
|
||||||
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#get_snippets_directory() "{{{
|
function! neosnippet#get_snippets_directory() "{{{
|
||||||
return neosnippet#helpers#get_snippets_directory()
|
return neosnippet#helpers#get_snippets_directory()
|
||||||
|
@ -144,14 +144,24 @@ function! neosnippet#mappings#_anonymous(snippet, options) "{{{
|
|||||||
call neosnippet#view#_insert(a:snippet, options, cur_text, col('.'))
|
call neosnippet#view#_insert(a:snippet, options, cur_text, col('.'))
|
||||||
return ''
|
return ''
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
function! neosnippet#mappings#_expand(trigger) "{{{
|
||||||
|
let col = col('.')
|
||||||
|
if mode() !=# 'i'
|
||||||
|
" Fix column.
|
||||||
|
let col += 2
|
||||||
|
endif
|
||||||
|
|
||||||
|
call neosnippet#view#_expand(
|
||||||
|
\ neosnippet#util#get_cur_text(), col, a:trigger)
|
||||||
|
return ''
|
||||||
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:snippets_expand(cur_text, col) "{{{
|
function! s:snippets_expand(cur_text, col) "{{{
|
||||||
let cur_word = neosnippet#helpers#get_cursor_snippet(
|
let cur_word = neosnippet#helpers#get_cursor_snippet(
|
||||||
\ neosnippet#helpers#get_snippets(),
|
\ neosnippet#helpers#get_snippets(),
|
||||||
\ a:cur_text)
|
\ a:cur_text)
|
||||||
|
|
||||||
call neosnippet#view#_expand(
|
call neosnippet#view#_expand(a:cur_text, a:col, cur_word)
|
||||||
\ a:cur_text, a:col, cur_word)
|
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:snippets_expand_or_jump(cur_text, col) "{{{
|
function! s:snippets_expand_or_jump(cur_text, col) "{{{
|
||||||
@ -184,7 +194,7 @@ function! s:SID_PREFIX() "{{{
|
|||||||
return matchstr(expand('<sfile>'), '<SNR>\d\+_\ze\w\+$')
|
return matchstr(expand('<sfile>'), '<SNR>\d\+_\ze\w\+$')
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:trigger(function) "{{{
|
function! neosnippet#mappings#_trigger(function) "{{{
|
||||||
call neosnippet#init#check()
|
call neosnippet#init#check()
|
||||||
|
|
||||||
let cur_text = neosnippet#util#get_cur_text()
|
let cur_text = neosnippet#util#get_cur_text()
|
||||||
@ -211,16 +221,16 @@ endfunction"}}}
|
|||||||
|
|
||||||
" Plugin key-mappings.
|
" Plugin key-mappings.
|
||||||
function! neosnippet#mappings#expand_or_jump_impl()
|
function! neosnippet#mappings#expand_or_jump_impl()
|
||||||
return s:trigger(s:SID_PREFIX().'snippets_expand_or_jump')
|
return neosnippet#mappings#_trigger(s:SID_PREFIX().'snippets_expand_or_jump')
|
||||||
endfunction
|
endfunction
|
||||||
function! neosnippet#mappings#jump_or_expand_impl()
|
function! neosnippet#mappings#jump_or_expand_impl()
|
||||||
return s:trigger(s:SID_PREFIX().'snippets_jump_or_expand')
|
return neosnippet#mappings#_trigger(s:SID_PREFIX().'snippets_jump_or_expand')
|
||||||
endfunction
|
endfunction
|
||||||
function! neosnippet#mappings#expand_impl()
|
function! neosnippet#mappings#expand_impl()
|
||||||
return s:trigger(s:SID_PREFIX().'snippets_expand')
|
return neosnippet#mappings#_trigger(s:SID_PREFIX().'snippets_expand')
|
||||||
endfunction
|
endfunction
|
||||||
function! neosnippet#mappings#jump_impl()
|
function! neosnippet#mappings#jump_impl()
|
||||||
return s:trigger('neosnippet#view#_jump')
|
return neosnippet#mappings#_trigger('neosnippet#view#_jump')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let &cpo = s:save_cpo
|
let &cpo = s:save_cpo
|
||||||
|
@ -332,6 +332,14 @@ neosnippet#anonymous({snippet}, [{options}])
|
|||||||
inoremap <silent> ((
|
inoremap <silent> ((
|
||||||
\ <C-r>=neosnippet#anonymous('\left(${1}\right)${0}')<CR>
|
\ <C-r>=neosnippet#anonymous('\left(${1}\right)${0}')<CR>
|
||||||
<
|
<
|
||||||
|
*neosnippet#expand()*
|
||||||
|
neosnippet#expand({trigger})
|
||||||
|
It expands the snippet trigger.
|
||||||
|
{trigger} is snippet trigger. >
|
||||||
|
|
||||||
|
nnoremap <silent> test
|
||||||
|
\ i<C-r>=neosnippet#expand('date_english')<CR>
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
FUNCTIONS *neosnippet-functions*
|
FUNCTIONS *neosnippet-functions*
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user