Add abort flag

This commit is contained in:
Shougo Matsushita 2016-02-08 21:48:14 +09:00
parent 232d2e8def
commit 644b551aff
17 changed files with 148 additions and 148 deletions

View File

@ -33,7 +33,7 @@ let s:source = {
\ g:neocomplcache_auto_completion_start_length,
\}
function! s:source.initialize() "{{{
function! s:source.initialize() abort "{{{
" Initialize.
call neocomplcache#set_dictionary_helper(
\ g:neocomplcache_source_rank, 'snippets_complete', 8)
@ -41,7 +41,7 @@ function! s:source.initialize() "{{{
\ g:neocomplcache_auto_completion_start_length)
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 word_candidates = neocomplcache#keyword_filter(
\ filter(values(neosnippet#helpers#get_snippets()),
@ -53,7 +53,7 @@ function! s:source.get_keyword_pos(cur_text) "{{{
return match(a:cur_text, '\S\+$')
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)
for snippet in list
@ -66,7 +66,7 @@ function! s:source.get_complete_words(cur_keyword_pos, cur_keyword_str) "{{{
return list
endfunction"}}}
function! s:keyword_filter(snippets, cur_keyword_str) "{{{
function! s:keyword_filter(snippets, cur_keyword_str) abort "{{{
" Uniq by real_name.
let dict = {}
@ -89,7 +89,7 @@ function! s:keyword_filter(snippets, cur_keyword_str) "{{{
return values(dict)
endfunction"}}}
function! neocomplcache#sources#snippets_complete#define() "{{{
function! neocomplcache#sources#snippets_complete#define() abort "{{{
return s:source
endfunction"}}}

View File

@ -37,7 +37,7 @@ let s:source = {
\ ['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())
if matchstr(a:context.input, '\S\+$') !=#
\ matchstr(a:context.input, '\w\+$')
@ -47,7 +47,7 @@ function! s:source.gather_candidates(context) "{{{
return snippets
endfunction"}}}
function! s:source.hooks.on_post_filter(context) "{{{
function! s:source.hooks.on_post_filter(context) abort "{{{
for snippet in a:context.candidates
let snippet.dup = 1
let snippet.menu = neosnippet#util#strwidthpart(
@ -57,7 +57,7 @@ function! s:source.hooks.on_post_filter(context) "{{{
return a:context.candidates
endfunction"}}}
function! neocomplete#sources#neosnippet#define() "{{{
function! neocomplete#sources#neosnippet#define() abort "{{{
return s:source
endfunction"}}}

View File

@ -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()
endfunction"}}}
function! neosnippet#expandable() "{{{
function! neosnippet#expandable() abort "{{{
return neosnippet#mappings#expandable()
endfunction"}}}
function! neosnippet#jumpable() "{{{
function! neosnippet#jumpable() abort "{{{
return neosnippet#mappings#jumpable()
endfunction"}}}
function! neosnippet#anonymous(snippet) "{{{
function! neosnippet#anonymous(snippet) abort "{{{
return neosnippet#mappings#_anonymous(a:snippet)
endfunction"}}}
function! neosnippet#expand(trigger) "{{{
function! neosnippet#expand(trigger) abort "{{{
return neosnippet#mappings#_expand(a:trigger)
endfunction"}}}
function! neosnippet#get_snippets_directory() "{{{
function! neosnippet#get_snippets_directory() abort "{{{
return neosnippet#helpers#get_snippets_directory()
endfunction"}}}
function! neosnippet#get_user_snippets_directory() "{{{
function! neosnippet#get_user_snippets_directory() abort "{{{
return copy(neosnippet#variables#snippets_dir())
endfunction"}}}
function! neosnippet#get_runtime_snippets_directory() "{{{
function! neosnippet#get_runtime_snippets_directory() abort "{{{
return copy(neosnippet#variables#runtime_dir())
endfunction"}}}
" Get marker patterns.
function! neosnippet#get_placeholder_target_marker_pattern() "{{{
function! neosnippet#get_placeholder_target_marker_pattern() abort "{{{
return '\${\d\+:\(#:\)\?TARGET\%(:.\{-}\)\?\\\@<!}'
endfunction"}}}
function! neosnippet#get_placeholder_marker_pattern() "{{{
function! neosnippet#get_placeholder_marker_pattern() abort "{{{
return '<`\d\+\%(:.\{-}\)\?\\\@<!`>'
endfunction"}}}
function! neosnippet#get_placeholder_marker_substitute_pattern() "{{{
function! neosnippet#get_placeholder_marker_substitute_pattern() abort "{{{
return '\${\(\d\+\%(:.\{-}\)\?\\\@<!\)}'
endfunction"}}}
function! neosnippet#get_placeholder_marker_substitute_nonzero_pattern() "{{{
function! neosnippet#get_placeholder_marker_substitute_nonzero_pattern() abort "{{{
return '\${\([1-9]\d*\%(:.\{-}\)\?\\\@<!\)}'
endfunction"}}}
function! neosnippet#get_placeholder_marker_substitute_zero_pattern() "{{{
function! neosnippet#get_placeholder_marker_substitute_zero_pattern() abort "{{{
return '\${\(0\%(:.\{-}\)\?\\\@<!\)}'
endfunction"}}}
function! neosnippet#get_placeholder_marker_default_pattern() "{{{
function! neosnippet#get_placeholder_marker_default_pattern() abort "{{{
return '<`\d\+:\zs.\{-}\ze\\\@<!`>'
endfunction"}}}
function! neosnippet#get_sync_placeholder_marker_pattern() "{{{
function! neosnippet#get_sync_placeholder_marker_pattern() abort "{{{
return '<{\d\+\%(:.\{-}\)\?\\\@<!}>'
endfunction"}}}
function! neosnippet#get_sync_placeholder_marker_default_pattern() "{{{
function! neosnippet#get_sync_placeholder_marker_default_pattern() abort "{{{
return '<{\d\+:\zs.\{-}\ze\\\@<!}>'
endfunction"}}}
function! neosnippet#get_mirror_placeholder_marker_pattern() "{{{
function! neosnippet#get_mirror_placeholder_marker_pattern() abort "{{{
return '<|\d\+|>'
endfunction"}}}
function! neosnippet#get_mirror_placeholder_marker_substitute_pattern() "{{{
function! neosnippet#get_mirror_placeholder_marker_substitute_pattern() abort "{{{
return '\$\(\d\+\)'
endfunction"}}}

View File

@ -34,14 +34,14 @@ let s:edit_options = [
let s:Cache = neosnippet#util#get_vital().import('System.Cache')
"}}}
function! s:get_list() "{{{
function! s:get_list() abort "{{{
if !exists('s:List')
let s:List = vital#of('neosnippet').import('Data.List')
endif
return s:List
endfunction"}}}
function! neosnippet#commands#_edit(args) "{{{
function! neosnippet#commands#_edit(args) abort "{{{
if neosnippet#util#is_sudo()
call neosnippet#util#print_error(
\ '"sudo vim" is detected. This feature is disabled.')
@ -92,7 +92,7 @@ function! neosnippet#commands#_edit(args) "{{{
endtry
endfunction"}}}
function! neosnippet#commands#_make_cache(filetype) "{{{
function! neosnippet#commands#_make_cache(filetype) abort "{{{
call neosnippet#init#check()
let filetype = a:filetype == '' ?
@ -128,7 +128,7 @@ function! neosnippet#commands#_make_cache(filetype) "{{{
endif
endfunction"}}}
function! neosnippet#commands#_source(filename) "{{{
function! neosnippet#commands#_source(filename) abort "{{{
call neosnippet#init#check()
let neosnippet = neosnippet#variables#current_neosnippet()
@ -136,7 +136,7 @@ function! neosnippet#commands#_source(filename) "{{{
\ neosnippet#parser#_parse_snippets(a:filename))
endfunction"}}}
function! neosnippet#commands#_clear_markers() "{{{
function! neosnippet#commands#_clear_markers() abort "{{{
let expand_stack = neosnippet#variables#expand_stack()
" Get patterns and count.
@ -150,12 +150,12 @@ function! neosnippet#commands#_clear_markers() "{{{
endfunction"}}}
" Complete helpers.
function! neosnippet#commands#_edit_complete(arglead, cmdline, cursorpos) "{{{
function! neosnippet#commands#_edit_complete(arglead, cmdline, cursorpos) abort "{{{
return filter(s:edit_options +
\ neosnippet#commands#_filetype_complete(a:arglead, a:cmdline, a:cursorpos),
\ 'stridx(v:val, a:arglead) == 0')
endfunction"}}}
function! neosnippet#commands#_filetype_complete(arglead, cmdline, cursorpos) "{{{
function! neosnippet#commands#_filetype_complete(arglead, cmdline, cursorpos) abort "{{{
" Dup check.
let ret = {}
for item in map(
@ -170,13 +170,13 @@ function! neosnippet#commands#_filetype_complete(arglead, cmdline, cursorpos) "{
return sort(keys(ret))
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()),
\ "stridx(v:val.word, a:arglead) == 0
\ && v:val.snip =~# neosnippet#get_placeholder_target_marker_pattern()"), 'v:val.word')
endfunction"}}}
function! s:initialize_options(options) "{{{
function! s:initialize_options(options) abort "{{{
let default_options = {
\ 'runtime' : 0,
\ 'vertical' : 0,

View File

@ -26,7 +26,7 @@
let s:save_cpo = &cpo
set cpo&vim
function! neosnippet#handlers#_complete_done() "{{{
function! neosnippet#handlers#_complete_done() abort "{{{
if empty(v:completed_item)
\ || !g:neosnippet#enable_completed_snippet
\ || s:is_auto_pairs()
@ -43,7 +43,7 @@ function! neosnippet#handlers#_complete_done() "{{{
call neosnippet#view#_insert(snippet, {}, cur_text, col)
endfunction"}}}
function! neosnippet#handlers#_cursor_moved() "{{{
function! neosnippet#handlers#_cursor_moved() abort "{{{
let expand_stack = neosnippet#variables#expand_stack()
" Get patterns and count.
@ -59,7 +59,7 @@ function! neosnippet#handlers#_cursor_moved() "{{{
endif
endfunction"}}}
function! neosnippet#handlers#_all_clear_markers() "{{{
function! neosnippet#handlers#_all_clear_markers() abort "{{{
let pos = getpos('.')
try
@ -74,7 +74,7 @@ function! neosnippet#handlers#_all_clear_markers() "{{{
endtry
endfunction"}}}
function! neosnippet#handlers#_restore_unnamed_register() "{{{
function! neosnippet#handlers#_restore_unnamed_register() abort "{{{
let neosnippet = neosnippet#variables#current_neosnippet()
if neosnippet.unnamed_register != ''

View File

@ -26,7 +26,7 @@
let s:save_cpo = &cpo
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\+$')
if cur_word != '' && has_key(a:snippets, cur_word)
return cur_word
@ -44,7 +44,7 @@ function! neosnippet#helpers#get_cursor_snippet(snippets, cur_text) "{{{
return cur_word
endfunction"}}}
function! neosnippet#helpers#get_snippets() "{{{
function! neosnippet#helpers#get_snippets() abort "{{{
call neosnippet#init#check()
let neosnippet = neosnippet#variables#current_neosnippet()
@ -72,12 +72,12 @@ function! neosnippet#helpers#get_snippets() "{{{
return snippets
endfunction"}}}
function! neosnippet#helpers#get_completion_snippets() "{{{
function! neosnippet#helpers#get_completion_snippets() abort "{{{
return filter(neosnippet#helpers#get_snippets(),
\ "!get(v:val.options, 'oneshot', 0)")
endfunction"}}}
function! neosnippet#helpers#get_snippets_directory() "{{{
function! neosnippet#helpers#get_snippets_directory() abort "{{{
let snippets_dir = copy(neosnippet#variables#snippets_dir())
if !get(g:neosnippet#disable_runtime_snippets,
\ neosnippet#helpers#get_filetype(),
@ -88,7 +88,7 @@ function! neosnippet#helpers#get_snippets_directory() "{{{
return snippets_dir
endfunction"}}}
function! neosnippet#helpers#get_filetype() "{{{
function! neosnippet#helpers#get_filetype() abort "{{{
if !exists('s:exists_context_filetype')
" context_filetype.vim installation check.
try
@ -109,7 +109,7 @@ function! neosnippet#helpers#get_filetype() "{{{
return context_filetype
endfunction"}}}
function! neosnippet#helpers#get_selected_text(type, ...) "{{{
function! neosnippet#helpers#get_selected_text(type, ...) abort "{{{
let sel_save = &selection
let &selection = 'inclusive'
let reg_save = @@
@ -134,7 +134,7 @@ function! neosnippet#helpers#get_selected_text(type, ...) "{{{
call setpos('.', pos)
endtry
endfunction"}}}
function! neosnippet#helpers#delete_selected_text(type, ...) "{{{
function! neosnippet#helpers#delete_selected_text(type, ...) abort "{{{
let sel_save = &selection
let &selection = 'inclusive'
let reg_save = @@
@ -157,7 +157,7 @@ function! neosnippet#helpers#delete_selected_text(type, ...) "{{{
call setpos('.', pos)
endtry
endfunction"}}}
function! neosnippet#helpers#substitute_selected_text(type, text) "{{{
function! neosnippet#helpers#substitute_selected_text(type, text) abort "{{{
let sel_save = &selection
let &selection = 'inclusive'
let reg_save = @@
@ -181,7 +181,7 @@ function! neosnippet#helpers#substitute_selected_text(type, text) "{{{
endtry
endfunction"}}}
function! s:is_beginning_of_line(cur_text) "{{{
function! s:is_beginning_of_line(cur_text) abort "{{{
let keyword_pattern = '\S\+'
let cur_keyword_str = matchstr(a:cur_text, keyword_pattern.'$')
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
endfunction"}}}
function! s:get_sources_filetypes(filetype) "{{{
function! s:get_sources_filetypes(filetype) abort "{{{
let filetypes =
\ exists('*context_filetype#get_filetypes') ?
\ context_filetype#get_filetypes(a:filetype) :

View File

@ -26,27 +26,27 @@
let s:save_cpo = &cpo
set cpo&vim
function! neosnippet#init#_initialize() "{{{
function! neosnippet#init#_initialize() abort "{{{
let s:is_initialized = 1
call s:initialize_others()
call s:initialize_cache()
endfunction"}}}
function! neosnippet#init#check() "{{{
function! neosnippet#init#check() abort "{{{
if !exists('s:is_initialized')
call neosnippet#init#_initialize()
endif
endfunction"}}}
function! s:initialize_cache() "{{{
function! s:initialize_cache() abort "{{{
" Make cache for _ snippets.
call neosnippet#commands#_make_cache('_')
" Initialize check.
call neosnippet#commands#_make_cache(&filetype)
endfunction"}}}
function! s:initialize_others() "{{{
function! s:initialize_others() abort "{{{
augroup neosnippet "{{{
autocmd!
" Set make cache event.
@ -98,7 +98,7 @@ function! s:initialize_others() "{{{
if g:neosnippet#enable_snipmate_compatibility "{{{
" For snipMate function.
function! Filename(...)
function! Filename(...) abort
let filename = expand('%:t:r')
if filename == ''
return a:0 == 2 ? a:2 : ''

View File

@ -26,21 +26,21 @@
let s:save_cpo = &cpo
set cpo&vim
function! neosnippet#mappings#expandable_or_jumpable() "{{{
function! neosnippet#mappings#expandable_or_jumpable() abort "{{{
return neosnippet#mappings#expandable() || neosnippet#mappings#jumpable()
endfunction"}}}
function! neosnippet#mappings#expandable() "{{{
function! neosnippet#mappings#expandable() abort "{{{
" Check snippet trigger.
return neosnippet#helpers#get_cursor_snippet(
\ neosnippet#helpers#get_snippets(), neosnippet#util#get_cur_text()) != ''
endfunction"}}}
function! neosnippet#mappings#jumpable() "{{{
function! neosnippet#mappings#jumpable() abort "{{{
" Found snippet placeholder.
return search(neosnippet#get_placeholder_marker_pattern(). '\|'
\ .neosnippet#get_sync_placeholder_marker_pattern(), 'nw') > 0
endfunction"}}}
function! neosnippet#mappings#_clear_select_mode_mappings() "{{{
function! neosnippet#mappings#_clear_select_mode_mappings() abort "{{{
if !g:neosnippet#disable_select_mode_mappings
return
endif
@ -64,7 +64,7 @@ function! neosnippet#mappings#_clear_select_mode_mappings() "{{{
snoremap <ESC> <BS><ESC>
endfunction"}}}
function! neosnippet#mappings#_register_oneshot_snippet() "{{{
function! neosnippet#mappings#_register_oneshot_snippet() abort "{{{
let trigger = input('Please input snippet trigger: ', 'oneshot')
if trigger == ''
return
@ -92,7 +92,7 @@ function! neosnippet#mappings#_register_oneshot_snippet() "{{{
echo 'Registered trigger : ' . trigger
endfunction"}}}
function! neosnippet#mappings#_expand_target() "{{{
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()
@ -109,7 +109,7 @@ function! neosnippet#mappings#_expand_target() "{{{
call neosnippet#mappings#_expand_target_trigger(trigger)
endfunction"}}}
function! neosnippet#mappings#_expand_target_trigger(trigger) "{{{
function! neosnippet#mappings#_expand_target_trigger(trigger) abort "{{{
let neosnippet = neosnippet#variables#current_neosnippet()
let neosnippet.target = substitute(
\ neosnippet#helpers#get_selected_text(visualmode(), 1), '\n$', '', '')
@ -136,14 +136,14 @@ function! neosnippet#mappings#_expand_target_trigger(trigger) "{{{
endif
endfunction"}}}
function! neosnippet#mappings#_anonymous(snippet) "{{{
function! neosnippet#mappings#_anonymous(snippet) abort "{{{
let [cur_text, col, expr] = neosnippet#mappings#_pre_trigger()
let expr .= printf("\<ESC>:call neosnippet#view#_insert(%s, {}, %s, %d)\<CR>",
\ string(a:snippet), string(cur_text), col)
return expr
endfunction"}}}
function! neosnippet#mappings#_expand(trigger) "{{{
function! neosnippet#mappings#_expand(trigger) abort "{{{
let [cur_text, col, expr] = neosnippet#mappings#_pre_trigger()
let expr .= printf("\<ESC>:call neosnippet#view#_expand(%s, %d, %s)\<CR>",
@ -152,7 +152,7 @@ function! neosnippet#mappings#_expand(trigger) "{{{
return expr
endfunction"}}}
function! s:snippets_expand(cur_text, col) "{{{
function! s:snippets_expand(cur_text, col) abort "{{{
let cur_word = neosnippet#helpers#get_cursor_snippet(
\ neosnippet#helpers#get_snippets(),
\ a:cur_text)
@ -161,7 +161,7 @@ function! s:snippets_expand(cur_text, col) "{{{
\ neosnippet#util#get_cur_text(), a:col, cur_word)
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(
\ neosnippet#helpers#get_snippets(), a:cur_text)
@ -174,7 +174,7 @@ function! s:snippets_expand_or_jump(cur_text, col) "{{{
endif
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(
\ neosnippet#helpers#get_snippets(), a:cur_text)
if search(neosnippet#get_placeholder_marker_pattern(). '\|'
@ -187,11 +187,11 @@ function! s:snippets_jump_or_expand(cur_text, col) "{{{
endif
endfunction"}}}
function! s:SID_PREFIX() "{{{
function! s:SID_PREFIX() abort "{{{
return matchstr(expand('<sfile>'), '<SNR>\d\+_\ze\w\+$')
endfunction"}}}
function! neosnippet#mappings#_trigger(function) "{{{
function! neosnippet#mappings#_trigger(function) abort "{{{
let [cur_text, col, expr] = neosnippet#mappings#_pre_trigger()
let expr .= printf("\<ESC>:call %s(%s,%d)\<CR>",
@ -200,7 +200,7 @@ function! neosnippet#mappings#_trigger(function) "{{{
return expr
endfunction"}}}
function! neosnippet#mappings#_pre_trigger() "{{{
function! neosnippet#mappings#_pre_trigger() abort "{{{
call neosnippet#init#check()
let cur_text = neosnippet#util#get_cur_text()
@ -223,22 +223,22 @@ function! neosnippet#mappings#_pre_trigger() "{{{
endfunction"}}}
" Plugin key-mappings.
function! neosnippet#mappings#expand_or_jump_impl()
function! neosnippet#mappings#expand_or_jump_impl() abort
return mode() ==# 's' ?
\ neosnippet#mappings#_trigger('neosnippet#view#_jump') :
\ neosnippet#mappings#_trigger(
\ s:SID_PREFIX().'snippets_expand_or_jump')
endfunction
function! neosnippet#mappings#jump_or_expand_impl()
function! neosnippet#mappings#jump_or_expand_impl() abort
return mode() ==# 's' ?
\ neosnippet#mappings#_trigger('neosnippet#view#_jump') :
\ neosnippet#mappings#_trigger(
\ s:SID_PREFIX().'snippets_jump_or_expand')
endfunction
function! neosnippet#mappings#expand_impl()
function! neosnippet#mappings#expand_impl() abort
return neosnippet#mappings#_trigger(s:SID_PREFIX().'snippets_expand')
endfunction
function! neosnippet#mappings#jump_impl()
function! neosnippet#mappings#jump_impl() abort
return neosnippet#mappings#_trigger('neosnippet#view#_jump')
endfunction

View File

@ -28,7 +28,7 @@ set cpo&vim
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)
call neosnippet#util#print_error(
\ printf('snippet file "%s" is not found.', a:filename))
@ -49,7 +49,7 @@ function! neosnippet#parser#_parse_snippets(filename) "{{{
return snippets
endfunction"}}}
function! neosnippet#parser#_parse_snippet(filename, trigger) "{{{
function! neosnippet#parser#_parse_snippet(filename, trigger) abort "{{{
if !filereadable(a:filename)
call neosnippet#util#print_error(
\ 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)
endfunction"}}}
function! s:parse(snippets_file) "{{{
function! s:parse(snippets_file) abort "{{{
let dup_check = {}
let snippet_dict = {}
let linenr = 1
@ -138,7 +138,7 @@ function! s:parse(snippets_file) "{{{
return [snippets, sourced]
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.
let snippet_dict = {
\ 'word' : '',
@ -180,7 +180,7 @@ function! s:parse_snippet_name(snippets_file, line, linenr, dup_check) "{{{
return snippet_dict
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.
" This will override what was set via the snippet line.
if a:line =~ '^abbr\s'
@ -221,7 +221,7 @@ function! s:add_snippet_attribute(snippets_file, line, linenr, snippet_dict) "{{
endif
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)
return
endif
@ -243,7 +243,7 @@ function! s:set_snippet_dict(snippet_dict, snippets, dup_check, snippets_file) "
endfor
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\+$', '', '')
if a:dict.word !~ '\n'
\ && a:dict.word !~
@ -282,7 +282,7 @@ function! neosnippet#parser#_initialize_snippet(dict, path, line, pattern, name)
return snippet
endfunction"}}}
function! neosnippet#parser#_initialize_snippet_options() "{{{
function! neosnippet#parser#_initialize_snippet_options() abort "{{{
return {
\ 'head' : 0,
\ 'word' :
@ -292,7 +292,7 @@ function! neosnippet#parser#_initialize_snippet_options() "{{{
\ }
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
" Set abbr

View File

@ -27,70 +27,70 @@ let s:save_cpo = &cpo
set cpo&vim
let s:V = vital#of('neosnippet')
function! neosnippet#util#get_vital() "{{{
function! neosnippet#util#get_vital() abort "{{{
return s:V
endfunction"}}}
function! s:get_prelude() "{{{
function! s:get_prelude() abort "{{{
if !exists('s:Prelude')
let s:Prelude = neosnippet#util#get_vital().import('Prelude')
endif
return s:Prelude
endfunction"}}}
function! s:get_list() "{{{
function! s:get_list() abort "{{{
if !exists('s:List')
let s:List = neosnippet#util#get_vital().import('Data.List')
endif
return s:List
endfunction"}}}
function! s:get_string() "{{{
function! s:get_string() abort "{{{
if !exists('s:String')
let s:String = neosnippet#util#get_vital().import('Data.String')
endif
return s:String
endfunction"}}}
function! s:get_process() "{{{
function! s:get_process() abort "{{{
if !exists('s:Process')
let s:Process = neosnippet#util#get_vital().import('Process')
endif
return s:Process
endfunction"}}}
function! neosnippet#util#substitute_path_separator(...) "{{{
function! neosnippet#util#substitute_path_separator(...) abort "{{{
return call(s:get_prelude().substitute_path_separator, a:000)
endfunction"}}}
function! neosnippet#util#system(...) "{{{
function! neosnippet#util#system(...) abort "{{{
return call(s:get_process().system, a:000)
endfunction"}}}
function! neosnippet#util#has_vimproc(...) "{{{
function! neosnippet#util#has_vimproc(...) abort "{{{
return call(s:get_process().has_vimproc, a:000)
endfunction"}}}
function! neosnippet#util#is_windows(...) "{{{
function! neosnippet#util#is_windows(...) abort "{{{
return call(s:get_prelude().is_windows, a:000)
endfunction"}}}
function! neosnippet#util#is_mac(...) "{{{
function! neosnippet#util#is_mac(...) abort "{{{
return call(s:get_prelude().is_mac, a:000)
endfunction"}}}
function! neosnippet#util#get_last_status(...) "{{{
function! neosnippet#util#get_last_status(...) abort "{{{
return call(s:get_process().get_last_status, a:000)
endfunction"}}}
function! neosnippet#util#escape_pattern(...) "{{{
function! neosnippet#util#escape_pattern(...) abort "{{{
return call(s:get_prelude().escape_pattern, a:000)
endfunction"}}}
function! neosnippet#util#iconv(...) "{{{
function! neosnippet#util#iconv(...) abort "{{{
return call(s:get_process().iconv, a:000)
endfunction"}}}
function! neosnippet#util#truncate(...) "{{{
function! neosnippet#util#truncate(...) abort "{{{
return call(s:get_string().truncate, a:000)
endfunction"}}}
function! neosnippet#util#strwidthpart(...) "{{{
function! neosnippet#util#strwidthpart(...) abort "{{{
return call(s:get_string().strwidthpart, a:000)
endfunction"}}}
function! neosnippet#util#expand(path) "{{{
function! neosnippet#util#expand(path) abort "{{{
return neosnippet#util#substitute_path_separator(
\ expand(escape(a:path, '*?[]"={}'), 1))
endfunction"}}}
function! neosnippet#util#set_default(var, val, ...) "{{{
function! neosnippet#util#set_default(var, val, ...) abort "{{{
let old_var = get(a:000, 0, '')
if exists(old_var)
let {a:var} = {old_var}
@ -98,25 +98,25 @@ function! neosnippet#util#set_default(var, val, ...) "{{{
let {a:var} = a:val
endif
endfunction"}}}
function! neosnippet#util#set_dictionary_helper(...) "{{{
function! neosnippet#util#set_dictionary_helper(...) abort "{{{
return call(s:get_prelude().set_dictionary_helper, a:000)
endfunction"}}}
function! neosnippet#util#get_cur_text() "{{{
function! neosnippet#util#get_cur_text() abort "{{{
return
\ (mode() ==# 'i' ? (col('.')-1) : col('.')) >= len(getline('.')) ?
\ getline('.') :
\ matchstr(getline('.'),
\ '^.*\%' . col('.') . 'c' . (mode() ==# 'i' ? '' : '.'))
endfunction"}}}
function! neosnippet#util#get_next_text() "{{{
function! neosnippet#util#get_next_text() abort "{{{
return getline('.')[len(neosnippet#util#get_cur_text()) :]
endfunction"}}}
function! neosnippet#util#print_error(string) "{{{
function! neosnippet#util#print_error(string) abort "{{{
echohl Error | echomsg '[neosnippet] ' . a:string | echohl None
endfunction"}}}
function! neosnippet#util#parse_options(args, options_list) "{{{
function! neosnippet#util#parse_options(args, options_list) abort "{{{
let args = []
let options = {}
for arg in split(a:args, '\%(\\\@<!\s\)\+')
@ -154,13 +154,13 @@ function! neosnippet#util#get_buffer_config(
endfunction"}}}
" Sudo check.
function! neosnippet#util#is_sudo() "{{{
function! neosnippet#util#is_sudo() abort "{{{
return $SUDO_USER != '' && $USER !=# $SUDO_USER
\ && $HOME !=# expand('~'.$USER)
\ && $HOME ==# expand('~'.$SUDO_USER)
endfunction"}}}
function! neosnippet#util#option2list(str) "{{{
function! neosnippet#util#option2list(str) abort "{{{
return type(a:str) == type('') ? split(a:str, '\s*,\s*') : a:str
endfunction"}}}

View File

@ -26,7 +26,7 @@
let s:save_cpo = &cpo
set cpo&vim
function! neosnippet#variables#current_neosnippet() "{{{
function! neosnippet#variables#current_neosnippet() abort "{{{
if !exists('b:neosnippet')
let b:neosnippet = {
\ 'snippets' : {},
@ -40,34 +40,34 @@ function! neosnippet#variables#current_neosnippet() "{{{
return b:neosnippet
endfunction"}}}
function! neosnippet#variables#expand_stack() "{{{
function! neosnippet#variables#expand_stack() abort "{{{
if !exists('s:expand_stack')
let s:expand_stack = []
endif
return s:expand_stack
endfunction"}}}
function! neosnippet#variables#pop_expand_stack() "{{{
function! neosnippet#variables#pop_expand_stack() abort "{{{
let s:expand_stack = s:expand_stack[: -2]
endfunction"}}}
function! neosnippet#variables#clear_expand_stack() "{{{
function! neosnippet#variables#clear_expand_stack() abort "{{{
let s:expand_stack = []
endfunction"}}}
function! neosnippet#variables#snippets() "{{{
function! neosnippet#variables#snippets() abort "{{{
if !exists('s:snippets')
let s:snippets= {}
endif
return s:snippets
endfunction"}}}
function! neosnippet#variables#set_snippets(list) "{{{
function! neosnippet#variables#set_snippets(list) abort "{{{
if !exists('s:snippets')
let s:snippets= {}
endif
let s:snippets = a:list
endfunction"}}}
function! neosnippet#variables#snippets_dir() "{{{
function! neosnippet#variables#snippets_dir() abort "{{{
" Set snippets_dir.
let snippets_dir = []
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, "[\\\\/]$", "", "")')
endfunction"}}}
function! neosnippet#variables#runtime_dir() "{{{
function! neosnippet#variables#runtime_dir() abort "{{{
" Set runtime dir.
let runtime_dir = split(globpath(&runtimepath, 'neosnippets'), '\n')
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, "[\\\\/]$", "", "")')
endfunction"}}}
function! neosnippet#variables#data_dir() "{{{
function! neosnippet#variables#data_dir() abort "{{{
let g:neosnippet#data_directory =
\ substitute(fnamemodify(get(
\ g:, 'neosnippet#data_directory',

View File

@ -26,7 +26,7 @@
let s:save_cpo = &cpo
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()
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)
endfunction"}}}
function! neosnippet#view#_insert(snippet, options, cur_text, col) "{{{
function! neosnippet#view#_insert(snippet, options, cur_text, col) abort "{{{
let options = extend(
\ neosnippet#parser#_initialize_snippet_options(),
\ a:options)
@ -132,7 +132,7 @@ function! neosnippet#view#_insert(snippet, options, cur_text, col) "{{{
endif
endtry
endfunction"}}}
function! neosnippet#view#_jump(_, col) "{{{
function! neosnippet#view#_jump(_, col) abort "{{{
try
let expand_stack = neosnippet#variables#expand_stack()
@ -176,7 +176,7 @@ function! neosnippet#view#_jump(_, col) "{{{
endtry
endfunction"}}}
function! s:indent_snippet(begin, end) "{{{
function! s:indent_snippet(begin, end) abort "{{{
if a:begin > a:end
return
endif
@ -215,7 +215,7 @@ function! s:indent_snippet(begin, end) "{{{
endtry
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('.')
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)
return [begin, end]
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)
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
endfunction"}}}
function! neosnippet#view#_search_outof_range(col) "{{{
function! neosnippet#view#_search_outof_range(col) abort "{{{
call s:substitute_placeholder_marker(1, 0, 0)
let pattern = neosnippet#get_placeholder_marker_pattern()
@ -302,7 +302,7 @@ function! neosnippet#view#_search_outof_range(col) "{{{
" Not found.
return 0
endfunction"}}}
function! neosnippet#view#_clear_markers(expand_info) "{{{
function! neosnippet#view#_clear_markers(expand_info) abort "{{{
" Search patterns.
let [begin, end] = neosnippet#view#_get_snippet_range(
\ a:expand_info.begin_line,
@ -338,7 +338,7 @@ function! neosnippet#view#_clear_markers(expand_info) "{{{
call neosnippet#variables#pop_expand_stack()
endtry
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 pattern = substitute(neosnippet#get_placeholder_marker_pattern(),
@ -424,7 +424,7 @@ function! s:expand_placeholder(start, end, holder_cnt, line, ...) "{{{
startinsert!
endif
endfunction"}}}
function! s:expand_target_placeholder(line, col) "{{{
function! s:expand_target_placeholder(line, col) abort "{{{
" Expand target
let neosnippet = neosnippet#variables#current_neosnippet()
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)
endfunction"}}}
function! s:search_sync_placeholder(start, end, number) "{{{
function! s:search_sync_placeholder(start, end, number) abort "{{{
if a:end == 0
" Search in current buffer.
let cnt = matchstr(getline('.'),
@ -505,7 +505,7 @@ function! s:search_sync_placeholder(start, end, number) "{{{
return -1
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
let cnt = a:snippet_holder_cnt-1
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, ''))
endif
endfunction"}}}
function! s:eval_snippet(snippet_text) "{{{
function! s:eval_snippet(snippet_text) abort "{{{
let snip_word = ''
let prev_match = 0
let match = match(a:snippet_text, '\\\@<!`.\{-}\\\@<!`')
@ -563,7 +563,7 @@ function! s:eval_snippet(snippet_text) "{{{
return snip_word
endfunction"}}}
function! s:skip_next_auto_completion() "{{{
function! s:skip_next_auto_completion() abort "{{{
" Skip next auto completion.
let neosnippet = neosnippet#variables#current_neosnippet()
let neosnippet.trigger = 0

View File

@ -26,7 +26,7 @@
let s:save_cpo = &cpo
set cpo&vim
function! unite#sources#neosnippet#define() "{{{
function! unite#sources#neosnippet#define() abort "{{{
let kind = {
\ 'name' : 'neosnippet',
\ 'default_action' : 'expand',
@ -46,14 +46,14 @@ let s:source = {
\ '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 =
\ s:get_keyword_pos(neosnippet#util#get_cur_text())
let a:context.source__snippets =
\ sort(values(neosnippet#helpers#get_completion_snippets()))
endfunction"}}}
function! s:source.gather_candidates(args, context) "{{{
function! s:source.gather_candidates(args, context) abort "{{{
return map(copy(a:context.source__snippets), "{
\ 'word' : v:val.word,
\ 'abbr' : printf('%-50s %s', v:val.word, v:val.menu_abbr),
@ -74,7 +74,7 @@ let s:action_table = {}
let s:action_table.expand = {
\ '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_keyword_str = matchstr(cur_text, '\S\+$')
let context = unite#get_context()
@ -88,7 +88,7 @@ let s:action_table.preview = {
\ 'is_selectable' : 1,
\ 'is_quit' : 0,
\ }
function! s:action_table.preview.func(candidates) "{{{
function! s:action_table.preview.func(candidates) abort "{{{
for snip in a:candidates
echohl String
echo snip.action__complete_word
@ -102,7 +102,7 @@ let s:action_table.unite__new_candidate = {
\ 'description' : 'add new snippet',
\ '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: ')
if trigger == ''
echo 'Canceled.'
@ -136,7 +136,7 @@ let s:source.action_table = s:action_table
unlet! s:action_table
"}}}
function! unite#sources#neosnippet#start_complete() "{{{
function! unite#sources#neosnippet#start_complete() abort "{{{
if !exists(':Unite')
call neosnippet#util#print_error(
\ 'unite.vim is not installed.')
@ -149,7 +149,7 @@ function! unite#sources#neosnippet#start_complete() "{{{
\ { 'input': neosnippet#util#get_cur_text(), 'buffer_name' : '' })
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\+$')
if cur_keyword_pos < 0
" Empty string.

View File

@ -26,7 +26,7 @@
let s:save_cpo = &cpo
set cpo&vim
function! unite#sources#neosnippet_file#define() "{{{
function! unite#sources#neosnippet_file#define() abort "{{{
return [s:source_user, s:source_runtime]
endfunction "}}}
@ -37,7 +37,7 @@ let s:action_table.neosnippet_source = {
\ 'is_selectable' : 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
let snippet_name = candidate.action__path
if snippet_name != ''
@ -52,7 +52,7 @@ let s:source_user = {
\ 'description' : 'neosnippet user file',
\ '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(
\ neosnippet#get_user_snippets_directory())
endfunction "}}}
@ -62,7 +62,7 @@ let s:source_user.action_table.unite__new_candidate = {
\ 'is_invalidate_cache' : 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(
\ 'New snippet file name: ', neosnippet#helpers#get_filetype())
if filename != ''
@ -77,7 +77,7 @@ let s:source_runtime = {
\ 'description' : 'neosnippet runtime file',
\ '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(
\ neosnippet#get_runtime_snippets_directory())
endfunction "}}}
@ -87,7 +87,7 @@ let s:source_runtime.action_table.unite__new_candidate = {
\ 'is_invalidate_cache' : 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(
\ 'New snippet file name: ', neosnippet#helpers#get_filetype())
if filename != ''
@ -96,7 +96,7 @@ function! s:source_runtime.action_table.unite__new_candidate.func(candidate) "{{
endfunction"}}}
function! s:get_snippet_candidates(dirs) "{{{
function! s:get_snippet_candidates(dirs) abort "{{{
let _ = []
for directory in a:dirs
let _ += map(split(unite#util#substitute_path_separator(

View File

@ -1,5 +1,5 @@
" For honza-snippets function.
function! vim_snippets#Filename(...)
function! vim_snippets#Filename(...) abort
let filename = expand('%:t:r')
if filename == ''
return a:0 == 2 ? a:2 : ''

View File

@ -40,7 +40,7 @@ endif
setlocal indentexpr=SnippetsIndent()
function! SnippetsIndent() "{{{
function! SnippetsIndent() abort "{{{
let line = getline('.')
let prev_line = (line('.') == 1)? '' : getline(line('.')-1)
let syntax = '\%(include\|snippet\|abbr\|prev_word\|delete\|alias\|options\|regexp\)'

View File

@ -1,7 +1,7 @@
let s:suite = themis#suite('toml')
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(
\ '(', ')',
\ '(foobar)'),
@ -32,7 +32,7 @@ function! s:suite.get_in_paren()
\ 'long, int')
endfunction
function! s:suite.get_completed_snippet()
function! s:suite.get_completed_snippet() abort
call s:assert.equals(neosnippet#parser#_get_completed_snippet({
\ 'word' : 'foo(', 'abbr' : 'foo()',
\ 'menu' : '', 'info' : ''