diff --git a/autoload/neosnippet/helpers.vim b/autoload/neosnippet/helpers.vim index 495d02b..69357e4 100644 --- a/autoload/neosnippet/helpers.vim +++ b/autoload/neosnippet/helpers.vim @@ -44,7 +44,9 @@ function! neosnippet#helpers#get_cursor_snippet(snippets, cur_text) abort "{{{ return cur_word endfunction"}}} -function! neosnippet#helpers#get_snippets() abort "{{{ +function! neosnippet#helpers#get_snippets(...) abort "{{{ + let mode = get(a:000, 0, mode()) + call neosnippet#init#check() let neosnippet = neosnippet#variables#current_neosnippet() @@ -56,7 +58,7 @@ function! neosnippet#helpers#get_snippets() abort "{{{ let cur_text = neosnippet#util#get_cur_text() - if mode() ==# 'i' + if mode ==# 'i' || mode ==# 's' " Special filters. if !s:is_beginning_of_line(cur_text) call filter(snippets, '!v:val.options.head') diff --git a/autoload/neosnippet/mappings.vim b/autoload/neosnippet/mappings.vim index 696e088..65a5746 100644 --- a/autoload/neosnippet/mappings.vim +++ b/autoload/neosnippet/mappings.vim @@ -32,7 +32,8 @@ endfunction"}}} function! neosnippet#mappings#expandable() abort "{{{ " Check snippet trigger. return neosnippet#helpers#get_cursor_snippet( - \ neosnippet#helpers#get_snippets(), neosnippet#util#get_cur_text()) != '' + \ neosnippet#helpers#get_snippets('i'), + \ neosnippet#util#get_cur_text()) != '' endfunction"}}} function! neosnippet#mappings#jumpable() abort "{{{ " Found snippet placeholder. @@ -95,8 +96,8 @@ function! neosnippet#mappings#_expand_target() abort "{{{ let trigger = input('Please input snippet trigger: ', \ '', 'customlist,neosnippet#commands#_complete_target_snippets') let neosnippet = neosnippet#variables#current_neosnippet() - if !has_key(neosnippet#helpers#get_snippets(), trigger) || - \ neosnippet#helpers#get_snippets()[trigger].snip !~# + if !has_key(neosnippet#helpers#get_snippets('i'), trigger) || + \ neosnippet#helpers#get_snippets('i')[trigger].snip !~# \ neosnippet#get_placeholder_target_marker_pattern() if trigger != '' echo 'The trigger is invalid.' @@ -153,7 +154,7 @@ endfunction"}}} function! s:snippets_expand(cur_text, col) abort "{{{ let cur_word = neosnippet#helpers#get_cursor_snippet( - \ neosnippet#helpers#get_snippets(), + \ neosnippet#helpers#get_snippets('i'), \ a:cur_text) call neosnippet#view#_expand( @@ -162,7 +163,7 @@ endfunction"}}} function! s:snippets_expand_or_jump(cur_text, col) abort "{{{ let cur_word = neosnippet#helpers#get_cursor_snippet( - \ neosnippet#helpers#get_snippets(), a:cur_text) + \ neosnippet#helpers#get_snippets('i'), a:cur_text) if cur_word != '' " Found snippet trigger. @@ -175,7 +176,7 @@ endfunction"}}} function! s:snippets_jump_or_expand(cur_text, col) abort "{{{ let cur_word = neosnippet#helpers#get_cursor_snippet( - \ neosnippet#helpers#get_snippets(), a:cur_text) + \ neosnippet#helpers#get_snippets('i'), a:cur_text) if search(neosnippet#get_placeholder_marker_pattern(). '\|' \ .neosnippet#get_sync_placeholder_marker_pattern(), 'nw') > 0 " Found snippet placeholder.