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