- Converted markers.
This commit is contained in:
parent
0fa62bcea1
commit
c98182d10d
@ -32,7 +32,7 @@ let s:source = {
|
||||
\ 'kind' : 'complfunc',
|
||||
\}
|
||||
|
||||
function! s:source.initialize()"{{{
|
||||
function! s:source.initialize() "{{{
|
||||
" Initialize.
|
||||
call neocomplcache#set_dictionary_helper(
|
||||
\ g:neocomplcache_source_rank, 'snippets_complete', 8)
|
||||
@ -40,7 +40,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) "{{{
|
||||
let cur_word = matchstr(a:cur_text, '\w\+$')
|
||||
let word_candidates = neocomplcache#keyword_filter(
|
||||
\ filter(values(neosnippet#get_snippets()),
|
||||
@ -52,7 +52,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) "{{{
|
||||
let list = s:keyword_filter(neosnippet#get_snippets(), a:cur_keyword_str)
|
||||
|
||||
" Substitute abbr.
|
||||
@ -69,7 +69,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) "{{{
|
||||
" Uniq by real_name.
|
||||
let dict = {}
|
||||
|
||||
@ -112,7 +112,7 @@ function! s:keyword_filter(snippets, cur_keyword_str)"{{{
|
||||
endfunction"}}}
|
||||
|
||||
|
||||
function! neocomplcache#sources#snippets_complete#define()"{{{
|
||||
function! neocomplcache#sources#snippets_complete#define() "{{{
|
||||
return s:source
|
||||
endfunction"}}}
|
||||
|
||||
@ -120,20 +120,20 @@ function! s:compare_words(i1, i2)
|
||||
return a:i1.menu - a:i2.menu
|
||||
endfunction
|
||||
|
||||
function! neocomplcache#sources#snippets_complete#expandable()"{{{
|
||||
function! neocomplcache#sources#snippets_complete#expandable() "{{{
|
||||
return neosnippet#expandable()
|
||||
endfunction"}}}
|
||||
function! neocomplcache#sources#snippets_complete#force_expandable()"{{{
|
||||
function! neocomplcache#sources#snippets_complete#force_expandable() "{{{
|
||||
return neosnippet#expandable()
|
||||
endfunction"}}}
|
||||
function! neocomplcache#sources#snippets_complete#jumpable()"{{{
|
||||
function! neocomplcache#sources#snippets_complete#jumpable() "{{{
|
||||
return neosnippet#jumpable()
|
||||
endfunction"}}}
|
||||
|
||||
function! neocomplcache#sources#snippets_complete#get_snippets()"{{{
|
||||
function! neocomplcache#sources#snippets_complete#get_snippets() "{{{
|
||||
return neosnippet#get_snippets()
|
||||
endfunction"}}}
|
||||
function! neocomplcache#sources#snippets_complete#get_snippets_dir()"{{{
|
||||
function! neocomplcache#sources#snippets_complete#get_snippets_dir() "{{{
|
||||
return neosnippet#get_snippets_directory()
|
||||
endfunction"}}}
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
" Global options definition."{{{
|
||||
" Global options definition. "{{{
|
||||
call neosnippet#util#set_default(
|
||||
\ 'g:neosnippet#disable_runtime_snippets', {})
|
||||
call neosnippet#util#set_default(
|
||||
@ -47,7 +47,7 @@ let s:neosnippet_options = [
|
||||
\]
|
||||
"}}}
|
||||
|
||||
function! s:initialize()"{{{
|
||||
function! s:initialize() "{{{
|
||||
" Initialize.
|
||||
let s:snippets_expand_stack = []
|
||||
|
||||
@ -107,13 +107,13 @@ function! s:initialize()"{{{
|
||||
endif
|
||||
endfunction"}}}
|
||||
|
||||
" For echodoc."{{{
|
||||
" For echodoc. "{{{
|
||||
let s:doc_dict = {
|
||||
\ 'name' : 'neosnippet',
|
||||
\ 'rank' : 100,
|
||||
\ 'filetypes' : {},
|
||||
\ }
|
||||
function! s:doc_dict.search(cur_text)"{{{
|
||||
function! s:doc_dict.search(cur_text) "{{{
|
||||
if mode() !=# 'i'
|
||||
return []
|
||||
endif
|
||||
@ -135,7 +135,7 @@ function! s:doc_dict.search(cur_text)"{{{
|
||||
endfunction"}}}
|
||||
"}}}
|
||||
|
||||
function! neosnippet#expandable()"{{{
|
||||
function! neosnippet#expandable() "{{{
|
||||
let ret = 0
|
||||
|
||||
let snippets = neosnippet#get_snippets()
|
||||
@ -153,21 +153,21 @@ function! neosnippet#expandable()"{{{
|
||||
|
||||
return ret
|
||||
endfunction"}}}
|
||||
function! neosnippet#jumpable()"{{{
|
||||
function! neosnippet#jumpable() "{{{
|
||||
" Found snippet placeholder.
|
||||
return search(s:get_placeholder_marker_pattern(). '\|'
|
||||
\ .s:get_sync_placeholder_marker_pattern(), 'nw') > 0
|
||||
endfunction"}}}
|
||||
|
||||
function! neosnippet#caching()"{{{
|
||||
function! neosnippet#caching() "{{{
|
||||
call neosnippet#make_cache(&filetype)
|
||||
endfunction"}}}
|
||||
|
||||
function! neosnippet#recaching()"{{{
|
||||
function! neosnippet#recaching() "{{{
|
||||
let s:snippets = {}
|
||||
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) "{{{
|
||||
if empty(a:snippet_dict)
|
||||
return
|
||||
endif
|
||||
@ -189,7 +189,7 @@ function! s:set_snippet_dict(snippet_dict, snippets, dup_check, snippets_file)"{
|
||||
let a:dup_check[alias] = alias_snippet
|
||||
endfor
|
||||
endfunction"}}}
|
||||
function! s:initialize_snippet(dict, path, line, pattern, name)"{{{
|
||||
function! s:initialize_snippet(dict, path, line, pattern, name) "{{{
|
||||
let a:dict.word = substitute(a:dict.word, '\n\+$', '', '')
|
||||
if a:dict.word !~
|
||||
\ s:get_placeholder_marker_substitute_pattern()
|
||||
@ -234,11 +234,11 @@ function! s:initialize_snippet(dict, path, line, pattern, name)"{{{
|
||||
|
||||
return snippet
|
||||
endfunction"}}}
|
||||
function! s:initialize_snippet_options()"{{{
|
||||
function! s:initialize_snippet_options() "{{{
|
||||
return { 'head' : 0, 'word' : 0, 'indent' : 0 }
|
||||
endfunction"}}}
|
||||
|
||||
function! neosnippet#edit_snippets(args)"{{{
|
||||
function! neosnippet#edit_snippets(args) "{{{
|
||||
let [args, options] = neosnippet#util#parse_options(
|
||||
\ a:args, s:neosnippet_options)
|
||||
|
||||
@ -279,7 +279,7 @@ function! neosnippet#edit_snippets(args)"{{{
|
||||
endtry
|
||||
endfunction"}}}
|
||||
|
||||
function! s:initialize_options(options)"{{{
|
||||
function! s:initialize_options(options) "{{{
|
||||
let default_options = {
|
||||
\ 'runtime' : 0,
|
||||
\ 'vertical' : 0,
|
||||
@ -298,7 +298,7 @@ function! s:initialize_options(options)"{{{
|
||||
return options
|
||||
endfunction"}}}
|
||||
|
||||
function! neosnippet#make_cache(filetype)"{{{
|
||||
function! neosnippet#make_cache(filetype) "{{{
|
||||
let filetype = a:filetype == '' ?
|
||||
\ &filetype : a:filetype
|
||||
if filetype ==# ''
|
||||
@ -325,12 +325,12 @@ function! neosnippet#make_cache(filetype)"{{{
|
||||
let s:snippets[filetype] = snippet
|
||||
endfunction"}}}
|
||||
|
||||
function! neosnippet#source_file(filename)"{{{
|
||||
function! neosnippet#source_file(filename) "{{{
|
||||
let neosnippet = neosnippet#get_current_neosnippet()
|
||||
call s:parse_snippets_file(neosnippet.snippets, a:filename)
|
||||
endfunction"}}}
|
||||
|
||||
function! s:parse_snippets_file(snippets, snippets_file)"{{{
|
||||
function! s:parse_snippets_file(snippets, snippets_file) "{{{
|
||||
let dup_check = {}
|
||||
let snippet_dict = {}
|
||||
|
||||
@ -400,7 +400,7 @@ function! s:parse_snippets_file(snippets, snippets_file)"{{{
|
||||
return a:snippets
|
||||
endfunction"}}}
|
||||
|
||||
function! s:parse_snippet_name(snippets_file, line, linenr, dup_check)"{{{
|
||||
function! s:parse_snippet_name(snippets_file, line, linenr, dup_check) "{{{
|
||||
" Initialize snippet dict.
|
||||
let snippet_dict = { 'word' : '', 'linenr' : a:linenr,
|
||||
\ 'options' : s:initialize_snippet_options() }
|
||||
@ -438,7 +438,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) "{{{
|
||||
" 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'
|
||||
@ -479,7 +479,7 @@ function! s:add_snippet_attribute(snippets_file, line, linenr, snippet_dict)"{{{
|
||||
endif
|
||||
endfunction"}}}
|
||||
|
||||
function! s:is_beginning_of_line(cur_text)"{{{
|
||||
function! s:is_beginning_of_line(cur_text) "{{{
|
||||
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)]
|
||||
@ -487,7 +487,7 @@ function! s:is_beginning_of_line(cur_text)"{{{
|
||||
|
||||
return prev_word_end <= 0
|
||||
endfunction"}}}
|
||||
function! s:get_cursor_snippet(snippets, cur_text)"{{{
|
||||
function! s:get_cursor_snippet(snippets, cur_text) "{{{
|
||||
let cur_word = matchstr(a:cur_text, '\S\+$')
|
||||
if cur_word != '' && has_key(a:snippets, cur_word)
|
||||
return cur_word
|
||||
@ -505,7 +505,7 @@ function! s:get_cursor_snippet(snippets, cur_text)"{{{
|
||||
return cur_word
|
||||
endfunction"}}}
|
||||
|
||||
function! s:snippets_expand(cur_text, col)"{{{
|
||||
function! s:snippets_expand(cur_text, col) "{{{
|
||||
let cur_word = s:get_cursor_snippet(
|
||||
\ neosnippet#get_snippets(),
|
||||
\ a:cur_text)
|
||||
@ -513,7 +513,7 @@ function! s:snippets_expand(cur_text, col)"{{{
|
||||
call neosnippet#expand(
|
||||
\ a:cur_text, a:col, cur_word)
|
||||
endfunction"}}}
|
||||
function! neosnippet#jump(cur_text, col)"{{{
|
||||
function! neosnippet#jump(cur_text, col) "{{{
|
||||
call s:skip_next_auto_completion()
|
||||
|
||||
" Get patterns and count.
|
||||
@ -544,7 +544,7 @@ function! neosnippet#jump(cur_text, col)"{{{
|
||||
|
||||
return s:search_outof_range(a:col)
|
||||
endfunction"}}}
|
||||
function! s:snippets_expand_or_jump(cur_text, col)"{{{
|
||||
function! s:snippets_expand_or_jump(cur_text, col) "{{{
|
||||
let cur_word = s:get_cursor_snippet(
|
||||
\ neosnippet#get_snippets(), a:cur_text)
|
||||
|
||||
@ -556,7 +556,7 @@ function! s:snippets_expand_or_jump(cur_text, col)"{{{
|
||||
call neosnippet#jump(a:cur_text, a:col)
|
||||
endif
|
||||
endfunction"}}}
|
||||
function! s:snippets_jump_or_expand(cur_text, col)"{{{
|
||||
function! s:snippets_jump_or_expand(cur_text, col) "{{{
|
||||
let cur_word = s:get_cursor_snippet(
|
||||
\ neosnippet#get_snippets(), a:cur_text)
|
||||
if search(s:get_placeholder_marker_pattern(). '\|'
|
||||
@ -569,7 +569,7 @@ function! s:snippets_jump_or_expand(cur_text, col)"{{{
|
||||
endif
|
||||
endfunction"}}}
|
||||
|
||||
function! neosnippet#expand(cur_text, col, trigger_name)"{{{
|
||||
function! neosnippet#expand(cur_text, col, trigger_name) "{{{
|
||||
call s:skip_next_auto_completion()
|
||||
|
||||
let snippets = neosnippet#get_snippets()
|
||||
@ -661,7 +661,7 @@ function! neosnippet#expand(cur_text, col, trigger_name)"{{{
|
||||
let &l:iminsert = 0
|
||||
let &l:imsearch = 0
|
||||
endfunction"}}}
|
||||
function! neosnippet#expand_target()"{{{
|
||||
function! neosnippet#expand_target() "{{{
|
||||
let trigger = input('Please input snippet trigger: ',
|
||||
\ '', 'customlist,neosnippet#complete_target_snippets')
|
||||
let neosnippet = neosnippet#get_current_neosnippet()
|
||||
@ -678,7 +678,7 @@ function! neosnippet#expand_target()"{{{
|
||||
|
||||
call neosnippet#expand_target_trigger(trigger)
|
||||
endfunction"}}}
|
||||
function! neosnippet#expand_target_trigger(trigger)"{{{
|
||||
function! neosnippet#expand_target_trigger(trigger) "{{{
|
||||
let neosnippet = neosnippet#get_current_neosnippet()
|
||||
let neosnippet.target = substitute(
|
||||
\ neosnippet#get_selected_text(visualmode(), 1), '\n$', '', '')
|
||||
@ -692,7 +692,7 @@ function! neosnippet#expand_target_trigger(trigger)"{{{
|
||||
|
||||
call neosnippet#expand(neosnippet#util#get_cur_text(), col, a:trigger)
|
||||
endfunction"}}}
|
||||
function! s:indent_snippet(begin, end)"{{{
|
||||
function! s:indent_snippet(begin, end) "{{{
|
||||
if a:begin > a:end
|
||||
return
|
||||
endif
|
||||
@ -734,7 +734,7 @@ function! s:indent_snippet(begin, end)"{{{
|
||||
endtry
|
||||
endfunction"}}}
|
||||
|
||||
function! neosnippet#register_oneshot_snippet()"{{{
|
||||
function! neosnippet#register_oneshot_snippet() "{{{
|
||||
let trigger = input('Please input snippet trigger: ', 'oneshot')
|
||||
if trigger == ''
|
||||
return
|
||||
@ -761,7 +761,7 @@ function! neosnippet#register_oneshot_snippet()"{{{
|
||||
echo 'Registered trigger : ' . trigger
|
||||
endfunction"}}}
|
||||
|
||||
function! s:get_snippet_range(begin_line, begin_patterns, end_line, end_patterns)"{{{
|
||||
function! s:get_snippet_range(begin_line, begin_patterns, end_line, end_patterns) "{{{
|
||||
let pos = getpos('.')
|
||||
|
||||
call cursor(a:begin_line, 0)
|
||||
@ -795,7 +795,7 @@ function! s:get_snippet_range(begin_line, begin_patterns, end_line, end_patterns
|
||||
call setpos('.', pos)
|
||||
return [begin, end]
|
||||
endfunction"}}}
|
||||
function! s:search_snippet_range(start, end, cnt)"{{{
|
||||
function! s:search_snippet_range(start, end, cnt) "{{{
|
||||
call s:substitute_placeholder_marker(a:start, a:end, a:cnt)
|
||||
|
||||
" Search marker pattern.
|
||||
@ -810,7 +810,7 @@ function! s:search_snippet_range(start, end, cnt)"{{{
|
||||
|
||||
return 0
|
||||
endfunction"}}}
|
||||
function! s:search_outof_range(col)"{{{
|
||||
function! s:search_outof_range(col) "{{{
|
||||
call s:substitute_placeholder_marker(1, 0, 0)
|
||||
|
||||
let pattern = s:get_placeholder_marker_pattern()
|
||||
@ -835,7 +835,7 @@ function! s:search_outof_range(col)"{{{
|
||||
" Not found.
|
||||
return 0
|
||||
endfunction"}}}
|
||||
function! s:expand_placeholder(start, end, holder_cnt, line)"{{{
|
||||
function! s:expand_placeholder(start, end, holder_cnt, line) "{{{
|
||||
let pattern = substitute(s:get_placeholder_marker_pattern(),
|
||||
\ '\\d\\+', a:holder_cnt, '')
|
||||
let current_line = getline(a:line)
|
||||
@ -909,7 +909,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) "{{{
|
||||
" Expand target
|
||||
let neosnippet = neosnippet#get_current_neosnippet()
|
||||
let next_line = getline(a:line)[a:col-1 :]
|
||||
@ -957,7 +957,7 @@ function! s:expand_target_placeholder(line, col)"{{{
|
||||
|
||||
call neosnippet#jump(neosnippet#util#get_cur_text(), col)
|
||||
endfunction"}}}
|
||||
function! s:search_sync_placeholder(start, end, number)"{{{
|
||||
function! s:search_sync_placeholder(start, end, number) "{{{
|
||||
if a:end == 0
|
||||
" Search in current buffer.
|
||||
let cnt = matchstr(getline('.'),
|
||||
@ -978,7 +978,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) "{{{
|
||||
if a:snippet_holder_cnt > 0
|
||||
let cnt = a:snippet_holder_cnt-1
|
||||
let sync_marker = substitute(s:get_sync_placeholder_marker_pattern(),
|
||||
@ -1014,7 +1014,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) "{{{
|
||||
let snip_word = ''
|
||||
let prev_match = 0
|
||||
let match = match(a:snippet_text, '\\\@<!`.\{-}\\\@<!`')
|
||||
@ -1036,7 +1036,7 @@ function! s:eval_snippet(snippet_text)"{{{
|
||||
|
||||
return snip_word
|
||||
endfunction"}}}
|
||||
function! neosnippet#get_current_neosnippet()"{{{
|
||||
function! neosnippet#get_current_neosnippet() "{{{
|
||||
if !exists('b:neosnippet')
|
||||
let b:neosnippet = {
|
||||
\ 'snippets' : {},
|
||||
@ -1047,7 +1047,7 @@ function! neosnippet#get_current_neosnippet()"{{{
|
||||
|
||||
return b:neosnippet
|
||||
endfunction"}}}
|
||||
function! neosnippet#get_snippets()"{{{
|
||||
function! neosnippet#get_snippets() "{{{
|
||||
let neosnippet = neosnippet#get_current_neosnippet()
|
||||
let snippets = copy(neosnippet.snippets)
|
||||
for filetype in s:get_sources_filetypes(neosnippet#get_filetype())
|
||||
@ -1067,7 +1067,7 @@ function! neosnippet#get_snippets()"{{{
|
||||
|
||||
return snippets
|
||||
endfunction"}}}
|
||||
function! neosnippet#get_snippets_directory()"{{{
|
||||
function! neosnippet#get_snippets_directory() "{{{
|
||||
let snippets_dir = copy(s:snippets_dir)
|
||||
if !get(g:neosnippet#disable_runtime_snippets,
|
||||
\ neosnippet#get_filetype(),
|
||||
@ -1077,22 +1077,22 @@ function! neosnippet#get_snippets_directory()"{{{
|
||||
|
||||
return snippets_dir
|
||||
endfunction"}}}
|
||||
function! neosnippet#get_filetype()"{{{
|
||||
function! neosnippet#get_filetype() "{{{
|
||||
return exists('*neocomplcache#get_context_filetype') ?
|
||||
\ neocomplcache#get_context_filetype(1) : &filetype
|
||||
endfunction"}}}
|
||||
function! s:get_sources_filetypes(filetype)"{{{
|
||||
function! s:get_sources_filetypes(filetype) "{{{
|
||||
return (exists('*neocomplcache#get_source_filetypes') ?
|
||||
\ neocomplcache#get_source_filetypes(a:filetype) :
|
||||
\ [a:filetype]) + ['_']
|
||||
endfunction"}}}
|
||||
|
||||
function! neosnippet#edit_complete(arglead, cmdline, cursorpos)"{{{
|
||||
function! neosnippet#edit_complete(arglead, cmdline, cursorpos) "{{{
|
||||
return filter(s:neosnippet_options + neosnippet#filetype_complete(
|
||||
\ a:arglead, a:cmdline, a:cursorpos), 'stridx(v:val, a:arglead) == 0')
|
||||
endfunction"}}}
|
||||
" Complete filetype helper.
|
||||
function! neosnippet#filetype_complete(arglead, cmdline, cursorpos)"{{{
|
||||
function! neosnippet#filetype_complete(arglead, cmdline, cursorpos) "{{{
|
||||
" Dup check.
|
||||
let ret = {}
|
||||
for item in map(
|
||||
@ -1107,42 +1107,42 @@ function! neosnippet#filetype_complete(arglead, cmdline, cursorpos)"{{{
|
||||
|
||||
return sort(keys(ret))
|
||||
endfunction"}}}
|
||||
function! neosnippet#complete_target_snippets(arglead, cmdline, cursorpos)"{{{
|
||||
function! neosnippet#complete_target_snippets(arglead, cmdline, cursorpos) "{{{
|
||||
return map(filter(values(neosnippet#get_snippets()),
|
||||
\ "stridx(v:val.word, a:arglead) == 0
|
||||
\ && v:val.snip =~# neosnippet#get_placeholder_target_marker_pattern()"), 'v:val.word')
|
||||
endfunction"}}}
|
||||
|
||||
function! neosnippet#get_placeholder_target_marker_pattern()"{{{
|
||||
function! neosnippet#get_placeholder_target_marker_pattern() "{{{
|
||||
return '\${\d\+:TARGET\%(:.\{-}\)\?\\\@<!}'
|
||||
endfunction"}}}
|
||||
function! s:get_placeholder_marker_pattern()"{{{
|
||||
function! s:get_placeholder_marker_pattern() "{{{
|
||||
return '<`\d\+\%(:.\{-}\)\?\\\@<!`>'
|
||||
endfunction"}}}
|
||||
function! s:get_placeholder_marker_substitute_pattern()"{{{
|
||||
function! s:get_placeholder_marker_substitute_pattern() "{{{
|
||||
return '\${\(\d\+\%(:.\{-}\)\?\\\@<!\)}'
|
||||
endfunction"}}}
|
||||
function! s:get_placeholder_marker_default_pattern()"{{{
|
||||
function! s:get_placeholder_marker_default_pattern() "{{{
|
||||
return '<`\d\+:\zs.\{-}\ze\\\@<!`>'
|
||||
endfunction"}}}
|
||||
function! s:get_sync_placeholder_marker_pattern()"{{{
|
||||
function! s:get_sync_placeholder_marker_pattern() "{{{
|
||||
return '<{\d\+\%(:.\{-}\)\?\\\@<!}>'
|
||||
endfunction"}}}
|
||||
function! s:get_sync_placeholder_marker_default_pattern()"{{{
|
||||
function! s:get_sync_placeholder_marker_default_pattern() "{{{
|
||||
return '<{\d\+:\zs.\{-}\ze\\\@<!}>'
|
||||
endfunction"}}}
|
||||
function! s:get_mirror_placeholder_marker_pattern()"{{{
|
||||
function! s:get_mirror_placeholder_marker_pattern() "{{{
|
||||
return '<|\d\+|>'
|
||||
endfunction"}}}
|
||||
function! s:get_mirror_placeholder_marker_substitute_pattern()"{{{
|
||||
function! s:get_mirror_placeholder_marker_substitute_pattern() "{{{
|
||||
return '\$\(\d\+\)'
|
||||
endfunction"}}}
|
||||
|
||||
function! s:SID_PREFIX()"{{{
|
||||
function! s:SID_PREFIX() "{{{
|
||||
return matchstr(expand('<sfile>'), '<SNR>\d\+_')
|
||||
endfunction"}}}
|
||||
|
||||
function! s:trigger(function)"{{{
|
||||
function! s:trigger(function) "{{{
|
||||
let cur_text = neosnippet#util#get_cur_text()
|
||||
|
||||
let col = col('.')
|
||||
@ -1164,7 +1164,7 @@ function! s:trigger(function)"{{{
|
||||
return expr
|
||||
endfunction"}}}
|
||||
|
||||
function! neosnippet#get_selected_text(type, ...)"{{{
|
||||
function! neosnippet#get_selected_text(type, ...) "{{{
|
||||
let sel_save = &selection
|
||||
let &selection = 'inclusive'
|
||||
let reg_save = @@
|
||||
@ -1189,7 +1189,7 @@ function! neosnippet#get_selected_text(type, ...)"{{{
|
||||
call setpos('.', pos)
|
||||
endtry
|
||||
endfunction"}}}
|
||||
function! neosnippet#delete_selected_text(type, ...)"{{{
|
||||
function! neosnippet#delete_selected_text(type, ...) "{{{
|
||||
let sel_save = &selection
|
||||
let &selection = 'inclusive'
|
||||
let reg_save = @@
|
||||
@ -1212,7 +1212,7 @@ function! neosnippet#delete_selected_text(type, ...)"{{{
|
||||
call setpos('.', pos)
|
||||
endtry
|
||||
endfunction"}}}
|
||||
function! neosnippet#substitute_selected_text(type, text)"{{{
|
||||
function! neosnippet#substitute_selected_text(type, text) "{{{
|
||||
let sel_save = &selection
|
||||
let &selection = 'inclusive'
|
||||
let reg_save = @@
|
||||
@ -1236,7 +1236,7 @@ function! neosnippet#substitute_selected_text(type, text)"{{{
|
||||
endtry
|
||||
endfunction"}}}
|
||||
|
||||
function! neosnippet#clear_select_mode_mappings()"{{{
|
||||
function! neosnippet#clear_select_mode_mappings() "{{{
|
||||
if !g:neosnippet#disable_select_mode_mappings
|
||||
return
|
||||
endif
|
||||
|
@ -29,32 +29,32 @@ set cpo&vim
|
||||
|
||||
let s:V = vital#of('neosnippet')
|
||||
|
||||
function! neosnippet#util#substitute_path_separator(...)"{{{
|
||||
function! neosnippet#util#substitute_path_separator(...) "{{{
|
||||
return call(s:V.substitute_path_separator, a:000)
|
||||
endfunction"}}}
|
||||
function! neosnippet#util#system(...)"{{{
|
||||
function! neosnippet#util#system(...) "{{{
|
||||
return call(s:V.system, a:000)
|
||||
endfunction"}}}
|
||||
function! neosnippet#util#has_vimproc(...)"{{{
|
||||
function! neosnippet#util#has_vimproc(...) "{{{
|
||||
return call(s:V.has_vimproc, a:000)
|
||||
endfunction"}}}
|
||||
function! neosnippet#util#is_windows(...)"{{{
|
||||
function! neosnippet#util#is_windows(...) "{{{
|
||||
return call(s:V.is_windows, a:000)
|
||||
endfunction"}}}
|
||||
function! neosnippet#util#is_mac(...)"{{{
|
||||
function! neosnippet#util#is_mac(...) "{{{
|
||||
return call(s:V.is_mac, a:000)
|
||||
endfunction"}}}
|
||||
function! neosnippet#util#get_last_status(...)"{{{
|
||||
function! neosnippet#util#get_last_status(...) "{{{
|
||||
return call(s:V.get_last_status, a:000)
|
||||
endfunction"}}}
|
||||
function! neosnippet#util#escape_pattern(...)"{{{
|
||||
function! neosnippet#util#escape_pattern(...) "{{{
|
||||
return call(s:V.escape_pattern, a:000)
|
||||
endfunction"}}}
|
||||
function! neosnippet#util#iconv(...)"{{{
|
||||
function! neosnippet#util#iconv(...) "{{{
|
||||
return call(s:V.iconv, a:000)
|
||||
endfunction"}}}
|
||||
|
||||
function! neosnippet#util#expand(path)"{{{
|
||||
function! neosnippet#util#expand(path) "{{{
|
||||
return neosnippet#util#substitute_path_separator(
|
||||
\ expand(escape(a:path, '*?[]"={}'), 1))
|
||||
endfunction"}}}
|
||||
@ -66,22 +66,22 @@ function! neosnippet#util#set_default(var, val, ...) "{{{
|
||||
\ {alternate_var} : a:val
|
||||
endif
|
||||
endfunction"}}}
|
||||
function! neosnippet#util#set_dictionary_helper(...)"{{{
|
||||
function! neosnippet#util#set_dictionary_helper(...) "{{{
|
||||
return call(s:V.set_dictionary_helper, a:000)
|
||||
endfunction"}}}
|
||||
|
||||
function! neosnippet#util#get_cur_text()"{{{
|
||||
function! neosnippet#util#get_cur_text() "{{{
|
||||
return
|
||||
\ (mode() ==# 'i' ? (col('.')-1) : col('.')) >= len(getline('.')) ?
|
||||
\ getline('.') :
|
||||
\ matchstr(getline('.'),
|
||||
\ '^.*\%' . col('.') . 'c' . (mode() ==# 'i' ? '' : '.'))
|
||||
endfunction"}}}
|
||||
function! neosnippet#util#print_error(string)"{{{
|
||||
function! neosnippet#util#print_error(string) "{{{
|
||||
echohl Error | echomsg a:string | echohl None
|
||||
endfunction"}}}
|
||||
|
||||
function! neosnippet#util#parse_options(args, options_list)"{{{
|
||||
function! neosnippet#util#parse_options(args, options_list) "{{{
|
||||
let args = []
|
||||
let options = {}
|
||||
for arg in split(a:args, '\%(\\\@<!\s\)\+')
|
||||
|
@ -82,13 +82,13 @@ function! s:source.gather_candidates(args, context) "{{{
|
||||
return list
|
||||
endfunction "}}}
|
||||
|
||||
" Actions"{{{
|
||||
" Actions "{{{
|
||||
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) "{{{
|
||||
let cur_text = neosnippet#util#get_cur_text()
|
||||
let cur_keyword_str = matchstr(cur_text, '\S\+$')
|
||||
let context = unite#get_context()
|
||||
@ -102,7 +102,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) "{{{
|
||||
for snip in a:candidates
|
||||
echohl String
|
||||
echo snip.action__complete_word
|
||||
@ -118,7 +118,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) "{{{
|
||||
let trigger = unite#util#input('Please input snippet trigger: ')
|
||||
if trigger == ''
|
||||
echo 'Canceled.'
|
||||
@ -171,7 +171,7 @@ function! unite#sources#snippet#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) "{{{
|
||||
let cur_keyword_pos = match(a:cur_text, '\S\+$')
|
||||
if cur_keyword_pos < 0
|
||||
" Empty string.
|
||||
|
@ -70,11 +70,11 @@ function! s:source.gather_candidates(args, context) "{{{
|
||||
return list
|
||||
endfunction "}}}
|
||||
|
||||
" Actions"{{{
|
||||
" Actions "{{{
|
||||
let s:source.action_table.select = {
|
||||
\ 'description' : 'select targetted snippet',
|
||||
\ }
|
||||
function! s:source.action_table.select.func(candidate)"{{{
|
||||
function! s:source.action_table.select.func(candidate) "{{{
|
||||
let context = a:candidate.source__context
|
||||
if bufnr('%') != context.source__bufnr ||
|
||||
\ line('.') != context.source__linenr
|
||||
@ -105,7 +105,7 @@ function! unite#sources#snippet_target#start() "{{{
|
||||
\ { 'buffer_name' : 'snippet/target' })
|
||||
endfunction "}}}
|
||||
|
||||
function! s:get_keyword_pos(cur_text)"{{{
|
||||
function! s:get_keyword_pos(cur_text) "{{{
|
||||
let cur_keyword_pos = match(a:cur_text, '\S\+$')
|
||||
if cur_keyword_pos < 0
|
||||
" Empty string.
|
||||
|
@ -76,7 +76,7 @@ function! s:is_dict(Value)
|
||||
return type(a:Value) ==# s:__TYPE_DICT
|
||||
endfunction
|
||||
|
||||
function! s:truncate_smart(str, max, footer_width, separator)"{{{
|
||||
function! s:truncate_smart(str, max, footer_width, separator) "{{{
|
||||
let width = s:wcswidth(a:str)
|
||||
if width <= a:max
|
||||
let ret = a:str
|
||||
@ -89,7 +89,7 @@ function! s:truncate_smart(str, max, footer_width, separator)"{{{
|
||||
return s:truncate(ret, a:max)
|
||||
endfunction"}}}
|
||||
|
||||
function! s:truncate(str, width)"{{{
|
||||
function! s:truncate(str, width) "{{{
|
||||
" Original function is from mattn.
|
||||
" http://github.com/mattn/googlereader-vim/tree/master
|
||||
|
||||
@ -112,11 +112,11 @@ function! s:truncate(str, width)"{{{
|
||||
return ret
|
||||
endfunction"}}}
|
||||
|
||||
function! s:strchars(str)"{{{
|
||||
function! s:strchars(str) "{{{
|
||||
return len(substitute(a:str, '.', 'x', 'g'))
|
||||
endfunction"}}}
|
||||
|
||||
function! s:strwidthpart(str, width)"{{{
|
||||
function! s:strwidthpart(str, width) "{{{
|
||||
if a:width <= 0
|
||||
return ''
|
||||
endif
|
||||
@ -130,7 +130,7 @@ function! s:strwidthpart(str, width)"{{{
|
||||
|
||||
return ret
|
||||
endfunction"}}}
|
||||
function! s:strwidthpart_reverse(str, width)"{{{
|
||||
function! s:strwidthpart_reverse(str, width) "{{{
|
||||
if a:width <= 0
|
||||
return ''
|
||||
endif
|
||||
@ -147,11 +147,11 @@ endfunction"}}}
|
||||
|
||||
if v:version >= 703
|
||||
" Use builtin function.
|
||||
function! s:wcswidth(str)"{{{
|
||||
function! s:wcswidth(str) "{{{
|
||||
return strwidth(a:str)
|
||||
endfunction"}}}
|
||||
else
|
||||
function! s:wcswidth(str)"{{{
|
||||
function! s:wcswidth(str) "{{{
|
||||
if a:str =~# '^[\x00-\x7f]*$'
|
||||
return strlen(a:str)
|
||||
end
|
||||
@ -171,7 +171,7 @@ else
|
||||
endfunction"}}}
|
||||
|
||||
" UTF-8 only.
|
||||
function! s:_wcwidth(ucs)"{{{
|
||||
function! s:_wcwidth(ucs) "{{{
|
||||
let ucs = a:ucs
|
||||
if (ucs >= 0x1100
|
||||
\ && (ucs <= 0x115f
|
||||
@ -198,17 +198,17 @@ let s:is_cygwin = has('win32unix')
|
||||
let s:is_mac = !s:is_windows && !s:is_cygwin
|
||||
\ && (has('mac') || has('macunix') || has('gui_macvim') ||
|
||||
\ (!executable('xdg-open') && system('uname') =~? '^darwin'))
|
||||
function! s:is_windows()"{{{
|
||||
function! s:is_windows() "{{{
|
||||
return s:is_windows
|
||||
endfunction"}}}
|
||||
function! s:is_cygwin()"{{{
|
||||
function! s:is_cygwin() "{{{
|
||||
return s:is_cygwin
|
||||
endfunction"}}}
|
||||
function! s:is_mac()"{{{
|
||||
function! s:is_mac() "{{{
|
||||
return s:is_mac
|
||||
endfunction"}}}
|
||||
|
||||
function! s:print_error(message)"{{{
|
||||
function! s:print_error(message) "{{{
|
||||
echohl ErrorMsg
|
||||
for m in split(a:message, "\n")
|
||||
echomsg m
|
||||
@ -216,14 +216,14 @@ function! s:print_error(message)"{{{
|
||||
echohl None
|
||||
endfunction"}}}
|
||||
|
||||
function! s:smart_execute_command(action, word)"{{{
|
||||
function! s:smart_execute_command(action, word) "{{{
|
||||
execute a:action . ' ' . (a:word == '' ? '' : '`=a:word`')
|
||||
endfunction"}}}
|
||||
|
||||
function! s:escape_file_searching(buffer_name)"{{{
|
||||
function! s:escape_file_searching(buffer_name) "{{{
|
||||
return escape(a:buffer_name, '*[]?{}, ')
|
||||
endfunction"}}}
|
||||
function! s:escape_pattern(str)"{{{
|
||||
function! s:escape_pattern(str) "{{{
|
||||
return escape(a:str, '~"\.^$[]*')
|
||||
endfunction"}}}
|
||||
" iconv() wrapper for safety.
|
||||
@ -270,20 +270,20 @@ function! s:set_default(var, val) "{{{
|
||||
let {a:var} = a:val
|
||||
endif
|
||||
endfunction"}}}
|
||||
function! s:set_dictionary_helper(variable, keys, pattern)"{{{
|
||||
function! s:set_dictionary_helper(variable, keys, pattern) "{{{
|
||||
for key in split(a:keys, '\s*,\s*')
|
||||
if !has_key(a:variable, key)
|
||||
let a:variable[key] = a:pattern
|
||||
endif
|
||||
endfor
|
||||
endfunction"}}}
|
||||
function! s:substitute_path_separator(path)"{{{
|
||||
function! s:substitute_path_separator(path) "{{{
|
||||
return s:is_windows ? substitute(a:path, '\\', '/', 'g') : a:path
|
||||
endfunction"}}}
|
||||
function! s:path2directory(path)"{{{
|
||||
function! s:path2directory(path) "{{{
|
||||
return s:substitute_path_separator(isdirectory(a:path) ? a:path : fnamemodify(a:path, ':p:h'))
|
||||
endfunction"}}}
|
||||
function! s:path2project_directory(path, ...)"{{{
|
||||
function! s:path2project_directory(path, ...) "{{{
|
||||
let is_allow_empty = get(a:000, 0, 0)
|
||||
let search_directory = s:path2directory(a:path)
|
||||
let directory = ''
|
||||
@ -324,8 +324,8 @@ function! s:path2project_directory(path, ...)"{{{
|
||||
|
||||
return s:substitute_path_separator(directory)
|
||||
endfunction"}}}
|
||||
" Check vimproc."{{{
|
||||
function! s:has_vimproc()"{{{
|
||||
" Check vimproc. "{{{
|
||||
function! s:has_vimproc() "{{{
|
||||
if !exists('s:exists_vimproc')
|
||||
try
|
||||
call vimproc#version()
|
||||
@ -337,7 +337,7 @@ function! s:has_vimproc()"{{{
|
||||
return s:exists_vimproc
|
||||
endfunction"}}}
|
||||
"}}}
|
||||
function! s:system(str, ...)"{{{
|
||||
function! s:system(str, ...) "{{{
|
||||
let command = a:str
|
||||
let input = a:0 >= 1 ? a:1 : ''
|
||||
let command = s:iconv(command, &encoding, 'char')
|
||||
@ -359,7 +359,7 @@ function! s:system(str, ...)"{{{
|
||||
|
||||
return output
|
||||
endfunction"}}}
|
||||
function! s:get_last_status()"{{{
|
||||
function! s:get_last_status() "{{{
|
||||
return s:has_vimproc() ?
|
||||
\ vimproc#get_last_status() : v:shell_error
|
||||
endfunction"}}}
|
||||
|
@ -39,7 +39,7 @@ endif
|
||||
|
||||
setlocal indentexpr=SnippetsIndent()
|
||||
|
||||
function! SnippetsIndent()"{{{
|
||||
function! SnippetsIndent() "{{{
|
||||
let line = getline('.')
|
||||
let prev_line = (line('.') == 1)? '' : getline(line('.')-1)
|
||||
|
||||
|
@ -34,10 +34,10 @@ endif
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
" Obsolute options check."{{{
|
||||
" Obsolute options check. "{{{
|
||||
"}}}
|
||||
|
||||
" Plugin key-mappings."{{{
|
||||
" Plugin key-mappings. "{{{
|
||||
inoremap <silent><expr> <Plug>(neosnippet_expand_or_jump)
|
||||
\ neosnippet#expand_or_jump_impl()
|
||||
inoremap <silent><expr> <Plug>(neosnippet_jump_or_expand)
|
||||
@ -88,7 +88,7 @@ inoremap <expr><silent> <Plug>(neosnippet_start_unite_snippet)
|
||||
\ unite#sources#snippet#start_complete()
|
||||
"}}}
|
||||
|
||||
augroup neosnippet"{{{
|
||||
augroup neosnippet "{{{
|
||||
autocmd!
|
||||
" Set caching event.
|
||||
autocmd FileType * call neosnippet#caching()
|
||||
@ -99,7 +99,7 @@ augroup neosnippet"{{{
|
||||
\ call neosnippet#clear_select_mode_mappings()
|
||||
augroup END"}}}
|
||||
|
||||
" Commands."{{{
|
||||
" Commands. "{{{
|
||||
command! -nargs=? -complete=customlist,neosnippet#edit_complete
|
||||
\ NeoSnippetEdit
|
||||
\ call neosnippet#edit_snippets(<q-args>)
|
||||
|
Loading…
Reference in New Issue
Block a user