Fix #297 neosnippet#expand()
This commit is contained in:
parent
601f62b620
commit
6ce1d55242
@ -145,15 +145,28 @@ function! neosnippet#mappings#_anonymous(snippet, options) "{{{
|
|||||||
return ''
|
return ''
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#mappings#_expand(trigger) "{{{
|
function! neosnippet#mappings#_expand(trigger) "{{{
|
||||||
|
call neosnippet#init#check()
|
||||||
|
|
||||||
|
let cur_text = neosnippet#util#get_cur_text()
|
||||||
|
|
||||||
let col = col('.')
|
let col = col('.')
|
||||||
if mode() !=# 'i'
|
if mode() !=# 'i'
|
||||||
" Fix column.
|
" Fix column.
|
||||||
let col += 2
|
let col += 2
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call neosnippet#view#_expand(
|
" Get selected text.
|
||||||
\ neosnippet#util#get_cur_text(), col, a:trigger)
|
let neosnippet = neosnippet#variables#current_neosnippet()
|
||||||
return ''
|
let neosnippet.trigger = 1
|
||||||
|
let expr = ''
|
||||||
|
if mode() ==# 's' && neosnippet.optional_tabstop
|
||||||
|
let expr .= "\<C-o>\"_d"
|
||||||
|
endif
|
||||||
|
|
||||||
|
let expr .= printf("\<ESC>:call neosnippet#view#_expand(%s,%d, %s)\<CR>",
|
||||||
|
\ string(cur_text), col, string(a:trigger))
|
||||||
|
|
||||||
|
return expr
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:snippets_expand(cur_text, col) "{{{
|
function! s:snippets_expand(cur_text, col) "{{{
|
||||||
|
@ -335,10 +335,13 @@ neosnippet#anonymous({snippet}, [{options}])
|
|||||||
*neosnippet#expand()*
|
*neosnippet#expand()*
|
||||||
neosnippet#expand({trigger})
|
neosnippet#expand({trigger})
|
||||||
It expands the snippet trigger.
|
It expands the snippet trigger.
|
||||||
{trigger} is snippet trigger. >
|
{trigger} is snippet trigger.
|
||||||
|
Note: You can use this function with |map-<expr>|.
|
||||||
nnoremap <silent> test
|
>
|
||||||
|
inoremap <silent> test
|
||||||
\ i<C-r>=neosnippet#expand('date_english')<CR>
|
\ i<C-r>=neosnippet#expand('date_english')<CR>
|
||||||
|
nnoremap <silent><expr> test
|
||||||
|
\ neosnippet#expand('date_english')
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
FUNCTIONS *neosnippet-functions*
|
FUNCTIONS *neosnippet-functions*
|
||||||
|
Loading…
Reference in New Issue
Block a user