Add abort flag
This commit is contained in:
parent
232d2e8def
commit
644b551aff
@ -33,7 +33,7 @@ let s:source = {
|
|||||||
\ g:neocomplcache_auto_completion_start_length,
|
\ g:neocomplcache_auto_completion_start_length,
|
||||||
\}
|
\}
|
||||||
|
|
||||||
function! s:source.initialize() "{{{
|
function! s:source.initialize() abort "{{{
|
||||||
" Initialize.
|
" Initialize.
|
||||||
call neocomplcache#set_dictionary_helper(
|
call neocomplcache#set_dictionary_helper(
|
||||||
\ g:neocomplcache_source_rank, 'snippets_complete', 8)
|
\ g:neocomplcache_source_rank, 'snippets_complete', 8)
|
||||||
@ -41,7 +41,7 @@ function! s:source.initialize() "{{{
|
|||||||
\ g:neocomplcache_auto_completion_start_length)
|
\ g:neocomplcache_auto_completion_start_length)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:source.get_keyword_pos(cur_text) "{{{
|
function! s:source.get_keyword_pos(cur_text) abort "{{{
|
||||||
let cur_word = matchstr(a:cur_text, '\w\+$')
|
let cur_word = matchstr(a:cur_text, '\w\+$')
|
||||||
let word_candidates = neocomplcache#keyword_filter(
|
let word_candidates = neocomplcache#keyword_filter(
|
||||||
\ filter(values(neosnippet#helpers#get_snippets()),
|
\ filter(values(neosnippet#helpers#get_snippets()),
|
||||||
@ -53,7 +53,7 @@ function! s:source.get_keyword_pos(cur_text) "{{{
|
|||||||
return match(a:cur_text, '\S\+$')
|
return match(a:cur_text, '\S\+$')
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:source.get_complete_words(cur_keyword_pos, cur_keyword_str) "{{{
|
function! s:source.get_complete_words(cur_keyword_pos, cur_keyword_str) abort "{{{
|
||||||
let list = s:keyword_filter(neosnippet#helpers#get_snippets(), a:cur_keyword_str)
|
let list = s:keyword_filter(neosnippet#helpers#get_snippets(), a:cur_keyword_str)
|
||||||
|
|
||||||
for snippet in list
|
for snippet in list
|
||||||
@ -66,7 +66,7 @@ function! s:source.get_complete_words(cur_keyword_pos, cur_keyword_str) "{{{
|
|||||||
return list
|
return list
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:keyword_filter(snippets, cur_keyword_str) "{{{
|
function! s:keyword_filter(snippets, cur_keyword_str) abort "{{{
|
||||||
" Uniq by real_name.
|
" Uniq by real_name.
|
||||||
let dict = {}
|
let dict = {}
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ function! s:keyword_filter(snippets, cur_keyword_str) "{{{
|
|||||||
return values(dict)
|
return values(dict)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neocomplcache#sources#snippets_complete#define() "{{{
|
function! neocomplcache#sources#snippets_complete#define() abort "{{{
|
||||||
return s:source
|
return s:source
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ let s:source = {
|
|||||||
\ ['matcher_fuzzy'] : ['matcher_head']),
|
\ ['matcher_fuzzy'] : ['matcher_head']),
|
||||||
\}
|
\}
|
||||||
|
|
||||||
function! s:source.gather_candidates(context) "{{{
|
function! s:source.gather_candidates(context) abort "{{{
|
||||||
let snippets = values(neosnippet#helpers#get_completion_snippets())
|
let snippets = values(neosnippet#helpers#get_completion_snippets())
|
||||||
if matchstr(a:context.input, '\S\+$') !=#
|
if matchstr(a:context.input, '\S\+$') !=#
|
||||||
\ matchstr(a:context.input, '\w\+$')
|
\ matchstr(a:context.input, '\w\+$')
|
||||||
@ -47,7 +47,7 @@ function! s:source.gather_candidates(context) "{{{
|
|||||||
return snippets
|
return snippets
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:source.hooks.on_post_filter(context) "{{{
|
function! s:source.hooks.on_post_filter(context) abort "{{{
|
||||||
for snippet in a:context.candidates
|
for snippet in a:context.candidates
|
||||||
let snippet.dup = 1
|
let snippet.dup = 1
|
||||||
let snippet.menu = neosnippet#util#strwidthpart(
|
let snippet.menu = neosnippet#util#strwidthpart(
|
||||||
@ -57,7 +57,7 @@ function! s:source.hooks.on_post_filter(context) "{{{
|
|||||||
return a:context.candidates
|
return a:context.candidates
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neocomplete#sources#neosnippet#define() "{{{
|
function! neocomplete#sources#neosnippet#define() abort "{{{
|
||||||
return s:source
|
return s:source
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
|
@ -53,61 +53,61 @@ call neosnippet#util#set_default(
|
|||||||
\ {'_':{ '(' : ')', '{' : '}', '"' : '"', '[' : ']' }})
|
\ {'_':{ '(' : ')', '{' : '}', '"' : '"', '[' : ']' }})
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
function! neosnippet#expandable_or_jumpable() "{{{
|
function! neosnippet#expandable_or_jumpable() abort "{{{
|
||||||
return neosnippet#mappings#expandable_or_jumpable()
|
return neosnippet#mappings#expandable_or_jumpable()
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#expandable() "{{{
|
function! neosnippet#expandable() abort "{{{
|
||||||
return neosnippet#mappings#expandable()
|
return neosnippet#mappings#expandable()
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#jumpable() "{{{
|
function! neosnippet#jumpable() abort "{{{
|
||||||
return neosnippet#mappings#jumpable()
|
return neosnippet#mappings#jumpable()
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#anonymous(snippet) "{{{
|
function! neosnippet#anonymous(snippet) abort "{{{
|
||||||
return neosnippet#mappings#_anonymous(a:snippet)
|
return neosnippet#mappings#_anonymous(a:snippet)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#expand(trigger) "{{{
|
function! neosnippet#expand(trigger) abort "{{{
|
||||||
return neosnippet#mappings#_expand(a:trigger)
|
return neosnippet#mappings#_expand(a:trigger)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#get_snippets_directory() "{{{
|
function! neosnippet#get_snippets_directory() abort "{{{
|
||||||
return neosnippet#helpers#get_snippets_directory()
|
return neosnippet#helpers#get_snippets_directory()
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#get_user_snippets_directory() "{{{
|
function! neosnippet#get_user_snippets_directory() abort "{{{
|
||||||
return copy(neosnippet#variables#snippets_dir())
|
return copy(neosnippet#variables#snippets_dir())
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#get_runtime_snippets_directory() "{{{
|
function! neosnippet#get_runtime_snippets_directory() abort "{{{
|
||||||
return copy(neosnippet#variables#runtime_dir())
|
return copy(neosnippet#variables#runtime_dir())
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
" Get marker patterns.
|
" Get marker patterns.
|
||||||
function! neosnippet#get_placeholder_target_marker_pattern() "{{{
|
function! neosnippet#get_placeholder_target_marker_pattern() abort "{{{
|
||||||
return '\${\d\+:\(#:\)\?TARGET\%(:.\{-}\)\?\\\@<!}'
|
return '\${\d\+:\(#:\)\?TARGET\%(:.\{-}\)\?\\\@<!}'
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#get_placeholder_marker_pattern() "{{{
|
function! neosnippet#get_placeholder_marker_pattern() abort "{{{
|
||||||
return '<`\d\+\%(:.\{-}\)\?\\\@<!`>'
|
return '<`\d\+\%(:.\{-}\)\?\\\@<!`>'
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#get_placeholder_marker_substitute_pattern() "{{{
|
function! neosnippet#get_placeholder_marker_substitute_pattern() abort "{{{
|
||||||
return '\${\(\d\+\%(:.\{-}\)\?\\\@<!\)}'
|
return '\${\(\d\+\%(:.\{-}\)\?\\\@<!\)}'
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#get_placeholder_marker_substitute_nonzero_pattern() "{{{
|
function! neosnippet#get_placeholder_marker_substitute_nonzero_pattern() abort "{{{
|
||||||
return '\${\([1-9]\d*\%(:.\{-}\)\?\\\@<!\)}'
|
return '\${\([1-9]\d*\%(:.\{-}\)\?\\\@<!\)}'
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#get_placeholder_marker_substitute_zero_pattern() "{{{
|
function! neosnippet#get_placeholder_marker_substitute_zero_pattern() abort "{{{
|
||||||
return '\${\(0\%(:.\{-}\)\?\\\@<!\)}'
|
return '\${\(0\%(:.\{-}\)\?\\\@<!\)}'
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#get_placeholder_marker_default_pattern() "{{{
|
function! neosnippet#get_placeholder_marker_default_pattern() abort "{{{
|
||||||
return '<`\d\+:\zs.\{-}\ze\\\@<!`>'
|
return '<`\d\+:\zs.\{-}\ze\\\@<!`>'
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#get_sync_placeholder_marker_pattern() "{{{
|
function! neosnippet#get_sync_placeholder_marker_pattern() abort "{{{
|
||||||
return '<{\d\+\%(:.\{-}\)\?\\\@<!}>'
|
return '<{\d\+\%(:.\{-}\)\?\\\@<!}>'
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#get_sync_placeholder_marker_default_pattern() "{{{
|
function! neosnippet#get_sync_placeholder_marker_default_pattern() abort "{{{
|
||||||
return '<{\d\+:\zs.\{-}\ze\\\@<!}>'
|
return '<{\d\+:\zs.\{-}\ze\\\@<!}>'
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#get_mirror_placeholder_marker_pattern() "{{{
|
function! neosnippet#get_mirror_placeholder_marker_pattern() abort "{{{
|
||||||
return '<|\d\+|>'
|
return '<|\d\+|>'
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#get_mirror_placeholder_marker_substitute_pattern() "{{{
|
function! neosnippet#get_mirror_placeholder_marker_substitute_pattern() abort "{{{
|
||||||
return '\$\(\d\+\)'
|
return '\$\(\d\+\)'
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
|
@ -34,14 +34,14 @@ let s:edit_options = [
|
|||||||
let s:Cache = neosnippet#util#get_vital().import('System.Cache')
|
let s:Cache = neosnippet#util#get_vital().import('System.Cache')
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
function! s:get_list() "{{{
|
function! s:get_list() abort "{{{
|
||||||
if !exists('s:List')
|
if !exists('s:List')
|
||||||
let s:List = vital#of('neosnippet').import('Data.List')
|
let s:List = vital#of('neosnippet').import('Data.List')
|
||||||
endif
|
endif
|
||||||
return s:List
|
return s:List
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#commands#_edit(args) "{{{
|
function! neosnippet#commands#_edit(args) abort "{{{
|
||||||
if neosnippet#util#is_sudo()
|
if neosnippet#util#is_sudo()
|
||||||
call neosnippet#util#print_error(
|
call neosnippet#util#print_error(
|
||||||
\ '"sudo vim" is detected. This feature is disabled.')
|
\ '"sudo vim" is detected. This feature is disabled.')
|
||||||
@ -92,7 +92,7 @@ function! neosnippet#commands#_edit(args) "{{{
|
|||||||
endtry
|
endtry
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#commands#_make_cache(filetype) "{{{
|
function! neosnippet#commands#_make_cache(filetype) abort "{{{
|
||||||
call neosnippet#init#check()
|
call neosnippet#init#check()
|
||||||
|
|
||||||
let filetype = a:filetype == '' ?
|
let filetype = a:filetype == '' ?
|
||||||
@ -128,7 +128,7 @@ function! neosnippet#commands#_make_cache(filetype) "{{{
|
|||||||
endif
|
endif
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#commands#_source(filename) "{{{
|
function! neosnippet#commands#_source(filename) abort "{{{
|
||||||
call neosnippet#init#check()
|
call neosnippet#init#check()
|
||||||
|
|
||||||
let neosnippet = neosnippet#variables#current_neosnippet()
|
let neosnippet = neosnippet#variables#current_neosnippet()
|
||||||
@ -136,7 +136,7 @@ function! neosnippet#commands#_source(filename) "{{{
|
|||||||
\ neosnippet#parser#_parse_snippets(a:filename))
|
\ neosnippet#parser#_parse_snippets(a:filename))
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#commands#_clear_markers() "{{{
|
function! neosnippet#commands#_clear_markers() abort "{{{
|
||||||
let expand_stack = neosnippet#variables#expand_stack()
|
let expand_stack = neosnippet#variables#expand_stack()
|
||||||
|
|
||||||
" Get patterns and count.
|
" Get patterns and count.
|
||||||
@ -150,12 +150,12 @@ function! neosnippet#commands#_clear_markers() "{{{
|
|||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
" Complete helpers.
|
" Complete helpers.
|
||||||
function! neosnippet#commands#_edit_complete(arglead, cmdline, cursorpos) "{{{
|
function! neosnippet#commands#_edit_complete(arglead, cmdline, cursorpos) abort "{{{
|
||||||
return filter(s:edit_options +
|
return filter(s:edit_options +
|
||||||
\ neosnippet#commands#_filetype_complete(a:arglead, a:cmdline, a:cursorpos),
|
\ neosnippet#commands#_filetype_complete(a:arglead, a:cmdline, a:cursorpos),
|
||||||
\ 'stridx(v:val, a:arglead) == 0')
|
\ 'stridx(v:val, a:arglead) == 0')
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#commands#_filetype_complete(arglead, cmdline, cursorpos) "{{{
|
function! neosnippet#commands#_filetype_complete(arglead, cmdline, cursorpos) abort "{{{
|
||||||
" Dup check.
|
" Dup check.
|
||||||
let ret = {}
|
let ret = {}
|
||||||
for item in map(
|
for item in map(
|
||||||
@ -170,13 +170,13 @@ function! neosnippet#commands#_filetype_complete(arglead, cmdline, cursorpos) "{
|
|||||||
|
|
||||||
return sort(keys(ret))
|
return sort(keys(ret))
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#commands#_complete_target_snippets(arglead, cmdline, cursorpos) "{{{
|
function! neosnippet#commands#_complete_target_snippets(arglead, cmdline, cursorpos) abort "{{{
|
||||||
return map(filter(values(neosnippet#helpers#get_snippets()),
|
return map(filter(values(neosnippet#helpers#get_snippets()),
|
||||||
\ "stridx(v:val.word, a:arglead) == 0
|
\ "stridx(v:val.word, a:arglead) == 0
|
||||||
\ && v:val.snip =~# neosnippet#get_placeholder_target_marker_pattern()"), 'v:val.word')
|
\ && v:val.snip =~# neosnippet#get_placeholder_target_marker_pattern()"), 'v:val.word')
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:initialize_options(options) "{{{
|
function! s:initialize_options(options) abort "{{{
|
||||||
let default_options = {
|
let default_options = {
|
||||||
\ 'runtime' : 0,
|
\ 'runtime' : 0,
|
||||||
\ 'vertical' : 0,
|
\ 'vertical' : 0,
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
let s:save_cpo = &cpo
|
let s:save_cpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
function! neosnippet#handlers#_complete_done() "{{{
|
function! neosnippet#handlers#_complete_done() abort "{{{
|
||||||
if empty(v:completed_item)
|
if empty(v:completed_item)
|
||||||
\ || !g:neosnippet#enable_completed_snippet
|
\ || !g:neosnippet#enable_completed_snippet
|
||||||
\ || s:is_auto_pairs()
|
\ || s:is_auto_pairs()
|
||||||
@ -43,7 +43,7 @@ function! neosnippet#handlers#_complete_done() "{{{
|
|||||||
call neosnippet#view#_insert(snippet, {}, cur_text, col)
|
call neosnippet#view#_insert(snippet, {}, cur_text, col)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#handlers#_cursor_moved() "{{{
|
function! neosnippet#handlers#_cursor_moved() abort "{{{
|
||||||
let expand_stack = neosnippet#variables#expand_stack()
|
let expand_stack = neosnippet#variables#expand_stack()
|
||||||
|
|
||||||
" Get patterns and count.
|
" Get patterns and count.
|
||||||
@ -59,7 +59,7 @@ function! neosnippet#handlers#_cursor_moved() "{{{
|
|||||||
endif
|
endif
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#handlers#_all_clear_markers() "{{{
|
function! neosnippet#handlers#_all_clear_markers() abort "{{{
|
||||||
let pos = getpos('.')
|
let pos = getpos('.')
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -74,7 +74,7 @@ function! neosnippet#handlers#_all_clear_markers() "{{{
|
|||||||
endtry
|
endtry
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#handlers#_restore_unnamed_register() "{{{
|
function! neosnippet#handlers#_restore_unnamed_register() abort "{{{
|
||||||
let neosnippet = neosnippet#variables#current_neosnippet()
|
let neosnippet = neosnippet#variables#current_neosnippet()
|
||||||
|
|
||||||
if neosnippet.unnamed_register != ''
|
if neosnippet.unnamed_register != ''
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
let s:save_cpo = &cpo
|
let s:save_cpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
function! neosnippet#helpers#get_cursor_snippet(snippets, cur_text) "{{{
|
function! neosnippet#helpers#get_cursor_snippet(snippets, cur_text) abort "{{{
|
||||||
let cur_word = matchstr(a:cur_text, '\S\+$')
|
let cur_word = matchstr(a:cur_text, '\S\+$')
|
||||||
if cur_word != '' && has_key(a:snippets, cur_word)
|
if cur_word != '' && has_key(a:snippets, cur_word)
|
||||||
return cur_word
|
return cur_word
|
||||||
@ -44,7 +44,7 @@ function! neosnippet#helpers#get_cursor_snippet(snippets, cur_text) "{{{
|
|||||||
return cur_word
|
return cur_word
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#helpers#get_snippets() "{{{
|
function! neosnippet#helpers#get_snippets() abort "{{{
|
||||||
call neosnippet#init#check()
|
call neosnippet#init#check()
|
||||||
|
|
||||||
let neosnippet = neosnippet#variables#current_neosnippet()
|
let neosnippet = neosnippet#variables#current_neosnippet()
|
||||||
@ -72,12 +72,12 @@ function! neosnippet#helpers#get_snippets() "{{{
|
|||||||
|
|
||||||
return snippets
|
return snippets
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#helpers#get_completion_snippets() "{{{
|
function! neosnippet#helpers#get_completion_snippets() abort "{{{
|
||||||
return filter(neosnippet#helpers#get_snippets(),
|
return filter(neosnippet#helpers#get_snippets(),
|
||||||
\ "!get(v:val.options, 'oneshot', 0)")
|
\ "!get(v:val.options, 'oneshot', 0)")
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#helpers#get_snippets_directory() "{{{
|
function! neosnippet#helpers#get_snippets_directory() abort "{{{
|
||||||
let snippets_dir = copy(neosnippet#variables#snippets_dir())
|
let snippets_dir = copy(neosnippet#variables#snippets_dir())
|
||||||
if !get(g:neosnippet#disable_runtime_snippets,
|
if !get(g:neosnippet#disable_runtime_snippets,
|
||||||
\ neosnippet#helpers#get_filetype(),
|
\ neosnippet#helpers#get_filetype(),
|
||||||
@ -88,7 +88,7 @@ function! neosnippet#helpers#get_snippets_directory() "{{{
|
|||||||
return snippets_dir
|
return snippets_dir
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#helpers#get_filetype() "{{{
|
function! neosnippet#helpers#get_filetype() abort "{{{
|
||||||
if !exists('s:exists_context_filetype')
|
if !exists('s:exists_context_filetype')
|
||||||
" context_filetype.vim installation check.
|
" context_filetype.vim installation check.
|
||||||
try
|
try
|
||||||
@ -109,7 +109,7 @@ function! neosnippet#helpers#get_filetype() "{{{
|
|||||||
return context_filetype
|
return context_filetype
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#helpers#get_selected_text(type, ...) "{{{
|
function! neosnippet#helpers#get_selected_text(type, ...) abort "{{{
|
||||||
let sel_save = &selection
|
let sel_save = &selection
|
||||||
let &selection = 'inclusive'
|
let &selection = 'inclusive'
|
||||||
let reg_save = @@
|
let reg_save = @@
|
||||||
@ -134,7 +134,7 @@ function! neosnippet#helpers#get_selected_text(type, ...) "{{{
|
|||||||
call setpos('.', pos)
|
call setpos('.', pos)
|
||||||
endtry
|
endtry
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#helpers#delete_selected_text(type, ...) "{{{
|
function! neosnippet#helpers#delete_selected_text(type, ...) abort "{{{
|
||||||
let sel_save = &selection
|
let sel_save = &selection
|
||||||
let &selection = 'inclusive'
|
let &selection = 'inclusive'
|
||||||
let reg_save = @@
|
let reg_save = @@
|
||||||
@ -157,7 +157,7 @@ function! neosnippet#helpers#delete_selected_text(type, ...) "{{{
|
|||||||
call setpos('.', pos)
|
call setpos('.', pos)
|
||||||
endtry
|
endtry
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#helpers#substitute_selected_text(type, text) "{{{
|
function! neosnippet#helpers#substitute_selected_text(type, text) abort "{{{
|
||||||
let sel_save = &selection
|
let sel_save = &selection
|
||||||
let &selection = 'inclusive'
|
let &selection = 'inclusive'
|
||||||
let reg_save = @@
|
let reg_save = @@
|
||||||
@ -181,7 +181,7 @@ function! neosnippet#helpers#substitute_selected_text(type, text) "{{{
|
|||||||
endtry
|
endtry
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:is_beginning_of_line(cur_text) "{{{
|
function! s:is_beginning_of_line(cur_text) abort "{{{
|
||||||
let keyword_pattern = '\S\+'
|
let keyword_pattern = '\S\+'
|
||||||
let cur_keyword_str = matchstr(a:cur_text, keyword_pattern.'$')
|
let cur_keyword_str = matchstr(a:cur_text, keyword_pattern.'$')
|
||||||
let line_part = a:cur_text[: -1-len(cur_keyword_str)]
|
let line_part = a:cur_text[: -1-len(cur_keyword_str)]
|
||||||
@ -190,7 +190,7 @@ function! s:is_beginning_of_line(cur_text) "{{{
|
|||||||
return prev_word_end <= 0
|
return prev_word_end <= 0
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:get_sources_filetypes(filetype) "{{{
|
function! s:get_sources_filetypes(filetype) abort "{{{
|
||||||
let filetypes =
|
let filetypes =
|
||||||
\ exists('*context_filetype#get_filetypes') ?
|
\ exists('*context_filetype#get_filetypes') ?
|
||||||
\ context_filetype#get_filetypes(a:filetype) :
|
\ context_filetype#get_filetypes(a:filetype) :
|
||||||
|
@ -26,27 +26,27 @@
|
|||||||
let s:save_cpo = &cpo
|
let s:save_cpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
function! neosnippet#init#_initialize() "{{{
|
function! neosnippet#init#_initialize() abort "{{{
|
||||||
let s:is_initialized = 1
|
let s:is_initialized = 1
|
||||||
|
|
||||||
call s:initialize_others()
|
call s:initialize_others()
|
||||||
call s:initialize_cache()
|
call s:initialize_cache()
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#init#check() "{{{
|
function! neosnippet#init#check() abort "{{{
|
||||||
if !exists('s:is_initialized')
|
if !exists('s:is_initialized')
|
||||||
call neosnippet#init#_initialize()
|
call neosnippet#init#_initialize()
|
||||||
endif
|
endif
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:initialize_cache() "{{{
|
function! s:initialize_cache() abort "{{{
|
||||||
" Make cache for _ snippets.
|
" Make cache for _ snippets.
|
||||||
call neosnippet#commands#_make_cache('_')
|
call neosnippet#commands#_make_cache('_')
|
||||||
|
|
||||||
" Initialize check.
|
" Initialize check.
|
||||||
call neosnippet#commands#_make_cache(&filetype)
|
call neosnippet#commands#_make_cache(&filetype)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! s:initialize_others() "{{{
|
function! s:initialize_others() abort "{{{
|
||||||
augroup neosnippet "{{{
|
augroup neosnippet "{{{
|
||||||
autocmd!
|
autocmd!
|
||||||
" Set make cache event.
|
" Set make cache event.
|
||||||
@ -98,7 +98,7 @@ function! s:initialize_others() "{{{
|
|||||||
|
|
||||||
if g:neosnippet#enable_snipmate_compatibility "{{{
|
if g:neosnippet#enable_snipmate_compatibility "{{{
|
||||||
" For snipMate function.
|
" For snipMate function.
|
||||||
function! Filename(...)
|
function! Filename(...) abort
|
||||||
let filename = expand('%:t:r')
|
let filename = expand('%:t:r')
|
||||||
if filename == ''
|
if filename == ''
|
||||||
return a:0 == 2 ? a:2 : ''
|
return a:0 == 2 ? a:2 : ''
|
||||||
|
@ -26,21 +26,21 @@
|
|||||||
let s:save_cpo = &cpo
|
let s:save_cpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
function! neosnippet#mappings#expandable_or_jumpable() "{{{
|
function! neosnippet#mappings#expandable_or_jumpable() abort "{{{
|
||||||
return neosnippet#mappings#expandable() || neosnippet#mappings#jumpable()
|
return neosnippet#mappings#expandable() || neosnippet#mappings#jumpable()
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#mappings#expandable() "{{{
|
function! neosnippet#mappings#expandable() abort "{{{
|
||||||
" Check snippet trigger.
|
" Check snippet trigger.
|
||||||
return neosnippet#helpers#get_cursor_snippet(
|
return neosnippet#helpers#get_cursor_snippet(
|
||||||
\ neosnippet#helpers#get_snippets(), neosnippet#util#get_cur_text()) != ''
|
\ neosnippet#helpers#get_snippets(), neosnippet#util#get_cur_text()) != ''
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#mappings#jumpable() "{{{
|
function! neosnippet#mappings#jumpable() abort "{{{
|
||||||
" Found snippet placeholder.
|
" Found snippet placeholder.
|
||||||
return search(neosnippet#get_placeholder_marker_pattern(). '\|'
|
return search(neosnippet#get_placeholder_marker_pattern(). '\|'
|
||||||
\ .neosnippet#get_sync_placeholder_marker_pattern(), 'nw') > 0
|
\ .neosnippet#get_sync_placeholder_marker_pattern(), 'nw') > 0
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#mappings#_clear_select_mode_mappings() "{{{
|
function! neosnippet#mappings#_clear_select_mode_mappings() abort "{{{
|
||||||
if !g:neosnippet#disable_select_mode_mappings
|
if !g:neosnippet#disable_select_mode_mappings
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@ -64,7 +64,7 @@ function! neosnippet#mappings#_clear_select_mode_mappings() "{{{
|
|||||||
snoremap <ESC> <BS><ESC>
|
snoremap <ESC> <BS><ESC>
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#mappings#_register_oneshot_snippet() "{{{
|
function! neosnippet#mappings#_register_oneshot_snippet() abort "{{{
|
||||||
let trigger = input('Please input snippet trigger: ', 'oneshot')
|
let trigger = input('Please input snippet trigger: ', 'oneshot')
|
||||||
if trigger == ''
|
if trigger == ''
|
||||||
return
|
return
|
||||||
@ -92,7 +92,7 @@ function! neosnippet#mappings#_register_oneshot_snippet() "{{{
|
|||||||
echo 'Registered trigger : ' . trigger
|
echo 'Registered trigger : ' . trigger
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#mappings#_expand_target() "{{{
|
function! neosnippet#mappings#_expand_target() abort "{{{
|
||||||
let trigger = input('Please input snippet trigger: ',
|
let trigger = input('Please input snippet trigger: ',
|
||||||
\ '', 'customlist,neosnippet#commands#_complete_target_snippets')
|
\ '', 'customlist,neosnippet#commands#_complete_target_snippets')
|
||||||
let neosnippet = neosnippet#variables#current_neosnippet()
|
let neosnippet = neosnippet#variables#current_neosnippet()
|
||||||
@ -109,7 +109,7 @@ function! neosnippet#mappings#_expand_target() "{{{
|
|||||||
|
|
||||||
call neosnippet#mappings#_expand_target_trigger(trigger)
|
call neosnippet#mappings#_expand_target_trigger(trigger)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#mappings#_expand_target_trigger(trigger) "{{{
|
function! neosnippet#mappings#_expand_target_trigger(trigger) abort "{{{
|
||||||
let neosnippet = neosnippet#variables#current_neosnippet()
|
let neosnippet = neosnippet#variables#current_neosnippet()
|
||||||
let neosnippet.target = substitute(
|
let neosnippet.target = substitute(
|
||||||
\ neosnippet#helpers#get_selected_text(visualmode(), 1), '\n$', '', '')
|
\ neosnippet#helpers#get_selected_text(visualmode(), 1), '\n$', '', '')
|
||||||
@ -136,14 +136,14 @@ function! neosnippet#mappings#_expand_target_trigger(trigger) "{{{
|
|||||||
endif
|
endif
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#mappings#_anonymous(snippet) "{{{
|
function! neosnippet#mappings#_anonymous(snippet) abort "{{{
|
||||||
let [cur_text, col, expr] = neosnippet#mappings#_pre_trigger()
|
let [cur_text, col, expr] = neosnippet#mappings#_pre_trigger()
|
||||||
let expr .= printf("\<ESC>:call neosnippet#view#_insert(%s, {}, %s, %d)\<CR>",
|
let expr .= printf("\<ESC>:call neosnippet#view#_insert(%s, {}, %s, %d)\<CR>",
|
||||||
\ string(a:snippet), string(cur_text), col)
|
\ string(a:snippet), string(cur_text), col)
|
||||||
|
|
||||||
return expr
|
return expr
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#mappings#_expand(trigger) "{{{
|
function! neosnippet#mappings#_expand(trigger) abort "{{{
|
||||||
let [cur_text, col, expr] = neosnippet#mappings#_pre_trigger()
|
let [cur_text, col, expr] = neosnippet#mappings#_pre_trigger()
|
||||||
|
|
||||||
let expr .= printf("\<ESC>:call neosnippet#view#_expand(%s, %d, %s)\<CR>",
|
let expr .= printf("\<ESC>:call neosnippet#view#_expand(%s, %d, %s)\<CR>",
|
||||||
@ -152,7 +152,7 @@ function! neosnippet#mappings#_expand(trigger) "{{{
|
|||||||
return expr
|
return expr
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:snippets_expand(cur_text, col) "{{{
|
function! s:snippets_expand(cur_text, col) abort "{{{
|
||||||
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)
|
||||||
@ -161,7 +161,7 @@ function! s:snippets_expand(cur_text, col) "{{{
|
|||||||
\ neosnippet#util#get_cur_text(), a:col, cur_word)
|
\ neosnippet#util#get_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) abort "{{{
|
||||||
let cur_word = neosnippet#helpers#get_cursor_snippet(
|
let cur_word = neosnippet#helpers#get_cursor_snippet(
|
||||||
\ neosnippet#helpers#get_snippets(), a:cur_text)
|
\ neosnippet#helpers#get_snippets(), a:cur_text)
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ function! s:snippets_expand_or_jump(cur_text, col) "{{{
|
|||||||
endif
|
endif
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:snippets_jump_or_expand(cur_text, col) "{{{
|
function! s:snippets_jump_or_expand(cur_text, col) abort "{{{
|
||||||
let cur_word = neosnippet#helpers#get_cursor_snippet(
|
let cur_word = neosnippet#helpers#get_cursor_snippet(
|
||||||
\ neosnippet#helpers#get_snippets(), a:cur_text)
|
\ neosnippet#helpers#get_snippets(), a:cur_text)
|
||||||
if search(neosnippet#get_placeholder_marker_pattern(). '\|'
|
if search(neosnippet#get_placeholder_marker_pattern(). '\|'
|
||||||
@ -187,11 +187,11 @@ function! s:snippets_jump_or_expand(cur_text, col) "{{{
|
|||||||
endif
|
endif
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:SID_PREFIX() "{{{
|
function! s:SID_PREFIX() abort "{{{
|
||||||
return matchstr(expand('<sfile>'), '<SNR>\d\+_\ze\w\+$')
|
return matchstr(expand('<sfile>'), '<SNR>\d\+_\ze\w\+$')
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#mappings#_trigger(function) "{{{
|
function! neosnippet#mappings#_trigger(function) abort "{{{
|
||||||
let [cur_text, col, expr] = neosnippet#mappings#_pre_trigger()
|
let [cur_text, col, expr] = neosnippet#mappings#_pre_trigger()
|
||||||
|
|
||||||
let expr .= printf("\<ESC>:call %s(%s,%d)\<CR>",
|
let expr .= printf("\<ESC>:call %s(%s,%d)\<CR>",
|
||||||
@ -200,7 +200,7 @@ function! neosnippet#mappings#_trigger(function) "{{{
|
|||||||
return expr
|
return expr
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#mappings#_pre_trigger() "{{{
|
function! neosnippet#mappings#_pre_trigger() abort "{{{
|
||||||
call neosnippet#init#check()
|
call neosnippet#init#check()
|
||||||
|
|
||||||
let cur_text = neosnippet#util#get_cur_text()
|
let cur_text = neosnippet#util#get_cur_text()
|
||||||
@ -223,22 +223,22 @@ function! neosnippet#mappings#_pre_trigger() "{{{
|
|||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
" Plugin key-mappings.
|
" Plugin key-mappings.
|
||||||
function! neosnippet#mappings#expand_or_jump_impl()
|
function! neosnippet#mappings#expand_or_jump_impl() abort
|
||||||
return mode() ==# 's' ?
|
return mode() ==# 's' ?
|
||||||
\ neosnippet#mappings#_trigger('neosnippet#view#_jump') :
|
\ neosnippet#mappings#_trigger('neosnippet#view#_jump') :
|
||||||
\ neosnippet#mappings#_trigger(
|
\ neosnippet#mappings#_trigger(
|
||||||
\ s:SID_PREFIX().'snippets_expand_or_jump')
|
\ s:SID_PREFIX().'snippets_expand_or_jump')
|
||||||
endfunction
|
endfunction
|
||||||
function! neosnippet#mappings#jump_or_expand_impl()
|
function! neosnippet#mappings#jump_or_expand_impl() abort
|
||||||
return mode() ==# 's' ?
|
return mode() ==# 's' ?
|
||||||
\ neosnippet#mappings#_trigger('neosnippet#view#_jump') :
|
\ neosnippet#mappings#_trigger('neosnippet#view#_jump') :
|
||||||
\ neosnippet#mappings#_trigger(
|
\ neosnippet#mappings#_trigger(
|
||||||
\ s:SID_PREFIX().'snippets_jump_or_expand')
|
\ s:SID_PREFIX().'snippets_jump_or_expand')
|
||||||
endfunction
|
endfunction
|
||||||
function! neosnippet#mappings#expand_impl()
|
function! neosnippet#mappings#expand_impl() abort
|
||||||
return neosnippet#mappings#_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() abort
|
||||||
return neosnippet#mappings#_trigger('neosnippet#view#_jump')
|
return neosnippet#mappings#_trigger('neosnippet#view#_jump')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ set cpo&vim
|
|||||||
|
|
||||||
let s:Cache = neosnippet#util#get_vital().import('System.Cache')
|
let s:Cache = neosnippet#util#get_vital().import('System.Cache')
|
||||||
|
|
||||||
function! neosnippet#parser#_parse_snippets(filename) "{{{
|
function! neosnippet#parser#_parse_snippets(filename) abort "{{{
|
||||||
if !filereadable(a:filename)
|
if !filereadable(a:filename)
|
||||||
call neosnippet#util#print_error(
|
call neosnippet#util#print_error(
|
||||||
\ printf('snippet file "%s" is not found.', a:filename))
|
\ printf('snippet file "%s" is not found.', a:filename))
|
||||||
@ -49,7 +49,7 @@ function! neosnippet#parser#_parse_snippets(filename) "{{{
|
|||||||
|
|
||||||
return snippets
|
return snippets
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#parser#_parse_snippet(filename, trigger) "{{{
|
function! neosnippet#parser#_parse_snippet(filename, trigger) abort "{{{
|
||||||
if !filereadable(a:filename)
|
if !filereadable(a:filename)
|
||||||
call neosnippet#util#print_error(
|
call neosnippet#util#print_error(
|
||||||
\ printf('snippet file "%s" is not found.', a:filename))
|
\ printf('snippet file "%s" is not found.', a:filename))
|
||||||
@ -66,7 +66,7 @@ function! neosnippet#parser#_parse_snippet(filename, trigger) "{{{
|
|||||||
\ snippet_dict, a:filename, 1, '', a:trigger)
|
\ snippet_dict, a:filename, 1, '', a:trigger)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:parse(snippets_file) "{{{
|
function! s:parse(snippets_file) abort "{{{
|
||||||
let dup_check = {}
|
let dup_check = {}
|
||||||
let snippet_dict = {}
|
let snippet_dict = {}
|
||||||
let linenr = 1
|
let linenr = 1
|
||||||
@ -138,7 +138,7 @@ function! s:parse(snippets_file) "{{{
|
|||||||
return [snippets, sourced]
|
return [snippets, sourced]
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:parse_snippet_name(snippets_file, line, linenr, dup_check) "{{{
|
function! s:parse_snippet_name(snippets_file, line, linenr, dup_check) abort "{{{
|
||||||
" Initialize snippet dict.
|
" Initialize snippet dict.
|
||||||
let snippet_dict = {
|
let snippet_dict = {
|
||||||
\ 'word' : '',
|
\ 'word' : '',
|
||||||
@ -180,7 +180,7 @@ function! s:parse_snippet_name(snippets_file, line, linenr, dup_check) "{{{
|
|||||||
return snippet_dict
|
return snippet_dict
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:add_snippet_attribute(snippets_file, line, linenr, snippet_dict) "{{{
|
function! s:add_snippet_attribute(snippets_file, line, linenr, snippet_dict) abort "{{{
|
||||||
" Allow overriding/setting of the description (abbr) of the snippet.
|
" Allow overriding/setting of the description (abbr) of the snippet.
|
||||||
" This will override what was set via the snippet line.
|
" This will override what was set via the snippet line.
|
||||||
if a:line =~ '^abbr\s'
|
if a:line =~ '^abbr\s'
|
||||||
@ -221,7 +221,7 @@ function! s:add_snippet_attribute(snippets_file, line, linenr, snippet_dict) "{{
|
|||||||
endif
|
endif
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:set_snippet_dict(snippet_dict, snippets, dup_check, snippets_file) "{{{
|
function! s:set_snippet_dict(snippet_dict, snippets, dup_check, snippets_file) abort "{{{
|
||||||
if empty(a:snippet_dict)
|
if empty(a:snippet_dict)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@ -243,7 +243,7 @@ function! s:set_snippet_dict(snippet_dict, snippets, dup_check, snippets_file) "
|
|||||||
endfor
|
endfor
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#parser#_initialize_snippet(dict, path, line, pattern, name) "{{{
|
function! neosnippet#parser#_initialize_snippet(dict, path, line, pattern, name) abort "{{{
|
||||||
let a:dict.word = substitute(a:dict.word, '\n\+$', '', '')
|
let a:dict.word = substitute(a:dict.word, '\n\+$', '', '')
|
||||||
if a:dict.word !~ '\n'
|
if a:dict.word !~ '\n'
|
||||||
\ && a:dict.word !~
|
\ && a:dict.word !~
|
||||||
@ -282,7 +282,7 @@ function! neosnippet#parser#_initialize_snippet(dict, path, line, pattern, name)
|
|||||||
return snippet
|
return snippet
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#parser#_initialize_snippet_options() "{{{
|
function! neosnippet#parser#_initialize_snippet_options() abort "{{{
|
||||||
return {
|
return {
|
||||||
\ 'head' : 0,
|
\ 'head' : 0,
|
||||||
\ 'word' :
|
\ 'word' :
|
||||||
@ -292,7 +292,7 @@ function! neosnippet#parser#_initialize_snippet_options() "{{{
|
|||||||
\ }
|
\ }
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#parser#_get_completed_snippet(completed_item, next_text) "{{{
|
function! neosnippet#parser#_get_completed_snippet(completed_item, next_text) abort "{{{
|
||||||
let item = a:completed_item
|
let item = a:completed_item
|
||||||
|
|
||||||
" Set abbr
|
" Set abbr
|
||||||
|
@ -27,70 +27,70 @@ let s:save_cpo = &cpo
|
|||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
let s:V = vital#of('neosnippet')
|
let s:V = vital#of('neosnippet')
|
||||||
function! neosnippet#util#get_vital() "{{{
|
function! neosnippet#util#get_vital() abort "{{{
|
||||||
return s:V
|
return s:V
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! s:get_prelude() "{{{
|
function! s:get_prelude() abort "{{{
|
||||||
if !exists('s:Prelude')
|
if !exists('s:Prelude')
|
||||||
let s:Prelude = neosnippet#util#get_vital().import('Prelude')
|
let s:Prelude = neosnippet#util#get_vital().import('Prelude')
|
||||||
endif
|
endif
|
||||||
return s:Prelude
|
return s:Prelude
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! s:get_list() "{{{
|
function! s:get_list() abort "{{{
|
||||||
if !exists('s:List')
|
if !exists('s:List')
|
||||||
let s:List = neosnippet#util#get_vital().import('Data.List')
|
let s:List = neosnippet#util#get_vital().import('Data.List')
|
||||||
endif
|
endif
|
||||||
return s:List
|
return s:List
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! s:get_string() "{{{
|
function! s:get_string() abort "{{{
|
||||||
if !exists('s:String')
|
if !exists('s:String')
|
||||||
let s:String = neosnippet#util#get_vital().import('Data.String')
|
let s:String = neosnippet#util#get_vital().import('Data.String')
|
||||||
endif
|
endif
|
||||||
return s:String
|
return s:String
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! s:get_process() "{{{
|
function! s:get_process() abort "{{{
|
||||||
if !exists('s:Process')
|
if !exists('s:Process')
|
||||||
let s:Process = neosnippet#util#get_vital().import('Process')
|
let s:Process = neosnippet#util#get_vital().import('Process')
|
||||||
endif
|
endif
|
||||||
return s:Process
|
return s:Process
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#util#substitute_path_separator(...) "{{{
|
function! neosnippet#util#substitute_path_separator(...) abort "{{{
|
||||||
return call(s:get_prelude().substitute_path_separator, a:000)
|
return call(s:get_prelude().substitute_path_separator, a:000)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#util#system(...) "{{{
|
function! neosnippet#util#system(...) abort "{{{
|
||||||
return call(s:get_process().system, a:000)
|
return call(s:get_process().system, a:000)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#util#has_vimproc(...) "{{{
|
function! neosnippet#util#has_vimproc(...) abort "{{{
|
||||||
return call(s:get_process().has_vimproc, a:000)
|
return call(s:get_process().has_vimproc, a:000)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#util#is_windows(...) "{{{
|
function! neosnippet#util#is_windows(...) abort "{{{
|
||||||
return call(s:get_prelude().is_windows, a:000)
|
return call(s:get_prelude().is_windows, a:000)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#util#is_mac(...) "{{{
|
function! neosnippet#util#is_mac(...) abort "{{{
|
||||||
return call(s:get_prelude().is_mac, a:000)
|
return call(s:get_prelude().is_mac, a:000)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#util#get_last_status(...) "{{{
|
function! neosnippet#util#get_last_status(...) abort "{{{
|
||||||
return call(s:get_process().get_last_status, a:000)
|
return call(s:get_process().get_last_status, a:000)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#util#escape_pattern(...) "{{{
|
function! neosnippet#util#escape_pattern(...) abort "{{{
|
||||||
return call(s:get_prelude().escape_pattern, a:000)
|
return call(s:get_prelude().escape_pattern, a:000)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#util#iconv(...) "{{{
|
function! neosnippet#util#iconv(...) abort "{{{
|
||||||
return call(s:get_process().iconv, a:000)
|
return call(s:get_process().iconv, a:000)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#util#truncate(...) "{{{
|
function! neosnippet#util#truncate(...) abort "{{{
|
||||||
return call(s:get_string().truncate, a:000)
|
return call(s:get_string().truncate, a:000)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#util#strwidthpart(...) "{{{
|
function! neosnippet#util#strwidthpart(...) abort "{{{
|
||||||
return call(s:get_string().strwidthpart, a:000)
|
return call(s:get_string().strwidthpart, a:000)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#util#expand(path) "{{{
|
function! neosnippet#util#expand(path) abort "{{{
|
||||||
return neosnippet#util#substitute_path_separator(
|
return neosnippet#util#substitute_path_separator(
|
||||||
\ expand(escape(a:path, '*?[]"={}'), 1))
|
\ expand(escape(a:path, '*?[]"={}'), 1))
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#util#set_default(var, val, ...) "{{{
|
function! neosnippet#util#set_default(var, val, ...) abort "{{{
|
||||||
let old_var = get(a:000, 0, '')
|
let old_var = get(a:000, 0, '')
|
||||||
if exists(old_var)
|
if exists(old_var)
|
||||||
let {a:var} = {old_var}
|
let {a:var} = {old_var}
|
||||||
@ -98,25 +98,25 @@ function! neosnippet#util#set_default(var, val, ...) "{{{
|
|||||||
let {a:var} = a:val
|
let {a:var} = a:val
|
||||||
endif
|
endif
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#util#set_dictionary_helper(...) "{{{
|
function! neosnippet#util#set_dictionary_helper(...) abort "{{{
|
||||||
return call(s:get_prelude().set_dictionary_helper, a:000)
|
return call(s:get_prelude().set_dictionary_helper, a:000)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#util#get_cur_text() "{{{
|
function! neosnippet#util#get_cur_text() abort "{{{
|
||||||
return
|
return
|
||||||
\ (mode() ==# 'i' ? (col('.')-1) : col('.')) >= len(getline('.')) ?
|
\ (mode() ==# 'i' ? (col('.')-1) : col('.')) >= len(getline('.')) ?
|
||||||
\ getline('.') :
|
\ getline('.') :
|
||||||
\ matchstr(getline('.'),
|
\ matchstr(getline('.'),
|
||||||
\ '^.*\%' . col('.') . 'c' . (mode() ==# 'i' ? '' : '.'))
|
\ '^.*\%' . col('.') . 'c' . (mode() ==# 'i' ? '' : '.'))
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#util#get_next_text() "{{{
|
function! neosnippet#util#get_next_text() abort "{{{
|
||||||
return getline('.')[len(neosnippet#util#get_cur_text()) :]
|
return getline('.')[len(neosnippet#util#get_cur_text()) :]
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#util#print_error(string) "{{{
|
function! neosnippet#util#print_error(string) abort "{{{
|
||||||
echohl Error | echomsg '[neosnippet] ' . a:string | echohl None
|
echohl Error | echomsg '[neosnippet] ' . a:string | echohl None
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#util#parse_options(args, options_list) "{{{
|
function! neosnippet#util#parse_options(args, options_list) abort "{{{
|
||||||
let args = []
|
let args = []
|
||||||
let options = {}
|
let options = {}
|
||||||
for arg in split(a:args, '\%(\\\@<!\s\)\+')
|
for arg in split(a:args, '\%(\\\@<!\s\)\+')
|
||||||
@ -154,13 +154,13 @@ function! neosnippet#util#get_buffer_config(
|
|||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
" Sudo check.
|
" Sudo check.
|
||||||
function! neosnippet#util#is_sudo() "{{{
|
function! neosnippet#util#is_sudo() abort "{{{
|
||||||
return $SUDO_USER != '' && $USER !=# $SUDO_USER
|
return $SUDO_USER != '' && $USER !=# $SUDO_USER
|
||||||
\ && $HOME !=# expand('~'.$USER)
|
\ && $HOME !=# expand('~'.$USER)
|
||||||
\ && $HOME ==# expand('~'.$SUDO_USER)
|
\ && $HOME ==# expand('~'.$SUDO_USER)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#util#option2list(str) "{{{
|
function! neosnippet#util#option2list(str) abort "{{{
|
||||||
return type(a:str) == type('') ? split(a:str, '\s*,\s*') : a:str
|
return type(a:str) == type('') ? split(a:str, '\s*,\s*') : a:str
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
let s:save_cpo = &cpo
|
let s:save_cpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
function! neosnippet#variables#current_neosnippet() "{{{
|
function! neosnippet#variables#current_neosnippet() abort "{{{
|
||||||
if !exists('b:neosnippet')
|
if !exists('b:neosnippet')
|
||||||
let b:neosnippet = {
|
let b:neosnippet = {
|
||||||
\ 'snippets' : {},
|
\ 'snippets' : {},
|
||||||
@ -40,34 +40,34 @@ function! neosnippet#variables#current_neosnippet() "{{{
|
|||||||
|
|
||||||
return b:neosnippet
|
return b:neosnippet
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#variables#expand_stack() "{{{
|
function! neosnippet#variables#expand_stack() abort "{{{
|
||||||
if !exists('s:expand_stack')
|
if !exists('s:expand_stack')
|
||||||
let s:expand_stack = []
|
let s:expand_stack = []
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return s:expand_stack
|
return s:expand_stack
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#variables#pop_expand_stack() "{{{
|
function! neosnippet#variables#pop_expand_stack() abort "{{{
|
||||||
let s:expand_stack = s:expand_stack[: -2]
|
let s:expand_stack = s:expand_stack[: -2]
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#variables#clear_expand_stack() "{{{
|
function! neosnippet#variables#clear_expand_stack() abort "{{{
|
||||||
let s:expand_stack = []
|
let s:expand_stack = []
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#variables#snippets() "{{{
|
function! neosnippet#variables#snippets() abort "{{{
|
||||||
if !exists('s:snippets')
|
if !exists('s:snippets')
|
||||||
let s:snippets= {}
|
let s:snippets= {}
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return s:snippets
|
return s:snippets
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#variables#set_snippets(list) "{{{
|
function! neosnippet#variables#set_snippets(list) abort "{{{
|
||||||
if !exists('s:snippets')
|
if !exists('s:snippets')
|
||||||
let s:snippets= {}
|
let s:snippets= {}
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let s:snippets = a:list
|
let s:snippets = a:list
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#variables#snippets_dir() "{{{
|
function! neosnippet#variables#snippets_dir() abort "{{{
|
||||||
" Set snippets_dir.
|
" Set snippets_dir.
|
||||||
let snippets_dir = []
|
let snippets_dir = []
|
||||||
for dir in neosnippet#util#option2list(g:neosnippet#snippets_directory)
|
for dir in neosnippet#util#option2list(g:neosnippet#snippets_directory)
|
||||||
@ -80,7 +80,7 @@ function! neosnippet#variables#snippets_dir() "{{{
|
|||||||
|
|
||||||
return map(snippets_dir, 'substitute(v:val, "[\\\\/]$", "", "")')
|
return map(snippets_dir, 'substitute(v:val, "[\\\\/]$", "", "")')
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#variables#runtime_dir() "{{{
|
function! neosnippet#variables#runtime_dir() abort "{{{
|
||||||
" Set runtime dir.
|
" Set runtime dir.
|
||||||
let runtime_dir = split(globpath(&runtimepath, 'neosnippets'), '\n')
|
let runtime_dir = split(globpath(&runtimepath, 'neosnippets'), '\n')
|
||||||
if empty(runtime_dir) && empty(g:neosnippet#disable_runtime_snippets)
|
if empty(runtime_dir) && empty(g:neosnippet#disable_runtime_snippets)
|
||||||
@ -100,7 +100,7 @@ function! neosnippet#variables#runtime_dir() "{{{
|
|||||||
|
|
||||||
return map(runtime_dir, 'substitute(v:val, "[\\\\/]$", "", "")')
|
return map(runtime_dir, 'substitute(v:val, "[\\\\/]$", "", "")')
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#variables#data_dir() "{{{
|
function! neosnippet#variables#data_dir() abort "{{{
|
||||||
let g:neosnippet#data_directory =
|
let g:neosnippet#data_directory =
|
||||||
\ substitute(fnamemodify(get(
|
\ substitute(fnamemodify(get(
|
||||||
\ g:, 'neosnippet#data_directory',
|
\ g:, 'neosnippet#data_directory',
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
let s:save_cpo = &cpo
|
let s:save_cpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
function! neosnippet#view#_expand(cur_text, col, trigger_name) "{{{
|
function! neosnippet#view#_expand(cur_text, col, trigger_name) abort "{{{
|
||||||
let snippets = neosnippet#helpers#get_snippets()
|
let snippets = neosnippet#helpers#get_snippets()
|
||||||
|
|
||||||
if a:trigger_name == '' || !has_key(snippets, a:trigger_name)
|
if a:trigger_name == '' || !has_key(snippets, a:trigger_name)
|
||||||
@ -48,7 +48,7 @@ function! neosnippet#view#_expand(cur_text, col, trigger_name) "{{{
|
|||||||
|
|
||||||
call neosnippet#view#_insert(snippet.snip, snippet.options, cur_text, a:col)
|
call neosnippet#view#_insert(snippet.snip, snippet.options, cur_text, a:col)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#view#_insert(snippet, options, cur_text, col) "{{{
|
function! neosnippet#view#_insert(snippet, options, cur_text, col) abort "{{{
|
||||||
let options = extend(
|
let options = extend(
|
||||||
\ neosnippet#parser#_initialize_snippet_options(),
|
\ neosnippet#parser#_initialize_snippet_options(),
|
||||||
\ a:options)
|
\ a:options)
|
||||||
@ -132,7 +132,7 @@ function! neosnippet#view#_insert(snippet, options, cur_text, col) "{{{
|
|||||||
endif
|
endif
|
||||||
endtry
|
endtry
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#view#_jump(_, col) "{{{
|
function! neosnippet#view#_jump(_, col) abort "{{{
|
||||||
try
|
try
|
||||||
let expand_stack = neosnippet#variables#expand_stack()
|
let expand_stack = neosnippet#variables#expand_stack()
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ function! neosnippet#view#_jump(_, col) "{{{
|
|||||||
endtry
|
endtry
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:indent_snippet(begin, end) "{{{
|
function! s:indent_snippet(begin, end) abort "{{{
|
||||||
if a:begin > a:end
|
if a:begin > a:end
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@ -215,7 +215,7 @@ function! s:indent_snippet(begin, end) "{{{
|
|||||||
endtry
|
endtry
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! neosnippet#view#_get_snippet_range(begin_line, begin_patterns, end_line, end_patterns) "{{{
|
function! neosnippet#view#_get_snippet_range(begin_line, begin_patterns, end_line, end_patterns) abort "{{{
|
||||||
let pos = getpos('.')
|
let pos = getpos('.')
|
||||||
|
|
||||||
call cursor(a:begin_line, 0)
|
call cursor(a:begin_line, 0)
|
||||||
@ -254,7 +254,7 @@ function! neosnippet#view#_get_snippet_range(begin_line, begin_patterns, end_lin
|
|||||||
call setpos('.', pos)
|
call setpos('.', pos)
|
||||||
return [begin, end]
|
return [begin, end]
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#view#_search_snippet_range(start, end, cnt, ...) "{{{
|
function! neosnippet#view#_search_snippet_range(start, end, cnt, ...) abort "{{{
|
||||||
let is_select = get(a:000, 0, 1)
|
let is_select = get(a:000, 0, 1)
|
||||||
call s:substitute_placeholder_marker(a:start, a:end, a:cnt)
|
call s:substitute_placeholder_marker(a:start, a:end, a:cnt)
|
||||||
|
|
||||||
@ -277,7 +277,7 @@ function! neosnippet#view#_search_snippet_range(start, end, cnt, ...) "{{{
|
|||||||
|
|
||||||
return 0
|
return 0
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#view#_search_outof_range(col) "{{{
|
function! neosnippet#view#_search_outof_range(col) abort "{{{
|
||||||
call s:substitute_placeholder_marker(1, 0, 0)
|
call s:substitute_placeholder_marker(1, 0, 0)
|
||||||
|
|
||||||
let pattern = neosnippet#get_placeholder_marker_pattern()
|
let pattern = neosnippet#get_placeholder_marker_pattern()
|
||||||
@ -302,7 +302,7 @@ function! neosnippet#view#_search_outof_range(col) "{{{
|
|||||||
" Not found.
|
" Not found.
|
||||||
return 0
|
return 0
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! neosnippet#view#_clear_markers(expand_info) "{{{
|
function! neosnippet#view#_clear_markers(expand_info) abort "{{{
|
||||||
" Search patterns.
|
" Search patterns.
|
||||||
let [begin, end] = neosnippet#view#_get_snippet_range(
|
let [begin, end] = neosnippet#view#_get_snippet_range(
|
||||||
\ a:expand_info.begin_line,
|
\ a:expand_info.begin_line,
|
||||||
@ -338,7 +338,7 @@ function! neosnippet#view#_clear_markers(expand_info) "{{{
|
|||||||
call neosnippet#variables#pop_expand_stack()
|
call neosnippet#variables#pop_expand_stack()
|
||||||
endtry
|
endtry
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! s:expand_placeholder(start, end, holder_cnt, line, ...) "{{{
|
function! s:expand_placeholder(start, end, holder_cnt, line, ...) abort "{{{
|
||||||
let is_select = get(a:000, 0, 1)
|
let is_select = get(a:000, 0, 1)
|
||||||
|
|
||||||
let pattern = substitute(neosnippet#get_placeholder_marker_pattern(),
|
let pattern = substitute(neosnippet#get_placeholder_marker_pattern(),
|
||||||
@ -424,7 +424,7 @@ function! s:expand_placeholder(start, end, holder_cnt, line, ...) "{{{
|
|||||||
startinsert!
|
startinsert!
|
||||||
endif
|
endif
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! s:expand_target_placeholder(line, col) "{{{
|
function! s:expand_target_placeholder(line, col) abort "{{{
|
||||||
" Expand target
|
" Expand target
|
||||||
let neosnippet = neosnippet#variables#current_neosnippet()
|
let neosnippet = neosnippet#variables#current_neosnippet()
|
||||||
let next_line = getline(a:line)[a:col-1 :]
|
let next_line = getline(a:line)[a:col-1 :]
|
||||||
@ -484,7 +484,7 @@ function! s:expand_target_placeholder(line, col) "{{{
|
|||||||
|
|
||||||
call neosnippet#view#_jump('', col)
|
call neosnippet#view#_jump('', col)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! s:search_sync_placeholder(start, end, number) "{{{
|
function! s:search_sync_placeholder(start, end, number) abort "{{{
|
||||||
if a:end == 0
|
if a:end == 0
|
||||||
" Search in current buffer.
|
" Search in current buffer.
|
||||||
let cnt = matchstr(getline('.'),
|
let cnt = matchstr(getline('.'),
|
||||||
@ -505,7 +505,7 @@ function! s:search_sync_placeholder(start, end, number) "{{{
|
|||||||
|
|
||||||
return -1
|
return -1
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! s:substitute_placeholder_marker(start, end, snippet_holder_cnt) "{{{
|
function! s:substitute_placeholder_marker(start, end, snippet_holder_cnt) abort "{{{
|
||||||
if a:snippet_holder_cnt > 0
|
if a:snippet_holder_cnt > 0
|
||||||
let cnt = a:snippet_holder_cnt-1
|
let cnt = a:snippet_holder_cnt-1
|
||||||
let sync_marker = substitute(neosnippet#get_sync_placeholder_marker_pattern(),
|
let sync_marker = substitute(neosnippet#get_sync_placeholder_marker_pattern(),
|
||||||
@ -541,7 +541,7 @@ function! s:substitute_placeholder_marker(start, end, snippet_holder_cnt) "{{{
|
|||||||
call setline('.', substitute(getline('.'), sync_marker, sub, ''))
|
call setline('.', substitute(getline('.'), sync_marker, sub, ''))
|
||||||
endif
|
endif
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! s:eval_snippet(snippet_text) "{{{
|
function! s:eval_snippet(snippet_text) abort "{{{
|
||||||
let snip_word = ''
|
let snip_word = ''
|
||||||
let prev_match = 0
|
let prev_match = 0
|
||||||
let match = match(a:snippet_text, '\\\@<!`.\{-}\\\@<!`')
|
let match = match(a:snippet_text, '\\\@<!`.\{-}\\\@<!`')
|
||||||
@ -563,7 +563,7 @@ function! s:eval_snippet(snippet_text) "{{{
|
|||||||
|
|
||||||
return snip_word
|
return snip_word
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
function! s:skip_next_auto_completion() "{{{
|
function! s:skip_next_auto_completion() abort "{{{
|
||||||
" Skip next auto completion.
|
" Skip next auto completion.
|
||||||
let neosnippet = neosnippet#variables#current_neosnippet()
|
let neosnippet = neosnippet#variables#current_neosnippet()
|
||||||
let neosnippet.trigger = 0
|
let neosnippet.trigger = 0
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
let s:save_cpo = &cpo
|
let s:save_cpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
function! unite#sources#neosnippet#define() "{{{
|
function! unite#sources#neosnippet#define() abort "{{{
|
||||||
let kind = {
|
let kind = {
|
||||||
\ 'name' : 'neosnippet',
|
\ 'name' : 'neosnippet',
|
||||||
\ 'default_action' : 'expand',
|
\ 'default_action' : 'expand',
|
||||||
@ -46,14 +46,14 @@ let s:source = {
|
|||||||
\ 'action_table' : {},
|
\ 'action_table' : {},
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
function! s:source.hooks.on_init(args, context) "{{{
|
function! s:source.hooks.on_init(args, context) abort "{{{
|
||||||
let a:context.source__cur_keyword_pos =
|
let a:context.source__cur_keyword_pos =
|
||||||
\ s:get_keyword_pos(neosnippet#util#get_cur_text())
|
\ s:get_keyword_pos(neosnippet#util#get_cur_text())
|
||||||
let a:context.source__snippets =
|
let a:context.source__snippets =
|
||||||
\ sort(values(neosnippet#helpers#get_completion_snippets()))
|
\ sort(values(neosnippet#helpers#get_completion_snippets()))
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:source.gather_candidates(args, context) "{{{
|
function! s:source.gather_candidates(args, context) abort "{{{
|
||||||
return map(copy(a:context.source__snippets), "{
|
return map(copy(a:context.source__snippets), "{
|
||||||
\ 'word' : v:val.word,
|
\ 'word' : v:val.word,
|
||||||
\ 'abbr' : printf('%-50s %s', v:val.word, v:val.menu_abbr),
|
\ 'abbr' : printf('%-50s %s', v:val.word, v:val.menu_abbr),
|
||||||
@ -74,7 +74,7 @@ let s:action_table = {}
|
|||||||
let s:action_table.expand = {
|
let s:action_table.expand = {
|
||||||
\ 'description' : 'expand snippet',
|
\ 'description' : 'expand snippet',
|
||||||
\ }
|
\ }
|
||||||
function! s:action_table.expand.func(candidate) "{{{
|
function! s:action_table.expand.func(candidate) abort "{{{
|
||||||
let cur_text = neosnippet#util#get_cur_text()
|
let cur_text = neosnippet#util#get_cur_text()
|
||||||
let cur_keyword_str = matchstr(cur_text, '\S\+$')
|
let cur_keyword_str = matchstr(cur_text, '\S\+$')
|
||||||
let context = unite#get_context()
|
let context = unite#get_context()
|
||||||
@ -88,7 +88,7 @@ let s:action_table.preview = {
|
|||||||
\ 'is_selectable' : 1,
|
\ 'is_selectable' : 1,
|
||||||
\ 'is_quit' : 0,
|
\ 'is_quit' : 0,
|
||||||
\ }
|
\ }
|
||||||
function! s:action_table.preview.func(candidates) "{{{
|
function! s:action_table.preview.func(candidates) abort "{{{
|
||||||
for snip in a:candidates
|
for snip in a:candidates
|
||||||
echohl String
|
echohl String
|
||||||
echo snip.action__complete_word
|
echo snip.action__complete_word
|
||||||
@ -102,7 +102,7 @@ let s:action_table.unite__new_candidate = {
|
|||||||
\ 'description' : 'add new snippet',
|
\ 'description' : 'add new snippet',
|
||||||
\ 'is_quit' : 1,
|
\ 'is_quit' : 1,
|
||||||
\ }
|
\ }
|
||||||
function! s:action_table.unite__new_candidate.func(candidate) "{{{
|
function! s:action_table.unite__new_candidate.func(candidate) abort "{{{
|
||||||
let trigger = unite#util#input('Please input snippet trigger: ')
|
let trigger = unite#util#input('Please input snippet trigger: ')
|
||||||
if trigger == ''
|
if trigger == ''
|
||||||
echo 'Canceled.'
|
echo 'Canceled.'
|
||||||
@ -136,7 +136,7 @@ let s:source.action_table = s:action_table
|
|||||||
unlet! s:action_table
|
unlet! s:action_table
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
function! unite#sources#neosnippet#start_complete() "{{{
|
function! unite#sources#neosnippet#start_complete() abort "{{{
|
||||||
if !exists(':Unite')
|
if !exists(':Unite')
|
||||||
call neosnippet#util#print_error(
|
call neosnippet#util#print_error(
|
||||||
\ 'unite.vim is not installed.')
|
\ 'unite.vim is not installed.')
|
||||||
@ -149,7 +149,7 @@ function! unite#sources#neosnippet#start_complete() "{{{
|
|||||||
\ { 'input': neosnippet#util#get_cur_text(), 'buffer_name' : '' })
|
\ { 'input': neosnippet#util#get_cur_text(), 'buffer_name' : '' })
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:get_keyword_pos(cur_text) "{{{
|
function! s:get_keyword_pos(cur_text) abort "{{{
|
||||||
let cur_keyword_pos = match(a:cur_text, '\S\+$')
|
let cur_keyword_pos = match(a:cur_text, '\S\+$')
|
||||||
if cur_keyword_pos < 0
|
if cur_keyword_pos < 0
|
||||||
" Empty string.
|
" Empty string.
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
let s:save_cpo = &cpo
|
let s:save_cpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
function! unite#sources#neosnippet_file#define() "{{{
|
function! unite#sources#neosnippet_file#define() abort "{{{
|
||||||
return [s:source_user, s:source_runtime]
|
return [s:source_user, s:source_runtime]
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ let s:action_table.neosnippet_source = {
|
|||||||
\ 'is_selectable' : 1,
|
\ 'is_selectable' : 1,
|
||||||
\ 'is_quit' : 1,
|
\ 'is_quit' : 1,
|
||||||
\ }
|
\ }
|
||||||
function! s:action_table.neosnippet_source.func(candidates) "{{{
|
function! s:action_table.neosnippet_source.func(candidates) abort "{{{
|
||||||
for candidate in a:candidates
|
for candidate in a:candidates
|
||||||
let snippet_name = candidate.action__path
|
let snippet_name = candidate.action__path
|
||||||
if snippet_name != ''
|
if snippet_name != ''
|
||||||
@ -52,7 +52,7 @@ let s:source_user = {
|
|||||||
\ 'description' : 'neosnippet user file',
|
\ 'description' : 'neosnippet user file',
|
||||||
\ 'action_table' : copy(s:action_table),
|
\ 'action_table' : copy(s:action_table),
|
||||||
\ }
|
\ }
|
||||||
function! s:source_user.gather_candidates(args, context) "{{{
|
function! s:source_user.gather_candidates(args, context) abort "{{{
|
||||||
return s:get_snippet_candidates(
|
return s:get_snippet_candidates(
|
||||||
\ neosnippet#get_user_snippets_directory())
|
\ neosnippet#get_user_snippets_directory())
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
@ -62,7 +62,7 @@ let s:source_user.action_table.unite__new_candidate = {
|
|||||||
\ 'is_invalidate_cache' : 1,
|
\ 'is_invalidate_cache' : 1,
|
||||||
\ 'is_quit' : 1,
|
\ 'is_quit' : 1,
|
||||||
\ }
|
\ }
|
||||||
function! s:source_user.action_table.unite__new_candidate.func(candidate) "{{{
|
function! s:source_user.action_table.unite__new_candidate.func(candidate) abort "{{{
|
||||||
let filename = input(
|
let filename = input(
|
||||||
\ 'New snippet file name: ', neosnippet#helpers#get_filetype())
|
\ 'New snippet file name: ', neosnippet#helpers#get_filetype())
|
||||||
if filename != ''
|
if filename != ''
|
||||||
@ -77,7 +77,7 @@ let s:source_runtime = {
|
|||||||
\ 'description' : 'neosnippet runtime file',
|
\ 'description' : 'neosnippet runtime file',
|
||||||
\ 'action_table' : copy(s:action_table),
|
\ 'action_table' : copy(s:action_table),
|
||||||
\ }
|
\ }
|
||||||
function! s:source_runtime.gather_candidates(args, context) "{{{
|
function! s:source_runtime.gather_candidates(args, context) abort "{{{
|
||||||
return s:get_snippet_candidates(
|
return s:get_snippet_candidates(
|
||||||
\ neosnippet#get_runtime_snippets_directory())
|
\ neosnippet#get_runtime_snippets_directory())
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
@ -87,7 +87,7 @@ let s:source_runtime.action_table.unite__new_candidate = {
|
|||||||
\ 'is_invalidate_cache' : 1,
|
\ 'is_invalidate_cache' : 1,
|
||||||
\ 'is_quit' : 1,
|
\ 'is_quit' : 1,
|
||||||
\ }
|
\ }
|
||||||
function! s:source_runtime.action_table.unite__new_candidate.func(candidate) "{{{
|
function! s:source_runtime.action_table.unite__new_candidate.func(candidate) abort "{{{
|
||||||
let filename = input(
|
let filename = input(
|
||||||
\ 'New snippet file name: ', neosnippet#helpers#get_filetype())
|
\ 'New snippet file name: ', neosnippet#helpers#get_filetype())
|
||||||
if filename != ''
|
if filename != ''
|
||||||
@ -96,7 +96,7 @@ function! s:source_runtime.action_table.unite__new_candidate.func(candidate) "{{
|
|||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
|
|
||||||
function! s:get_snippet_candidates(dirs) "{{{
|
function! s:get_snippet_candidates(dirs) abort "{{{
|
||||||
let _ = []
|
let _ = []
|
||||||
for directory in a:dirs
|
for directory in a:dirs
|
||||||
let _ += map(split(unite#util#substitute_path_separator(
|
let _ += map(split(unite#util#substitute_path_separator(
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
" For honza-snippets function.
|
" For honza-snippets function.
|
||||||
function! vim_snippets#Filename(...)
|
function! vim_snippets#Filename(...) abort
|
||||||
let filename = expand('%:t:r')
|
let filename = expand('%:t:r')
|
||||||
if filename == ''
|
if filename == ''
|
||||||
return a:0 == 2 ? a:2 : ''
|
return a:0 == 2 ? a:2 : ''
|
||||||
|
@ -40,7 +40,7 @@ endif
|
|||||||
|
|
||||||
setlocal indentexpr=SnippetsIndent()
|
setlocal indentexpr=SnippetsIndent()
|
||||||
|
|
||||||
function! SnippetsIndent() "{{{
|
function! SnippetsIndent() abort "{{{
|
||||||
let line = getline('.')
|
let line = getline('.')
|
||||||
let prev_line = (line('.') == 1)? '' : getline(line('.')-1)
|
let prev_line = (line('.') == 1)? '' : getline(line('.')-1)
|
||||||
let syntax = '\%(include\|snippet\|abbr\|prev_word\|delete\|alias\|options\|regexp\)'
|
let syntax = '\%(include\|snippet\|abbr\|prev_word\|delete\|alias\|options\|regexp\)'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
let s:suite = themis#suite('toml')
|
let s:suite = themis#suite('toml')
|
||||||
let s:assert = themis#helper('assert')
|
let s:assert = themis#helper('assert')
|
||||||
|
|
||||||
function! s:suite.get_in_paren()
|
function! s:suite.get_in_paren() abort
|
||||||
call s:assert.equals(neosnippet#parser#_get_in_paren(
|
call s:assert.equals(neosnippet#parser#_get_in_paren(
|
||||||
\ '(', ')',
|
\ '(', ')',
|
||||||
\ '(foobar)'),
|
\ '(foobar)'),
|
||||||
@ -32,7 +32,7 @@ function! s:suite.get_in_paren()
|
|||||||
\ 'long, int')
|
\ 'long, int')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:suite.get_completed_snippet()
|
function! s:suite.get_completed_snippet() abort
|
||||||
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
|
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
|
||||||
\ 'word' : 'foo(', 'abbr' : 'foo()',
|
\ 'word' : 'foo(', 'abbr' : 'foo()',
|
||||||
\ 'menu' : '', 'info' : ''
|
\ 'menu' : '', 'info' : ''
|
||||||
|
Loading…
Reference in New Issue
Block a user