Remove markers

This commit is contained in:
Shougo Matsushita 2017-10-01 22:40:17 +09:00
parent c86a19b06a
commit ddd01d0ee3
15 changed files with 312 additions and 342 deletions

View File

@ -11,15 +11,15 @@ let s:source = {
\ g:neocomplcache_auto_completion_start_length, \ g:neocomplcache_auto_completion_start_length,
\} \}
function! s:source.initialize() abort "{{{ function! s:source.initialize() abort
" Initialize. " Initialize.
call neocomplcache#set_dictionary_helper( call neocomplcache#set_dictionary_helper(
\ g:neocomplcache_source_rank, 'snippets_complete', 8) \ g:neocomplcache_source_rank, 'snippets_complete', 8)
call neocomplcache#set_completion_length('snippets_complete', call neocomplcache#set_completion_length('snippets_complete',
\ g:neocomplcache_auto_completion_start_length) \ g:neocomplcache_auto_completion_start_length)
endfunction"}}} endfunction
function! s:source.get_keyword_pos(cur_text) abort "{{{ function! s:source.get_keyword_pos(cur_text) abort
let cur_word = matchstr(a:cur_text, '\w\+$') let cur_word = matchstr(a:cur_text, '\w\+$')
let word_candidates = neocomplcache#keyword_filter( let word_candidates = neocomplcache#keyword_filter(
\ filter(values(neosnippet#helpers#get_snippets()), \ filter(values(neosnippet#helpers#get_snippets()),
@ -29,9 +29,9 @@ function! s:source.get_keyword_pos(cur_text) abort "{{{
endif endif
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) abort "{{{ function! s:source.get_complete_words(cur_keyword_pos, cur_keyword_str) abort
let list = s:keyword_filter(neosnippet#helpers#get_snippets(), a:cur_keyword_str) let list = s:keyword_filter(neosnippet#helpers#get_snippets(), a:cur_keyword_str)
for snippet in list for snippet in list
@ -42,9 +42,9 @@ function! s:source.get_complete_words(cur_keyword_pos, cur_keyword_str) abort "{
endfor endfor
return list return list
endfunction"}}} endfunction
function! s:keyword_filter(snippets, cur_keyword_str) abort "{{{ function! s:keyword_filter(snippets, cur_keyword_str) abort
" Uniq by real_name. " Uniq by real_name.
let dict = {} let dict = {}
@ -65,10 +65,8 @@ function! s:keyword_filter(snippets, cur_keyword_str) abort "{{{
endfor endfor
return values(dict) return values(dict)
endfunction"}}} endfunction
function! neocomplcache#sources#snippets_complete#define() abort "{{{ function! neocomplcache#sources#snippets_complete#define() abort
return s:source return s:source
endfunction"}}} endfunction
" vim: foldmethod=marker

View File

@ -15,7 +15,7 @@ let s:source = {
\ ['matcher_fuzzy'] : ['matcher_head']), \ ['matcher_fuzzy'] : ['matcher_head']),
\} \}
function! s:source.gather_candidates(context) abort "{{{ function! s:source.gather_candidates(context) abort
let snippets = values(neosnippet#helpers#get_completion_snippets()) let snippets = values(neosnippet#helpers#get_completion_snippets())
if matchstr(a:context.input, '\S\+$') !=# if matchstr(a:context.input, '\S\+$') !=#
\ matchstr(a:context.input, '\w\+$') \ matchstr(a:context.input, '\w\+$')
@ -23,9 +23,9 @@ function! s:source.gather_candidates(context) abort "{{{
call filter(snippets, 'v:val.options.word') call filter(snippets, 'v:val.options.word')
endif endif
return snippets return snippets
endfunction"}}} endfunction
function! s:source.hooks.on_post_filter(context) abort "{{{ function! s:source.hooks.on_post_filter(context) abort
for snippet in a:context.candidates for snippet in a:context.candidates
let snippet.dup = 1 let snippet.dup = 1
let snippet.menu = neosnippet#util#strwidthpart( let snippet.menu = neosnippet#util#strwidthpart(
@ -33,10 +33,8 @@ function! s:source.hooks.on_post_filter(context) abort "{{{
endfor endfor
return a:context.candidates return a:context.candidates
endfunction"}}} endfunction
function! neocomplete#sources#neosnippet#define() abort "{{{ function! neocomplete#sources#neosnippet#define() abort
return s:source return s:source
endfunction"}}} endfunction
" vim: foldmethod=marker

View File

@ -4,7 +4,7 @@
" License: MIT license " License: MIT license
"============================================================================= "=============================================================================
" 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(
@ -31,64 +31,62 @@ call neosnippet#util#set_default(
call neosnippet#util#set_default( call neosnippet#util#set_default(
\ 'g:neosnippet#_completed_pairs', \ 'g:neosnippet#_completed_pairs',
\ {'_':{ '(' : ')', '{' : '}', '"' : '"', '[' : ']' }}) \ {'_':{ '(' : ')', '{' : '}', '"' : '"', '[' : ']' }})
"}}}
function! neosnippet#expandable_or_jumpable() abort "{{{
function! neosnippet#expandable_or_jumpable() abort
return neosnippet#mappings#expandable_or_jumpable() return neosnippet#mappings#expandable_or_jumpable()
endfunction"}}} endfunction
function! neosnippet#expandable() abort "{{{ function! neosnippet#expandable() abort
return neosnippet#mappings#expandable() return neosnippet#mappings#expandable()
endfunction"}}} endfunction
function! neosnippet#jumpable() abort "{{{ function! neosnippet#jumpable() abort
return neosnippet#mappings#jumpable() return neosnippet#mappings#jumpable()
endfunction"}}} endfunction
function! neosnippet#anonymous(snippet) abort "{{{ function! neosnippet#anonymous(snippet) abort
return neosnippet#mappings#_anonymous(a:snippet) return neosnippet#mappings#_anonymous(a:snippet)
endfunction"}}} endfunction
function! neosnippet#expand(trigger) abort "{{{ function! neosnippet#expand(trigger) abort
return neosnippet#mappings#_expand(a:trigger) return neosnippet#mappings#_expand(a:trigger)
endfunction"}}} endfunction
function! neosnippet#get_snippets_directory() abort "{{{ function! neosnippet#get_snippets_directory() abort
return neosnippet#helpers#get_snippets_directory() return neosnippet#helpers#get_snippets_directory()
endfunction"}}} endfunction
function! neosnippet#get_user_snippets_directory() abort "{{{ function! neosnippet#get_user_snippets_directory() abort
return copy(neosnippet#variables#snippets_dir()) return copy(neosnippet#variables#snippets_dir())
endfunction"}}} endfunction
function! neosnippet#get_runtime_snippets_directory() abort "{{{ function! neosnippet#get_runtime_snippets_directory() abort
return copy(neosnippet#variables#runtime_dir()) return copy(neosnippet#variables#runtime_dir())
endfunction"}}} endfunction
" Get marker patterns. " Get marker patterns.
function! neosnippet#get_placeholder_target_marker_pattern() abort "{{{ function! neosnippet#get_placeholder_target_marker_pattern() abort
return '\%(\\\@<!\|\\\\\zs\)\${\d\+:\(#:\)\?TARGET\%(:.\{-}\)\?\\\@<!}' return '\%(\\\@<!\|\\\\\zs\)\${\d\+:\(#:\)\?TARGET\%(:.\{-}\)\?\\\@<!}'
endfunction"}}} endfunction
function! neosnippet#get_placeholder_marker_pattern() abort "{{{ function! neosnippet#get_placeholder_marker_pattern() abort
return '<`\d\+\%(:.\{-}\)\?\\\@<!`>' return '<`\d\+\%(:.\{-}\)\?\\\@<!`>'
endfunction"}}} endfunction
function! neosnippet#get_placeholder_marker_substitute_pattern() abort "{{{ function! neosnippet#get_placeholder_marker_substitute_pattern() abort
return '\%(\\\@<!\|\\\\\zs\)\${\(\d\+\%(:.\{-}\)\?\\\@<!\)}' return '\%(\\\@<!\|\\\\\zs\)\${\(\d\+\%(:.\{-}\)\?\\\@<!\)}'
endfunction"}}} endfunction
function! neosnippet#get_placeholder_marker_substitute_nonzero_pattern() abort "{{{ function! neosnippet#get_placeholder_marker_substitute_nonzero_pattern() abort
return '\%(\\\@<!\|\\\\\zs\)\${\([1-9]\d*\%(:.\{-}\)\?\\\@<!\)}' return '\%(\\\@<!\|\\\\\zs\)\${\([1-9]\d*\%(:.\{-}\)\?\\\@<!\)}'
endfunction"}}} endfunction
function! neosnippet#get_placeholder_marker_substitute_zero_pattern() abort "{{{ function! neosnippet#get_placeholder_marker_substitute_zero_pattern() abort
return '\%(\\\@<!\|\\\\\zs\)\${\(0\%(:.\{-}\)\?\\\@<!\)}' return '\%(\\\@<!\|\\\\\zs\)\${\(0\%(:.\{-}\)\?\\\@<!\)}'
endfunction"}}} endfunction
function! neosnippet#get_placeholder_marker_default_pattern() abort "{{{ function! neosnippet#get_placeholder_marker_default_pattern() abort
return '<`\d\+:\zs.\{-}\ze\\\@<!`>' return '<`\d\+:\zs.\{-}\ze\\\@<!`>'
endfunction"}}} endfunction
function! neosnippet#get_sync_placeholder_marker_pattern() abort "{{{ function! neosnippet#get_sync_placeholder_marker_pattern() abort
return '<{\d\+\%(:.\{-}\)\?\\\@<!}>' return '<{\d\+\%(:.\{-}\)\?\\\@<!}>'
endfunction"}}} endfunction
function! neosnippet#get_sync_placeholder_marker_default_pattern() abort "{{{ function! neosnippet#get_sync_placeholder_marker_default_pattern() abort
return '<{\d\+:\zs.\{-}\ze\\\@<!}>' return '<{\d\+:\zs.\{-}\ze\\\@<!}>'
endfunction"}}} endfunction
function! neosnippet#get_mirror_placeholder_marker_pattern() abort "{{{ function! neosnippet#get_mirror_placeholder_marker_pattern() abort
return '<|\d\+|>' return '<|\d\+|>'
endfunction"}}} endfunction
function! neosnippet#get_mirror_placeholder_marker_substitute_pattern() abort "{{{ function! neosnippet#get_mirror_placeholder_marker_substitute_pattern() abort
return '\\\@<!\$\(\d\+\)' return '\\\@<!\$\(\d\+\)'
endfunction"}}} endfunction
" vim: foldmethod=marker

View File

@ -4,22 +4,22 @@
" License: MIT license " License: MIT license
"============================================================================= "=============================================================================
" Variables "{{{ " Variables
let s:edit_options = [ let s:edit_options = [
\ '-runtime', \ '-runtime',
\ '-vertical', '-horizontal', '-direction=', '-split', \ '-vertical', '-horizontal', '-direction=', '-split',
\] \]
let s:Cache = neosnippet#util#get_vital().import('System.Cache.Deprecated') let s:Cache = neosnippet#util#get_vital().import('System.Cache.Deprecated')
"}}}
function! s:get_list() abort "{{{
function! s:get_list() abort
if !exists('s:List') if !exists('s:List')
let s:List = vital#of('neosnippet').import('Data.List') let s:List = vital#of('neosnippet').import('Data.List')
endif endif
return s:List return s:List
endfunction"}}} endfunction
function! neosnippet#commands#_edit(args) abort "{{{ function! neosnippet#commands#_edit(args) abort
if neosnippet#util#is_sudo() if neosnippet#util#is_sudo()
call neosnippet#util#print_error( call neosnippet#util#print_error(
\ '"sudo vim" is detected. This feature is disabled.') \ '"sudo vim" is detected. This feature is disabled.')
@ -72,9 +72,9 @@ function! neosnippet#commands#_edit(args) abort "{{{
execute 'edit' fnameescape(filename) execute 'edit' fnameescape(filename)
catch /^Vim\%((\a\+)\)\=:E749/ catch /^Vim\%((\a\+)\)\=:E749/
endtry endtry
endfunction"}}} endfunction
function! neosnippet#commands#_make_cache(filetype) abort "{{{ function! neosnippet#commands#_make_cache(filetype) abort
call neosnippet#init#check() call neosnippet#init#check()
let filetype = a:filetype == '' ? let filetype = a:filetype == '' ?
@ -108,17 +108,17 @@ function! neosnippet#commands#_make_cache(filetype) abort "{{{
\ neosnippet#parser#_parse_snippet(filename, trigger) \ neosnippet#parser#_parse_snippet(filename, trigger)
endfor endfor
endif endif
endfunction"}}} endfunction
function! neosnippet#commands#_source(filename) abort "{{{ function! neosnippet#commands#_source(filename) abort
call neosnippet#init#check() call neosnippet#init#check()
let neosnippet = neosnippet#variables#current_neosnippet() let neosnippet = neosnippet#variables#current_neosnippet()
let neosnippet.snippets = extend(neosnippet.snippets, let neosnippet.snippets = extend(neosnippet.snippets,
\ neosnippet#parser#_parse_snippets(a:filename)) \ neosnippet#parser#_parse_snippets(a:filename))
endfunction"}}} endfunction
function! neosnippet#commands#_clear_markers() abort "{{{ function! neosnippet#commands#_clear_markers() abort
let expand_stack = neosnippet#variables#expand_stack() let expand_stack = neosnippet#variables#expand_stack()
" Get patterns and count. " Get patterns and count.
@ -129,15 +129,15 @@ function! neosnippet#commands#_clear_markers() abort "{{{
endif endif
call neosnippet#view#_clear_markers(expand_stack[-1]) call neosnippet#view#_clear_markers(expand_stack[-1])
endfunction"}}} endfunction
" Complete helpers. " Complete helpers.
function! neosnippet#commands#_edit_complete(arglead, cmdline, cursorpos) abort "{{{ function! neosnippet#commands#_edit_complete(arglead, cmdline, cursorpos) abort
return filter(s:edit_options + return filter(s:edit_options +
\ neosnippet#commands#_filetype_complete(a:arglead, a:cmdline, a:cursorpos), \ neosnippet#commands#_filetype_complete(a:arglead, a:cmdline, a:cursorpos),
\ 'stridx(v:val, a:arglead) == 0') \ 'stridx(v:val, a:arglead) == 0')
endfunction"}}} endfunction
function! neosnippet#commands#_filetype_complete(arglead, cmdline, cursorpos) abort "{{{ function! neosnippet#commands#_filetype_complete(arglead, cmdline, cursorpos) abort
" Dup check. " Dup check.
let ret = {} let ret = {}
for item in map( for item in map(
@ -151,14 +151,14 @@ function! neosnippet#commands#_filetype_complete(arglead, cmdline, cursorpos) ab
endfor endfor
return sort(keys(ret)) return sort(keys(ret))
endfunction"}}} endfunction
function! neosnippet#commands#_complete_target_snippets(arglead, cmdline, cursorpos) abort "{{{ function! neosnippet#commands#_complete_target_snippets(arglead, cmdline, cursorpos) abort
return map(filter(values(neosnippet#helpers#get_snippets()), return map(filter(values(neosnippet#helpers#get_snippets()),
\ "stridx(v:val.word, a:arglead) == 0 \ "stridx(v:val.word, a:arglead) == 0
\ && v:val.snip =~# neosnippet#get_placeholder_target_marker_pattern()"), 'v:val.word') \ && v:val.snip =~# neosnippet#get_placeholder_target_marker_pattern()"), 'v:val.word')
endfunction"}}} endfunction
function! s:initialize_options(options) abort "{{{ function! s:initialize_options(options) abort
let default_options = { let default_options = {
\ 'runtime' : 0, \ 'runtime' : 0,
\ 'vertical' : 0, \ 'vertical' : 0,
@ -175,9 +175,9 @@ function! s:initialize_options(options) abort "{{{
endif endif
return options return options
endfunction"}}} endfunction
function! s:get_snippets_files(path, filetype) abort "{{{ function! s:get_snippets_files(path, filetype) abort
let snippets_files = [] let snippets_files = []
for glob in s:get_list().flatten( for glob in s:get_list().flatten(
\ map(split(get(g:neosnippet#scope_aliases, \ map(split(get(g:neosnippet#scope_aliases,
@ -190,8 +190,8 @@ function! s:get_snippets_files(path, filetype) abort "{{{
let snippets_files += split(globpath(a:path, glob), '\n') let snippets_files += split(globpath(a:path, glob), '\n')
endfor endfor
return reverse(s:get_list().uniq(snippets_files)) return reverse(s:get_list().uniq(snippets_files))
endfunction"}}} endfunction
function! s:get_snippet_files(path, filetype) abort "{{{ function! s:get_snippet_files(path, filetype) abort
let snippet_files = [] let snippet_files = []
for glob in s:get_list().flatten( for glob in s:get_list().flatten(
\ map(split(get(g:neosnippet#scope_aliases, \ map(split(get(g:neosnippet#scope_aliases,
@ -200,6 +200,4 @@ function! s:get_snippet_files(path, filetype) abort "{{{
let snippet_files += split(globpath(a:path, glob), '\n') let snippet_files += split(globpath(a:path, glob), '\n')
endfor endfor
return reverse(s:get_list().uniq(snippet_files)) return reverse(s:get_list().uniq(snippet_files))
endfunction"}}} endfunction
" vim: foldmethod=marker

View File

@ -4,7 +4,7 @@
" License: MIT license " License: MIT license
"============================================================================= "=============================================================================
function! neosnippet#handlers#_cursor_moved() abort "{{{ function! neosnippet#handlers#_cursor_moved() abort
let expand_stack = neosnippet#variables#expand_stack() let expand_stack = neosnippet#variables#expand_stack()
" Get patterns and count. " Get patterns and count.
@ -18,9 +18,9 @@ function! neosnippet#handlers#_cursor_moved() abort "{{{
\ && line('.') != expand_info.begin_line \ && line('.') != expand_info.begin_line
call neosnippet#view#_clear_markers(expand_info) call neosnippet#view#_clear_markers(expand_info)
endif endif
endfunction"}}} endfunction
function! neosnippet#handlers#_all_clear_markers() abort "{{{ function! neosnippet#handlers#_all_clear_markers() abort
if !&l:modifiable if !&l:modifiable
return return
endif endif
@ -36,9 +36,9 @@ function! neosnippet#handlers#_all_clear_markers() abort "{{{
finally finally
call setpos('.', pos) call setpos('.', pos)
endtry endtry
endfunction"}}} endfunction
function! neosnippet#handlers#_restore_unnamed_register() abort "{{{ function! neosnippet#handlers#_restore_unnamed_register() abort
let neosnippet = neosnippet#variables#current_neosnippet() let neosnippet = neosnippet#variables#current_neosnippet()
if neosnippet.unnamed_register != '' if neosnippet.unnamed_register != ''
@ -46,6 +46,4 @@ function! neosnippet#handlers#_restore_unnamed_register() abort "{{{
let @" = neosnippet.unnamed_register let @" = neosnippet.unnamed_register
let neosnippet.unnamed_register = '' let neosnippet.unnamed_register = ''
endif endif
endfunction"}}} endfunction
" vim: foldmethod=marker

View File

@ -4,7 +4,7 @@
" License: MIT license " License: MIT license
"============================================================================= "=============================================================================
function! neosnippet#helpers#get_cursor_snippet(snippets, cur_text) abort "{{{ function! neosnippet#helpers#get_cursor_snippet(snippets, cur_text) abort
let cur_word = matchstr(a:cur_text, '\S\+$') let cur_word = matchstr(a:cur_text, '\S\+$')
if cur_word != '' && has_key(a:snippets, cur_word) if cur_word != '' && has_key(a:snippets, cur_word)
return cur_word return cur_word
@ -20,9 +20,9 @@ function! neosnippet#helpers#get_cursor_snippet(snippets, cur_text) abort "{{{
endwhile endwhile
return cur_word return cur_word
endfunction"}}} endfunction
function! neosnippet#helpers#get_snippets(...) abort "{{{ function! neosnippet#helpers#get_snippets(...) abort
let mode = get(a:000, 0, mode()) let mode = get(a:000, 0, mode())
call neosnippet#init#check() call neosnippet#init#check()
@ -51,13 +51,13 @@ function! neosnippet#helpers#get_snippets(...) abort "{{{
endif endif
return snippets return snippets
endfunction"}}} endfunction
function! neosnippet#helpers#get_completion_snippets() abort "{{{ function! neosnippet#helpers#get_completion_snippets() abort
return filter(neosnippet#helpers#get_snippets(), return filter(neosnippet#helpers#get_snippets(),
\ "!get(v:val.options, 'oneshot', 0)") \ "!get(v:val.options, 'oneshot', 0)")
endfunction"}}} endfunction
function! neosnippet#helpers#get_snippets_directory() abort "{{{ function! neosnippet#helpers#get_snippets_directory() abort
let snippets_dir = copy(neosnippet#variables#snippets_dir()) let snippets_dir = copy(neosnippet#variables#snippets_dir())
if !get(g:neosnippet#disable_runtime_snippets, if !get(g:neosnippet#disable_runtime_snippets,
\ neosnippet#helpers#get_filetype(), \ neosnippet#helpers#get_filetype(),
@ -66,9 +66,9 @@ function! neosnippet#helpers#get_snippets_directory() abort "{{{
endif endif
return snippets_dir return snippets_dir
endfunction"}}} endfunction
function! neosnippet#helpers#get_filetype() abort "{{{ function! neosnippet#helpers#get_filetype() abort
" context_filetype.vim installation check. " context_filetype.vim installation check.
if !exists('s:exists_context_filetype') if !exists('s:exists_context_filetype')
silent! call context_filetype#version() silent! call context_filetype#version()
@ -83,9 +83,9 @@ function! neosnippet#helpers#get_filetype() abort "{{{
endif endif
return context_filetype return context_filetype
endfunction"}}} endfunction
function! neosnippet#helpers#get_selected_text(type, ...) abort "{{{ function! neosnippet#helpers#get_selected_text(type, ...) abort
let sel_save = &selection let sel_save = &selection
let &selection = 'inclusive' let &selection = 'inclusive'
let reg_save = @@ let reg_save = @@
@ -109,8 +109,8 @@ function! neosnippet#helpers#get_selected_text(type, ...) abort "{{{
let @@ = reg_save let @@ = reg_save
call setpos('.', pos) call setpos('.', pos)
endtry endtry
endfunction"}}} endfunction
function! neosnippet#helpers#delete_selected_text(type, ...) abort "{{{ function! neosnippet#helpers#delete_selected_text(type, ...) abort
let sel_save = &selection let sel_save = &selection
let &selection = 'inclusive' let &selection = 'inclusive'
let reg_save = @@ let reg_save = @@
@ -132,8 +132,8 @@ function! neosnippet#helpers#delete_selected_text(type, ...) abort "{{{
let @@ = reg_save let @@ = reg_save
call setpos('.', pos) call setpos('.', pos)
endtry endtry
endfunction"}}} endfunction
function! neosnippet#helpers#substitute_selected_text(type, text) abort "{{{ function! neosnippet#helpers#substitute_selected_text(type, text) abort
let sel_save = &selection let sel_save = &selection
let &selection = 'inclusive' let &selection = 'inclusive'
let reg_save = @@ let reg_save = @@
@ -155,30 +155,28 @@ function! neosnippet#helpers#substitute_selected_text(type, text) abort "{{{
let @@ = reg_save let @@ = reg_save
call setpos('.', pos) call setpos('.', pos)
endtry endtry
endfunction"}}} endfunction
function! neosnippet#helpers#vim2json(expr) abort "{{{ function! neosnippet#helpers#vim2json(expr) abort
return has('patch-7.4.1498') ? json_encode(a:expr) : string(a:expr) return has('patch-7.4.1498') ? json_encode(a:expr) : string(a:expr)
endfunction "}}} endfunction
function! neosnippet#helpers#json2vim(expr) abort "{{{ function! neosnippet#helpers#json2vim(expr) abort
sandbox return has('patch-7.4.1498') ? json_decode(a:expr) : eval(a:expr) sandbox return has('patch-7.4.1498') ? json_decode(a:expr) : eval(a:expr)
endfunction "}}} endfunction
function! s:is_beginning_of_line(cur_text) abort "{{{ function! s:is_beginning_of_line(cur_text) abort
let keyword_pattern = '\S\+' let keyword_pattern = '\S\+'
let cur_keyword_str = matchstr(a:cur_text, keyword_pattern.'$') let cur_keyword_str = matchstr(a:cur_text, keyword_pattern.'$')
let line_part = a:cur_text[: -1-len(cur_keyword_str)] let line_part = a:cur_text[: -1-len(cur_keyword_str)]
let prev_word_end = matchend(line_part, keyword_pattern) let prev_word_end = matchend(line_part, keyword_pattern)
return prev_word_end <= 0 return prev_word_end <= 0
endfunction"}}} endfunction
function! s:get_sources_filetypes(filetype) abort "{{{ function! s:get_sources_filetypes(filetype) abort
let filetypes = let filetypes =
\ exists('*context_filetype#get_filetypes') ? \ exists('*context_filetype#get_filetypes') ?
\ context_filetype#get_filetypes(a:filetype) : \ context_filetype#get_filetypes(a:filetype) :
\ split(((a:filetype == '') ? 'nothing' : a:filetype), '\.') \ split(((a:filetype == '') ? 'nothing' : a:filetype), '\.')
return neosnippet#util#uniq(['_'] + filetypes + [a:filetype]) return neosnippet#util#uniq(['_'] + filetypes + [a:filetype])
endfunction"}}} endfunction
" vim: foldmethod=marker

View File

@ -4,28 +4,28 @@
" License: MIT license " License: MIT license
"============================================================================= "=============================================================================
function! neosnippet#init#_initialize() abort "{{{ function! neosnippet#init#_initialize() abort
let s:is_initialized = 1 let s:is_initialized = 1
call s:initialize_others() call s:initialize_others()
call s:initialize_cache() call s:initialize_cache()
endfunction"}}} endfunction
function! neosnippet#init#check() abort "{{{ function! neosnippet#init#check() abort
if !exists('s:is_initialized') if !exists('s:is_initialized')
call neosnippet#init#_initialize() call neosnippet#init#_initialize()
endif endif
endfunction"}}} endfunction
function! s:initialize_cache() abort "{{{ function! s:initialize_cache() abort
" Make cache for _ snippets. " Make cache for _ snippets.
call neosnippet#commands#_make_cache('_') call neosnippet#commands#_make_cache('_')
" Initialize check. " Initialize check.
call neosnippet#commands#_make_cache(&filetype) call neosnippet#commands#_make_cache(&filetype)
endfunction"}}} endfunction
function! s:initialize_others() abort "{{{ function! s:initialize_others() abort
augroup neosnippet "{{{ augroup neosnippet
autocmd! autocmd!
" Set make cache event. " Set make cache event.
autocmd FileType * autocmd FileType *
@ -35,7 +35,7 @@ function! s:initialize_others() abort "{{{
\ call neosnippet#variables#set_snippets({}) \ call neosnippet#variables#set_snippets({})
autocmd BufEnter * autocmd BufEnter *
\ call neosnippet#mappings#_clear_select_mode_mappings() \ call neosnippet#mappings#_clear_select_mode_mappings()
augroup END"}}} augroup END
if g:neosnippet#enable_auto_clear_markers if g:neosnippet#enable_auto_clear_markers
autocmd neosnippet CursorMoved,CursorMovedI * autocmd neosnippet CursorMoved,CursorMovedI *
@ -72,7 +72,7 @@ function! s:initialize_others() abort "{{{
call neosnippet#mappings#_clear_select_mode_mappings() call neosnippet#mappings#_clear_select_mode_mappings()
if g:neosnippet#enable_snipmate_compatibility "{{{ if g:neosnippet#enable_snipmate_compatibility
" For snipMate function. " For snipMate function.
function! Filename(...) abort function! Filename(...) abort
let filename = expand('%:t:r') let filename = expand('%:t:r')
@ -84,7 +84,5 @@ function! s:initialize_others() abort "{{{
return substitute(a:1, '$1', filename, 'g') return substitute(a:1, '$1', filename, 'g')
endif endif
endfunction endfunction
endif"}}} endif
endfunction"}}} endfunction
" vim: foldmethod=marker

View File

@ -4,22 +4,22 @@
" License: MIT license " License: MIT license
"============================================================================= "=============================================================================
function! neosnippet#mappings#expandable_or_jumpable() abort "{{{ function! neosnippet#mappings#expandable_or_jumpable() abort
return neosnippet#mappings#expandable() || neosnippet#mappings#jumpable() return neosnippet#mappings#expandable() || neosnippet#mappings#jumpable()
endfunction"}}} endfunction
function! neosnippet#mappings#expandable() abort "{{{ function! neosnippet#mappings#expandable() abort
" Check snippet trigger. " Check snippet trigger.
return neosnippet#mappings#completed_expandable() return neosnippet#mappings#completed_expandable()
\ || neosnippet#helpers#get_cursor_snippet( \ || neosnippet#helpers#get_cursor_snippet(
\ neosnippet#helpers#get_snippets('i'), \ neosnippet#helpers#get_snippets('i'),
\ neosnippet#util#get_cur_text()) != '' \ neosnippet#util#get_cur_text()) != ''
endfunction"}}} endfunction
function! neosnippet#mappings#jumpable() abort "{{{ function! neosnippet#mappings#jumpable() abort
" Found snippet placeholder. " Found snippet placeholder.
return search(neosnippet#get_placeholder_marker_pattern(). '\|' return search(neosnippet#get_placeholder_marker_pattern(). '\|'
\ .neosnippet#get_sync_placeholder_marker_pattern(), 'nw') > 0 \ .neosnippet#get_sync_placeholder_marker_pattern(), 'nw') > 0
endfunction"}}} endfunction
function! neosnippet#mappings#completed_expandable() abort "{{{ function! neosnippet#mappings#completed_expandable() abort
if !s:enabled_completed_snippet() if !s:enabled_completed_snippet()
return 0 return 0
endif endif
@ -28,14 +28,14 @@ function! neosnippet#mappings#completed_expandable() abort "{{{
\ v:completed_item, neosnippet#util#get_cur_text(), \ v:completed_item, neosnippet#util#get_cur_text(),
\ neosnippet#util#get_next_text()) \ neosnippet#util#get_next_text())
return snippet != '' return snippet != ''
endfunction"}}} endfunction
function! s:enabled_completed_snippet() abort "{{{ function! s:enabled_completed_snippet() abort
return exists('v:completed_item') return exists('v:completed_item')
\ && !empty(v:completed_item) \ && !empty(v:completed_item)
\ && g:neosnippet#enable_completed_snippet \ && g:neosnippet#enable_completed_snippet
endfunction"}}} endfunction
function! neosnippet#mappings#_clear_select_mode_mappings() abort "{{{ function! neosnippet#mappings#_clear_select_mode_mappings() abort
if !g:neosnippet#disable_select_mode_mappings if !g:neosnippet#disable_select_mode_mappings
return return
endif endif
@ -56,9 +56,9 @@ function! neosnippet#mappings#_clear_select_mode_mappings() abort "{{{
snoremap <BS> a<BS> snoremap <BS> a<BS>
snoremap <Del> a<BS> snoremap <Del> a<BS>
snoremap <C-h> a<BS> snoremap <C-h> a<BS>
endfunction"}}} endfunction
function! neosnippet#mappings#_register_oneshot_snippet() abort "{{{ function! neosnippet#mappings#_register_oneshot_snippet() abort
let trigger = input('Please input snippet trigger: ', 'oneshot') let trigger = input('Please input snippet trigger: ', 'oneshot')
if trigger == '' if trigger == ''
return return
@ -84,9 +84,9 @@ function! neosnippet#mappings#_register_oneshot_snippet() abort "{{{
\ '', 0, '', trigger) \ '', 0, '', trigger)
echo 'Registered trigger : ' . trigger echo 'Registered trigger : ' . trigger
endfunction"}}} endfunction
function! neosnippet#mappings#_expand_target() abort "{{{ function! neosnippet#mappings#_expand_target() abort
let trigger = input('Please input snippet trigger: ', let trigger = input('Please input snippet trigger: ',
\ '', 'customlist,neosnippet#commands#_complete_target_snippets') \ '', 'customlist,neosnippet#commands#_complete_target_snippets')
let neosnippet = neosnippet#variables#current_neosnippet() let neosnippet = neosnippet#variables#current_neosnippet()
@ -102,8 +102,8 @@ function! neosnippet#mappings#_expand_target() abort "{{{
endif endif
call neosnippet#mappings#_expand_target_trigger(trigger) call neosnippet#mappings#_expand_target_trigger(trigger)
endfunction"}}} endfunction
function! neosnippet#mappings#_expand_target_trigger(trigger) abort "{{{ function! neosnippet#mappings#_expand_target_trigger(trigger) abort
let neosnippet = neosnippet#variables#current_neosnippet() let neosnippet = neosnippet#variables#current_neosnippet()
let neosnippet.target = substitute( let neosnippet.target = substitute(
\ neosnippet#helpers#get_selected_text(visualmode(), 1), '\n$', '', '') \ neosnippet#helpers#get_selected_text(visualmode(), 1), '\n$', '', '')
@ -128,25 +128,25 @@ function! neosnippet#mappings#_expand_target_trigger(trigger) abort "{{{
call cursor(0, col('.') - 1) call cursor(0, col('.') - 1)
stopinsert stopinsert
endif endif
endfunction"}}} endfunction
function! neosnippet#mappings#_anonymous(snippet) abort "{{{ function! neosnippet#mappings#_anonymous(snippet) abort
let [cur_text, col, expr] = neosnippet#mappings#_pre_trigger() let [cur_text, col, expr] = neosnippet#mappings#_pre_trigger()
let expr .= printf("\<ESC>:call neosnippet#view#_insert(%s, {}, %s, %d)\<CR>", let expr .= printf("\<ESC>:call neosnippet#view#_insert(%s, {}, %s, %d)\<CR>",
\ string(a:snippet), string(cur_text), col) \ string(a:snippet), string(cur_text), col)
return expr return expr
endfunction"}}} endfunction
function! neosnippet#mappings#_expand(trigger) abort "{{{ function! neosnippet#mappings#_expand(trigger) abort
let [cur_text, col, expr] = neosnippet#mappings#_pre_trigger() let [cur_text, col, expr] = neosnippet#mappings#_pre_trigger()
let expr .= printf("\<ESC>:call neosnippet#view#_expand(%s, %d, %s)\<CR>", let expr .= printf("\<ESC>:call neosnippet#view#_expand(%s, %d, %s)\<CR>",
\ string(cur_text), col, string(a:trigger)) \ string(cur_text), col, string(a:trigger))
return expr return expr
endfunction"}}} endfunction
function! s:snippets_expand(cur_text, col) abort "{{{ function! s:snippets_expand(cur_text, col) abort
if s:expand_completed_snippets(a:cur_text, a:col) if s:expand_completed_snippets(a:cur_text, a:col)
return 0 return 0
endif endif
@ -162,8 +162,8 @@ function! s:snippets_expand(cur_text, col) abort "{{{
endif endif
return 1 return 1
endfunction"}}} endfunction
function! s:expand_completed_snippets(cur_text, col) abort "{{{ function! s:expand_completed_snippets(cur_text, col) abort
if !s:enabled_completed_snippet() if !s:enabled_completed_snippet()
return 0 return 0
endif endif
@ -194,15 +194,15 @@ function! s:expand_completed_snippets(cur_text, col) abort "{{{
call neosnippet#view#_insert(snippet, {}, cur_text, a:col) call neosnippet#view#_insert(snippet, {}, cur_text, a:col)
return 1 return 1
endfunction"}}} endfunction
function! s:snippets_expand_or_jump(cur_text, col) abort "{{{ function! s:snippets_expand_or_jump(cur_text, col) abort
if s:snippets_expand(a:cur_text, a:col) if s:snippets_expand(a:cur_text, a:col)
call neosnippet#view#_jump('', a:col) call neosnippet#view#_jump('', a:col)
endif endif
endfunction"}}} endfunction
function! s:snippets_jump_or_expand(cur_text, col) abort "{{{ function! s:snippets_jump_or_expand(cur_text, col) abort
if search(neosnippet#get_placeholder_marker_pattern(). '\|' if search(neosnippet#get_placeholder_marker_pattern(). '\|'
\ .neosnippet#get_sync_placeholder_marker_pattern(), 'nw') > 0 \ .neosnippet#get_sync_placeholder_marker_pattern(), 'nw') > 0
" Found snippet placeholder. " Found snippet placeholder.
@ -210,13 +210,13 @@ function! s:snippets_jump_or_expand(cur_text, col) abort "{{{
else else
return s:snippets_expand(a:cur_text, a:col) return s:snippets_expand(a:cur_text, a:col)
endif endif
endfunction"}}} endfunction
function! s:SID_PREFIX() abort "{{{ function! s:SID_PREFIX() abort
return matchstr(expand('<sfile>'), '<SNR>\d\+_\ze\w\+$') return matchstr(expand('<sfile>'), '<SNR>\d\+_\ze\w\+$')
endfunction"}}} endfunction
function! neosnippet#mappings#_trigger(function) abort "{{{ function! neosnippet#mappings#_trigger(function) abort
let [cur_text, col, expr] = neosnippet#mappings#_pre_trigger() let [cur_text, col, expr] = neosnippet#mappings#_pre_trigger()
if !neosnippet#mappings#expandable_or_jumpable() if !neosnippet#mappings#expandable_or_jumpable()
@ -227,9 +227,9 @@ function! neosnippet#mappings#_trigger(function) abort "{{{
\ a:function, string(cur_text), col) \ a:function, string(cur_text), col)
return expr return expr
endfunction"}}} endfunction
function! neosnippet#mappings#_pre_trigger() abort "{{{ function! neosnippet#mappings#_pre_trigger() abort
call neosnippet#init#check() call neosnippet#init#check()
let cur_text = neosnippet#util#get_cur_text() let cur_text = neosnippet#util#get_cur_text()
@ -249,7 +249,7 @@ function! neosnippet#mappings#_pre_trigger() abort "{{{
endif endif
return [cur_text, col, expr] return [cur_text, col, expr]
endfunction"}}} endfunction
" Plugin key-mappings. " Plugin key-mappings.
function! neosnippet#mappings#expand_or_jump_impl() abort function! neosnippet#mappings#expand_or_jump_impl() abort
@ -270,5 +270,3 @@ endfunction
function! neosnippet#mappings#jump_impl() abort function! neosnippet#mappings#jump_impl() abort
return neosnippet#mappings#_trigger('neosnippet#view#_jump') return neosnippet#mappings#_trigger('neosnippet#view#_jump')
endfunction endfunction
" vim: foldmethod=marker

View File

@ -6,7 +6,7 @@
let s:Cache = neosnippet#util#get_vital().import('System.Cache.Deprecated') let s:Cache = neosnippet#util#get_vital().import('System.Cache.Deprecated')
function! neosnippet#parser#_parse_snippets(filename) abort "{{{ function! neosnippet#parser#_parse_snippets(filename) abort
if !filereadable(a:filename) if !filereadable(a:filename)
call neosnippet#util#print_error( call neosnippet#util#print_error(
\ printf('snippet file "%s" is not found.', a:filename)) \ printf('snippet file "%s" is not found.', a:filename))
@ -32,8 +32,8 @@ function! neosnippet#parser#_parse_snippets(filename) abort "{{{
endif endif
return snippets return snippets
endfunction"}}} endfunction
function! neosnippet#parser#_parse_snippet(filename, trigger) abort "{{{ function! neosnippet#parser#_parse_snippet(filename, trigger) abort
if !filereadable(a:filename) if !filereadable(a:filename)
call neosnippet#util#print_error( call neosnippet#util#print_error(
\ printf('snippet file "%s" is not found.', a:filename)) \ printf('snippet file "%s" is not found.', a:filename))
@ -48,9 +48,9 @@ function! neosnippet#parser#_parse_snippet(filename, trigger) abort "{{{
return neosnippet#parser#_initialize_snippet( return neosnippet#parser#_initialize_snippet(
\ snippet_dict, a:filename, 1, '', a:trigger) \ snippet_dict, a:filename, 1, '', a:trigger)
endfunction"}}} endfunction
function! s:parse(snippets_file) abort "{{{ function! s:parse(snippets_file) abort
let dup_check = {} let dup_check = {}
let snippet_dict = {} let snippet_dict = {}
let linenr = 1 let linenr = 1
@ -120,9 +120,9 @@ function! s:parse(snippets_file) abort "{{{
endif endif
return [snippets, sourced] return [snippets, sourced]
endfunction"}}} endfunction
function! s:parse_snippet_name(snippets_file, line, linenr, dup_check) abort "{{{ function! s:parse_snippet_name(snippets_file, line, linenr, dup_check) abort
" Initialize snippet dict. " Initialize snippet dict.
let snippet_dict = { let snippet_dict = {
\ 'word' : '', \ 'word' : '',
@ -162,9 +162,9 @@ function! s:parse_snippet_name(snippets_file, line, linenr, dup_check) abort "{{
endif endif
return snippet_dict return snippet_dict
endfunction"}}} endfunction
function! s:add_snippet_attribute(snippets_file, line, linenr, snippet_dict) abort "{{{ function! s:add_snippet_attribute(snippets_file, line, linenr, snippet_dict) abort
" Allow overriding/setting of the description (abbr) of the snippet. " Allow overriding/setting of the description (abbr) of the snippet.
" This will override what was set via the snippet line. " This will override what was set via the snippet line.
if a:line =~ '^abbr\s' if a:line =~ '^abbr\s'
@ -203,9 +203,9 @@ function! s:add_snippet_attribute(snippets_file, line, linenr, snippet_dict) abo
call neosnippet#util#print_error( call neosnippet#util#print_error(
\ printf('Invalid syntax : "%s"', a:line)) \ printf('Invalid syntax : "%s"', a:line))
endif endif
endfunction"}}} endfunction
function! s:set_snippet_dict(snippet_dict, snippets, dup_check, snippets_file) abort "{{{ function! s:set_snippet_dict(snippet_dict, snippets, dup_check, snippets_file) abort
if empty(a:snippet_dict) if empty(a:snippet_dict)
return return
endif endif
@ -225,9 +225,9 @@ function! s:set_snippet_dict(snippet_dict, snippets, dup_check, snippets_file) a
let a:snippets[alias] = alias_snippet let a:snippets[alias] = alias_snippet
let a:dup_check[alias] = alias_snippet let a:dup_check[alias] = alias_snippet
endfor endfor
endfunction"}}} endfunction
function! neosnippet#parser#_initialize_snippet(dict, path, line, pattern, name) abort "{{{ function! neosnippet#parser#_initialize_snippet(dict, path, line, pattern, name) abort
let a:dict.word = substitute(a:dict.word, '\n\+$', '', '') let a:dict.word = substitute(a:dict.word, '\n\+$', '', '')
if a:dict.word !~ '\n' if a:dict.word !~ '\n'
\ && a:dict.word !~ \ && a:dict.word !~
@ -265,9 +265,9 @@ function! neosnippet#parser#_initialize_snippet(dict, path, line, pattern, name)
endif endif
return snippet return snippet
endfunction"}}} endfunction
function! neosnippet#parser#_initialize_snippet_options() abort "{{{ function! neosnippet#parser#_initialize_snippet_options() abort
return { return {
\ 'head' : 0, \ 'head' : 0,
\ 'word' : \ 'word' :
@ -275,9 +275,9 @@ function! neosnippet#parser#_initialize_snippet_options() abort "{{{
\ 'indent' : 0, \ 'indent' : 0,
\ 'oneshot' : 0, \ 'oneshot' : 0,
\ } \ }
endfunction"}}} endfunction
function! neosnippet#parser#_get_completed_snippet(completed_item, cur_text, next_text) abort "{{{ function! neosnippet#parser#_get_completed_snippet(completed_item, cur_text, next_text) abort
let item = a:completed_item let item = a:completed_item
if strridx(a:cur_text, item.word) != len(a:cur_text) - len(item.word) if strridx(a:cur_text, item.word) != len(a:cur_text) - len(item.word)
@ -376,9 +376,9 @@ function! neosnippet#parser#_get_completed_snippet(completed_item, cur_text, nex
let snippet .= '${' . cnt . '}' let snippet .= '${' . cnt . '}'
return snippet return snippet
endfunction"}}} endfunction
function! neosnippet#parser#_get_in_paren(key, pair, str) abort "{{{ function! neosnippet#parser#_get_in_paren(key, pair, str) abort
let s = '' let s = ''
let level = 0 let level = 0
for c in split(a:str, '\zs') for c in split(a:str, '\zs')
@ -402,9 +402,9 @@ function! neosnippet#parser#_get_in_paren(key, pair, str) abort "{{{
endfor endfor
return '' return ''
endfunction"}}} endfunction
function! neosnippet#parser#_conceal_argument(arg, cnt, args) abort "{{{ function! neosnippet#parser#_conceal_argument(arg, cnt, args) abort
let outside = '' let outside = ''
let inside = '' let inside = ''
if (a:args != '') if (a:args != '')
@ -415,5 +415,4 @@ function! neosnippet#parser#_conceal_argument(arg, cnt, args) abort "{{{
endif endif
endif endif
return printf('%s${%d:#:%s%s}', outside, a:cnt, inside, escape(a:arg, '{}')) return printf('%s${%d:#:%s%s}', outside, a:cnt, inside, escape(a:arg, '{}'))
endfunction"}}} endfunction
" vim: foldmethod=marker

View File

@ -4,99 +4,99 @@
" License: MIT license " License: MIT license
"============================================================================= "=============================================================================
function! neosnippet#util#get_vital() abort "{{{ function! neosnippet#util#get_vital() abort
if !exists('s:V') if !exists('s:V')
let s:V = vital#neosnippet#new() let s:V = vital#neosnippet#new()
endif endif
return s:V return s:V
endfunction"}}} endfunction
function! s:get_prelude() abort "{{{ function! s:get_prelude() abort
if !exists('s:Prelude') if !exists('s:Prelude')
let s:Prelude = neosnippet#util#get_vital().import('Prelude') let s:Prelude = neosnippet#util#get_vital().import('Prelude')
endif endif
return s:Prelude return s:Prelude
endfunction"}}} endfunction
function! s:get_list() abort "{{{ function! s:get_list() abort
if !exists('s:List') if !exists('s:List')
let s:List = neosnippet#util#get_vital().import('Data.List') let s:List = neosnippet#util#get_vital().import('Data.List')
endif endif
return s:List return s:List
endfunction"}}} endfunction
function! s:get_string() abort "{{{ function! s:get_string() abort
if !exists('s:String') if !exists('s:String')
let s:String = neosnippet#util#get_vital().import('Data.String') let s:String = neosnippet#util#get_vital().import('Data.String')
endif endif
return s:String return s:String
endfunction"}}} endfunction
function! s:get_process() abort "{{{ function! s:get_process() abort
if !exists('s:Process') if !exists('s:Process')
let s:Process = neosnippet#util#get_vital().import('Process') let s:Process = neosnippet#util#get_vital().import('Process')
endif endif
return s:Process return s:Process
endfunction"}}} endfunction
function! neosnippet#util#substitute_path_separator(...) abort "{{{ function! neosnippet#util#substitute_path_separator(...) abort
return call(s:get_prelude().substitute_path_separator, a:000) return call(s:get_prelude().substitute_path_separator, a:000)
endfunction"}}} endfunction
function! neosnippet#util#system(...) abort "{{{ function! neosnippet#util#system(...) abort
return call(s:get_process().system, a:000) return call(s:get_process().system, a:000)
endfunction"}}} endfunction
function! neosnippet#util#has_vimproc(...) abort "{{{ function! neosnippet#util#has_vimproc(...) abort
return call(s:get_process().has_vimproc, a:000) return call(s:get_process().has_vimproc, a:000)
endfunction"}}} endfunction
function! neosnippet#util#is_windows(...) abort "{{{ function! neosnippet#util#is_windows(...) abort
return call(s:get_prelude().is_windows, a:000) return call(s:get_prelude().is_windows, a:000)
endfunction"}}} endfunction
function! neosnippet#util#is_mac(...) abort "{{{ function! neosnippet#util#is_mac(...) abort
return call(s:get_prelude().is_mac, a:000) return call(s:get_prelude().is_mac, a:000)
endfunction"}}} endfunction
function! neosnippet#util#get_last_status(...) abort "{{{ function! neosnippet#util#get_last_status(...) abort
return call(s:get_process().get_last_status, a:000) return call(s:get_process().get_last_status, a:000)
endfunction"}}} endfunction
function! neosnippet#util#escape_pattern(...) abort "{{{ function! neosnippet#util#escape_pattern(...) abort
return call(s:get_string().escape_pattern, a:000) return call(s:get_string().escape_pattern, a:000)
endfunction"}}} endfunction
function! neosnippet#util#iconv(...) abort "{{{ function! neosnippet#util#iconv(...) abort
return call(s:get_process().iconv, a:000) return call(s:get_process().iconv, a:000)
endfunction"}}} endfunction
function! neosnippet#util#truncate(...) abort "{{{ function! neosnippet#util#truncate(...) abort
return call(s:get_string().truncate, a:000) return call(s:get_string().truncate, a:000)
endfunction"}}} endfunction
function! neosnippet#util#strwidthpart(...) abort "{{{ function! neosnippet#util#strwidthpart(...) abort
return call(s:get_string().strwidthpart, a:000) return call(s:get_string().strwidthpart, a:000)
endfunction"}}} endfunction
function! neosnippet#util#expand(path) abort "{{{ function! neosnippet#util#expand(path) abort
return neosnippet#util#substitute_path_separator( return neosnippet#util#substitute_path_separator(
\ expand(escape(a:path, '*?[]"={}'), 1)) \ expand(escape(a:path, '*?[]"={}'), 1))
endfunction"}}} endfunction
function! neosnippet#util#set_default(var, val, ...) abort "{{{ function! neosnippet#util#set_default(var, val, ...) abort
let old_var = get(a:000, 0, '') let old_var = get(a:000, 0, '')
if exists(old_var) if exists(old_var)
let {a:var} = {old_var} let {a:var} = {old_var}
elseif !exists(a:var) elseif !exists(a:var)
let {a:var} = a:val let {a:var} = a:val
endif endif
endfunction"}}} endfunction
function! neosnippet#util#set_dictionary_helper(...) abort "{{{ function! neosnippet#util#set_dictionary_helper(...) abort
return call(s:get_prelude().set_dictionary_helper, a:000) return call(s:get_prelude().set_dictionary_helper, a:000)
endfunction"}}} endfunction
function! neosnippet#util#get_cur_text() abort "{{{ function! neosnippet#util#get_cur_text() abort
return return
\ (mode() ==# 'i' ? (col('.')-1) : col('.')) >= len(getline('.')) ? \ (mode() ==# 'i' ? (col('.')-1) : col('.')) >= len(getline('.')) ?
\ getline('.') : \ getline('.') :
\ matchstr(getline('.'), \ matchstr(getline('.'),
\ '^.*\%' . col('.') . 'c' . (mode() ==# 'i' ? '' : '.')) \ '^.*\%' . col('.') . 'c' . (mode() ==# 'i' ? '' : '.'))
endfunction"}}} endfunction
function! neosnippet#util#get_next_text() abort "{{{ function! neosnippet#util#get_next_text() abort
return getline('.')[len(neosnippet#util#get_cur_text()) :] return getline('.')[len(neosnippet#util#get_cur_text()) :]
endfunction"}}} endfunction
function! neosnippet#util#print_error(string) abort "{{{ function! neosnippet#util#print_error(string) abort
echohl Error | echomsg '[neosnippet] ' . a:string | echohl None echohl Error | echomsg '[neosnippet] ' . a:string | echohl None
endfunction"}}} endfunction
function! neosnippet#util#parse_options(args, options_list) abort "{{{ function! neosnippet#util#parse_options(args, options_list) abort
let args = [] let args = []
let options = {} let options = {}
for arg in split(a:args, '\%(\\\@<!\s\)\+') for arg in split(a:args, '\%(\\\@<!\s\)\+')
@ -117,9 +117,9 @@ function! neosnippet#util#parse_options(args, options_list) abort "{{{
endfor endfor
return [args, options] return [args, options]
endfunction"}}} endfunction
function! neosnippet#util#get_buffer_config( function! neosnippet#util#get_buffer_config(
\ filetype, buffer_var, user_var, default_var, ...) abort "{{{ \ filetype, buffer_var, user_var, default_var, ...) abort
let default_val = get(a:000, 0, '') let default_val = get(a:000, 0, '')
if exists(a:buffer_var) if exists(a:buffer_var)
@ -131,18 +131,18 @@ function! neosnippet#util#get_buffer_config(
return get({a:user_var}, filetype, return get({a:user_var}, filetype,
\ get(eval(a:default_var), filetype, default_val)) \ get(eval(a:default_var), filetype, default_val))
endfunction"}}} endfunction
" Sudo check. " Sudo check.
function! neosnippet#util#is_sudo() abort "{{{ function! neosnippet#util#is_sudo() abort
return $SUDO_USER != '' && $USER !=# $SUDO_USER return $SUDO_USER != '' && $USER !=# $SUDO_USER
\ && $HOME !=# expand('~'.$USER) \ && $HOME !=# expand('~'.$USER)
\ && $HOME ==# expand('~'.$SUDO_USER) \ && $HOME ==# expand('~'.$SUDO_USER)
endfunction"}}} endfunction
function! neosnippet#util#option2list(str) abort "{{{ function! neosnippet#util#option2list(str) abort
return type(a:str) == type('') ? split(a:str, '\s*,\s*') : a:str return type(a:str) == type('') ? split(a:str, '\s*,\s*') : a:str
endfunction"}}} endfunction
function! neosnippet#util#uniq(list) abort function! neosnippet#util#uniq(list) abort
let list = copy(a:list) let list = copy(a:list)
@ -161,5 +161,3 @@ function! neosnippet#util#uniq(list) abort
endwhile endwhile
return list return list
endfunction endfunction
" vim: foldmethod=marker

View File

@ -4,7 +4,7 @@
" License: MIT license " License: MIT license
"============================================================================= "=============================================================================
function! neosnippet#variables#current_neosnippet() abort "{{{ function! neosnippet#variables#current_neosnippet() abort
if !exists('b:neosnippet') if !exists('b:neosnippet')
let b:neosnippet = { let b:neosnippet = {
\ 'snippets' : {}, \ 'snippets' : {},
@ -17,42 +17,42 @@ function! neosnippet#variables#current_neosnippet() abort "{{{
endif endif
return b:neosnippet return b:neosnippet
endfunction"}}} endfunction
function! neosnippet#variables#expand_stack() abort "{{{ function! neosnippet#variables#expand_stack() abort
if !exists('s:expand_stack') if !exists('s:expand_stack')
let s:expand_stack = [] let s:expand_stack = []
endif endif
return s:expand_stack return s:expand_stack
endfunction"}}} endfunction
function! neosnippet#variables#pop_expand_stack() abort "{{{ function! neosnippet#variables#pop_expand_stack() abort
let s:expand_stack = s:expand_stack[: -2] let s:expand_stack = s:expand_stack[: -2]
endfunction"}}} endfunction
function! neosnippet#variables#clear_expand_stack() abort "{{{ function! neosnippet#variables#clear_expand_stack() abort
let s:expand_stack = [] let s:expand_stack = []
endfunction"}}} endfunction
function! neosnippet#variables#snippets() abort "{{{ function! neosnippet#variables#snippets() abort
if !exists('s:snippets') if !exists('s:snippets')
let s:snippets= {} let s:snippets= {}
endif endif
return s:snippets return s:snippets
endfunction"}}} endfunction
function! neosnippet#variables#set_snippets(list) abort "{{{ function! neosnippet#variables#set_snippets(list) abort
if !exists('s:snippets') if !exists('s:snippets')
let s:snippets= {} let s:snippets= {}
endif endif
let s:snippets = a:list let s:snippets = a:list
endfunction"}}} endfunction
function! neosnippet#variables#snippets_dir() abort "{{{ function! neosnippet#variables#snippets_dir() abort
" Set snippets_dir. " Set snippets_dir.
let snippets_dir = map(neosnippet#util#option2list( let snippets_dir = map(neosnippet#util#option2list(
\ g:neosnippet#snippets_directory), \ g:neosnippet#snippets_directory),
\ 'neosnippet#util#expand(v:val)') \ 'neosnippet#util#expand(v:val)')
return map(snippets_dir, 'substitute(v:val, "[\\\\/]$", "", "")') return map(snippets_dir, 'substitute(v:val, "[\\\\/]$", "", "")')
endfunction"}}} endfunction
function! neosnippet#variables#runtime_dir() abort "{{{ function! neosnippet#variables#runtime_dir() abort
" Set runtime dir. " Set runtime dir.
let runtime_dir = split(globpath(&runtimepath, 'neosnippets'), '\n') let runtime_dir = split(globpath(&runtimepath, 'neosnippets'), '\n')
if empty(runtime_dir) && empty(g:neosnippet#disable_runtime_snippets) if empty(runtime_dir) && empty(g:neosnippet#disable_runtime_snippets)
@ -71,8 +71,8 @@ function! neosnippet#variables#runtime_dir() abort "{{{
endif endif
return map(runtime_dir, 'substitute(v:val, "[\\\\/]$", "", "")') return map(runtime_dir, 'substitute(v:val, "[\\\\/]$", "", "")')
endfunction"}}} endfunction
function! neosnippet#variables#data_dir() abort "{{{ function! neosnippet#variables#data_dir() abort
let g:neosnippet#data_directory = let g:neosnippet#data_directory =
\ substitute(fnamemodify(get( \ substitute(fnamemodify(get(
\ g:, 'neosnippet#data_directory', \ g:, 'neosnippet#data_directory',
@ -84,6 +84,4 @@ function! neosnippet#variables#data_dir() abort "{{{
endif endif
return g:neosnippet#data_directory return g:neosnippet#data_directory
endfunction"}}} endfunction
" vim: foldmethod=marker

View File

@ -4,7 +4,7 @@
" License: MIT license " License: MIT license
"============================================================================= "=============================================================================
function! neosnippet#view#_expand(cur_text, col, trigger_name) abort "{{{ function! neosnippet#view#_expand(cur_text, col, trigger_name) abort
let snippets = neosnippet#helpers#get_snippets() let snippets = neosnippet#helpers#get_snippets()
if a:trigger_name == '' || !has_key(snippets, a:trigger_name) if a:trigger_name == '' || !has_key(snippets, a:trigger_name)
@ -25,8 +25,8 @@ function! neosnippet#view#_expand(cur_text, col, trigger_name) abort "{{{
let cur_text = a:cur_text[: -1-len(a:trigger_name)] let cur_text = a:cur_text[: -1-len(a:trigger_name)]
call neosnippet#view#_insert(snippet.snip, snippet.options, cur_text, a:col) call neosnippet#view#_insert(snippet.snip, snippet.options, cur_text, a:col)
endfunction"}}} endfunction
function! neosnippet#view#_insert(snippet, options, cur_text, col) abort "{{{ function! neosnippet#view#_insert(snippet, options, cur_text, col) abort
let options = extend( let options = extend(
\ neosnippet#parser#_initialize_snippet_options(), \ neosnippet#parser#_initialize_snippet_options(),
\ a:options) \ a:options)
@ -105,8 +105,8 @@ function! neosnippet#view#_insert(snippet, options, cur_text, col) abort "{{{
silent! execute begin_line . ',' . end_line . 'foldopen!' silent! execute begin_line . ',' . end_line . 'foldopen!'
endif endif
endtry endtry
endfunction"}}} endfunction
function! neosnippet#view#_jump(_, col) abort "{{{ function! neosnippet#view#_jump(_, col) abort
try try
let expand_stack = neosnippet#variables#expand_stack() let expand_stack = neosnippet#variables#expand_stack()
@ -148,9 +148,9 @@ function! neosnippet#view#_jump(_, col) abort "{{{
finally finally
call s:skip_next_auto_completion() call s:skip_next_auto_completion()
endtry endtry
endfunction"}}} endfunction
function! s:indent_snippet(begin, end) abort "{{{ function! s:indent_snippet(begin, end) abort
if a:begin > a:end if a:begin > a:end
return return
endif endif
@ -187,9 +187,9 @@ function! s:indent_snippet(begin, end) abort "{{{
let &l:equalprg = equalprg let &l:equalprg = equalprg
call setpos('.', pos) call setpos('.', pos)
endtry endtry
endfunction"}}} endfunction
function! neosnippet#view#_get_snippet_range(begin_line, begin_patterns, end_line, end_patterns) abort "{{{ function! neosnippet#view#_get_snippet_range(begin_line, begin_patterns, end_line, end_patterns) abort
let pos = getpos('.') let pos = getpos('.')
call cursor(a:begin_line, 0) call cursor(a:begin_line, 0)
@ -227,8 +227,8 @@ function! neosnippet#view#_get_snippet_range(begin_line, begin_patterns, end_lin
call setpos('.', pos) call setpos('.', pos)
return [begin, end] return [begin, end]
endfunction"}}} endfunction
function! neosnippet#view#_search_snippet_range(start, end, cnt, ...) abort "{{{ function! neosnippet#view#_search_snippet_range(start, end, cnt, ...) abort
let is_select = get(a:000, 0, 1) let is_select = get(a:000, 0, 1)
call s:substitute_placeholder_marker(a:start, a:end, a:cnt) call s:substitute_placeholder_marker(a:start, a:end, a:cnt)
@ -250,8 +250,8 @@ function! neosnippet#view#_search_snippet_range(start, end, cnt, ...) abort "{{{
endfor endfor
return 0 return 0
endfunction"}}} endfunction
function! neosnippet#view#_search_outof_range(col) abort "{{{ function! neosnippet#view#_search_outof_range(col) abort
call s:substitute_placeholder_marker(1, 0, 0) call s:substitute_placeholder_marker(1, 0, 0)
let pattern = neosnippet#get_placeholder_marker_pattern() let pattern = neosnippet#get_placeholder_marker_pattern()
@ -275,8 +275,8 @@ function! neosnippet#view#_search_outof_range(col) abort "{{{
" Not found. " Not found.
return 0 return 0
endfunction"}}} endfunction
function! neosnippet#view#_clear_markers(expand_info) abort "{{{ function! neosnippet#view#_clear_markers(expand_info) abort
" Search patterns. " Search patterns.
let [begin, end] = neosnippet#view#_get_snippet_range( let [begin, end] = neosnippet#view#_get_snippet_range(
\ a:expand_info.begin_line, \ a:expand_info.begin_line,
@ -311,8 +311,8 @@ function! neosnippet#view#_clear_markers(expand_info) abort "{{{
call neosnippet#variables#pop_expand_stack() call neosnippet#variables#pop_expand_stack()
endtry endtry
endfunction"}}} endfunction
function! s:expand_placeholder(start, end, holder_cnt, line, ...) abort "{{{ function! s:expand_placeholder(start, end, holder_cnt, line, ...) abort
let is_select = get(a:000, 0, 1) let is_select = get(a:000, 0, 1)
let pattern = substitute(neosnippet#get_placeholder_marker_pattern(), let pattern = substitute(neosnippet#get_placeholder_marker_pattern(),
@ -401,8 +401,8 @@ function! s:expand_placeholder(start, end, holder_cnt, line, ...) abort "{{{
else else
startinsert! startinsert!
endif endif
endfunction"}}} endfunction
function! s:expand_target_placeholder(line, col) abort "{{{ function! s:expand_target_placeholder(line, col) abort
" Expand target " Expand target
let neosnippet = neosnippet#variables#current_neosnippet() let neosnippet = neosnippet#variables#current_neosnippet()
let next_line = getline(a:line)[a:col-1 :] let next_line = getline(a:line)[a:col-1 :]
@ -461,8 +461,8 @@ function! s:expand_target_placeholder(line, col) abort "{{{
let neosnippet.target = '' let neosnippet.target = ''
call neosnippet#view#_jump('', col) call neosnippet#view#_jump('', col)
endfunction"}}} endfunction
function! s:search_sync_placeholder(start, end, number) abort "{{{ function! s:search_sync_placeholder(start, end, number) abort
if a:end == 0 if a:end == 0
" Search in current buffer. " Search in current buffer.
let cnt = matchstr(getline('.'), let cnt = matchstr(getline('.'),
@ -482,8 +482,8 @@ function! s:search_sync_placeholder(start, end, number) abort "{{{
endif endif
return -1 return -1
endfunction"}}} endfunction
function! s:substitute_placeholder_marker(start, end, snippet_holder_cnt) abort "{{{ function! s:substitute_placeholder_marker(start, end, snippet_holder_cnt) abort
if a:snippet_holder_cnt > 0 if a:snippet_holder_cnt > 0
let cnt = a:snippet_holder_cnt-1 let cnt = a:snippet_holder_cnt-1
let sync_marker = substitute(neosnippet#get_sync_placeholder_marker_pattern(), let sync_marker = substitute(neosnippet#get_sync_placeholder_marker_pattern(),
@ -518,8 +518,8 @@ function! s:substitute_placeholder_marker(start, end, snippet_holder_cnt) abort
\ '\\d\\+', cnt, '') \ '\\d\\+', 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) abort "{{{ function! s:eval_snippet(snippet_text) abort
let snip_word = '' let snip_word = ''
let prev_match = 0 let prev_match = 0
let match = match(a:snippet_text, '\\\@<!`.\{-}\\\@<!`') let match = match(a:snippet_text, '\\\@<!`.\{-}\\\@<!`')
@ -540,8 +540,8 @@ function! s:eval_snippet(snippet_text) abort "{{{
endif endif
return snip_word return snip_word
endfunction"}}} endfunction
function! s:skip_next_auto_completion() abort "{{{ function! s:skip_next_auto_completion() abort
" Skip next auto completion. " Skip next auto completion.
let neosnippet = neosnippet#variables#current_neosnippet() let neosnippet = neosnippet#variables#current_neosnippet()
let neosnippet.trigger = 0 let neosnippet.trigger = 0
@ -552,6 +552,4 @@ function! s:skip_next_auto_completion() abort "{{{
if exists('#deoplete#CompleteDone') if exists('#deoplete#CompleteDone')
doautocmd deoplete CompleteDone doautocmd deoplete CompleteDone
endif endif
endfunction"}}} endfunction
" vim: foldmethod=marker

View File

@ -4,7 +4,7 @@
" License: MIT license " License: MIT license
"============================================================================= "=============================================================================
function! unite#sources#neosnippet#define() abort "{{{ function! unite#sources#neosnippet#define() abort
let kind = { let kind = {
\ 'name' : 'neosnippet', \ 'name' : 'neosnippet',
\ 'default_action' : 'expand', \ 'default_action' : 'expand',
@ -15,7 +15,7 @@ function! unite#sources#neosnippet#define() abort "{{{
call unite#define_kind(kind) call unite#define_kind(kind)
return s:source return s:source
endfunction "}}} endfunction
" neosnippet source. " neosnippet source.
let s:source = { let s:source = {
@ -24,14 +24,14 @@ let s:source = {
\ 'action_table' : {}, \ 'action_table' : {},
\ } \ }
function! s:source.hooks.on_init(args, context) abort "{{{ function! s:source.hooks.on_init(args, context) abort
let a:context.source__cur_keyword_pos = let a:context.source__cur_keyword_pos =
\ s:get_keyword_pos(neosnippet#util#get_cur_text()) \ s:get_keyword_pos(neosnippet#util#get_cur_text())
let a:context.source__snippets = let a:context.source__snippets =
\ sort(values(neosnippet#helpers#get_completion_snippets())) \ sort(values(neosnippet#helpers#get_completion_snippets()))
endfunction"}}} endfunction
function! s:source.gather_candidates(args, context) abort "{{{ function! s:source.gather_candidates(args, context) abort
return map(copy(a:context.source__snippets), "{ return map(copy(a:context.source__snippets), "{
\ 'word' : v:val.word, \ 'word' : v:val.word,
\ 'abbr' : printf('%-50s %s', v:val.word, v:val.menu_abbr), \ 'abbr' : printf('%-50s %s', v:val.word, v:val.menu_abbr),
@ -44,29 +44,29 @@ function! s:source.gather_candidates(args, context) abort "{{{
\ 'source__snip' : v:val.snip, \ 'source__snip' : v:val.snip,
\ 'source__snip_ref' : v:val, \ 'source__snip_ref' : v:val,
\ }") \ }")
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) abort "{{{ function! s:action_table.expand.func(candidate) abort
let cur_text = neosnippet#util#get_cur_text() let cur_text = neosnippet#util#get_cur_text()
let cur_keyword_str = matchstr(cur_text, '\S\+$') let cur_keyword_str = matchstr(cur_text, '\S\+$')
let context = unite#get_context() let context = unite#get_context()
call neosnippet#view#_expand( call neosnippet#view#_expand(
\ cur_text . a:candidate.action__complete_word[len(cur_keyword_str)], \ cur_text . a:candidate.action__complete_word[len(cur_keyword_str)],
\ context.col, a:candidate.action__complete_word) \ context.col, a:candidate.action__complete_word)
endfunction"}}} endfunction
let s:action_table.preview = { let s:action_table.preview = {
\ 'description' : 'preview snippet', \ 'description' : 'preview snippet',
\ 'is_selectable' : 1, \ 'is_selectable' : 1,
\ 'is_quit' : 0, \ 'is_quit' : 0,
\ } \ }
function! s:action_table.preview.func(candidates) abort "{{{ function! s:action_table.preview.func(candidates) abort
for snip in a:candidates for snip in a:candidates
echohl String echohl String
echo snip.action__complete_word echo snip.action__complete_word
@ -74,13 +74,13 @@ function! s:action_table.preview.func(candidates) abort "{{{
echo snip.source__snip echo snip.source__snip
echo ' ' echo ' '
endfor endfor
endfunction"}}} endfunction
let s:action_table.unite__new_candidate = { 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) abort "{{{ function! s:action_table.unite__new_candidate.func(candidate) abort
let trigger = unite#util#input('Please input snippet trigger: ') let trigger = unite#util#input('Please input snippet trigger: ')
if trigger == '' if trigger == ''
echo 'Canceled.' echo 'Canceled.'
@ -107,14 +107,14 @@ function! s:action_table.unite__new_candidate.func(candidate) abort "{{{
call cursor(line('$'), 0) call cursor(line('$'), 0)
call cursor(0, col('$')) call cursor(0, col('$'))
endfunction"}}} endfunction
let s:source.action_table = s:action_table let s:source.action_table = s:action_table
unlet! s:action_table unlet! s:action_table
"}}}
function! unite#sources#neosnippet#start_complete() abort "{{{
function! unite#sources#neosnippet#start_complete() abort
if !exists(':Unite') if !exists(':Unite')
call neosnippet#util#print_error( call neosnippet#util#print_error(
\ 'unite.vim is not installed.') \ 'unite.vim is not installed.')
@ -125,9 +125,9 @@ function! unite#sources#neosnippet#start_complete() abort "{{{
return unite#start_complete(['neosnippet'], return unite#start_complete(['neosnippet'],
\ { '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) abort "{{{ function! s:get_keyword_pos(cur_text) abort
let cur_keyword_pos = match(a:cur_text, '\S\+$') let cur_keyword_pos = match(a:cur_text, '\S\+$')
if cur_keyword_pos < 0 if cur_keyword_pos < 0
" Empty string. " Empty string.
@ -135,6 +135,4 @@ function! s:get_keyword_pos(cur_text) abort "{{{
endif endif
return cur_keyword_pos return cur_keyword_pos
endfunction"}}} endfunction
" vim: foldmethod=marker

View File

@ -4,9 +4,9 @@
" License: MIT license " License: MIT license
"============================================================================= "=============================================================================
function! unite#sources#neosnippet_file#define() abort "{{{ function! unite#sources#neosnippet_file#define() abort
return [s:source_user, s:source_runtime] return [s:source_user, s:source_runtime]
endfunction "}}} endfunction
" common action table " common action table
let s:action_table = {} let s:action_table = {}
@ -15,14 +15,14 @@ let s:action_table.neosnippet_source = {
\ 'is_selectable' : 1, \ 'is_selectable' : 1,
\ 'is_quit' : 1, \ 'is_quit' : 1,
\ } \ }
function! s:action_table.neosnippet_source.func(candidates) abort "{{{ function! s:action_table.neosnippet_source.func(candidates) abort
for candidate in a:candidates for candidate in a:candidates
let snippet_name = candidate.action__path let snippet_name = candidate.action__path
if snippet_name != '' if snippet_name != ''
call neosnippet#commands#_source(snippet_name) call neosnippet#commands#_source(snippet_name)
endif endif
endfor endfor
endfunction"}}} endfunction
" neosnippet source. " neosnippet source.
let s:source_user = { let s:source_user = {
@ -30,23 +30,23 @@ let s:source_user = {
\ 'description' : 'neosnippet user file', \ 'description' : 'neosnippet user file',
\ 'action_table' : copy(s:action_table), \ 'action_table' : copy(s:action_table),
\ } \ }
function! s:source_user.gather_candidates(args, context) abort "{{{ function! s:source_user.gather_candidates(args, context) abort
return s:get_snippet_candidates( return s:get_snippet_candidates(
\ neosnippet#get_user_snippets_directory()) \ neosnippet#get_user_snippets_directory())
endfunction "}}} endfunction
let s:source_user.action_table.unite__new_candidate = { let s:source_user.action_table.unite__new_candidate = {
\ 'description' : 'create new user snippet', \ 'description' : 'create new user snippet',
\ 'is_invalidate_cache' : 1, \ 'is_invalidate_cache' : 1,
\ 'is_quit' : 1, \ 'is_quit' : 1,
\ } \ }
function! s:source_user.action_table.unite__new_candidate.func(candidate) abort "{{{ function! s:source_user.action_table.unite__new_candidate.func(candidate) abort
let filename = input( let filename = input(
\ 'New snippet file name: ', neosnippet#helpers#get_filetype()) \ 'New snippet file name: ', neosnippet#helpers#get_filetype())
if filename != '' if filename != ''
call neosnippet#commands#_edit(filename) call neosnippet#commands#_edit(filename)
endif endif
endfunction"}}} endfunction
" neosnippet source. " neosnippet source.
@ -55,26 +55,26 @@ let s:source_runtime = {
\ 'description' : 'neosnippet runtime file', \ 'description' : 'neosnippet runtime file',
\ 'action_table' : copy(s:action_table), \ 'action_table' : copy(s:action_table),
\ } \ }
function! s:source_runtime.gather_candidates(args, context) abort "{{{ function! s:source_runtime.gather_candidates(args, context) abort
return s:get_snippet_candidates( return s:get_snippet_candidates(
\ neosnippet#get_runtime_snippets_directory()) \ neosnippet#get_runtime_snippets_directory())
endfunction "}}} endfunction
let s:source_runtime.action_table.unite__new_candidate = { let s:source_runtime.action_table.unite__new_candidate = {
\ 'description' : 'create new runtime snippet', \ 'description' : 'create new runtime snippet',
\ 'is_invalidate_cache' : 1, \ 'is_invalidate_cache' : 1,
\ 'is_quit' : 1, \ 'is_quit' : 1,
\ } \ }
function! s:source_runtime.action_table.unite__new_candidate.func(candidate) abort "{{{ function! s:source_runtime.action_table.unite__new_candidate.func(candidate) abort
let filename = input( let filename = input(
\ 'New snippet file name: ', neosnippet#helpers#get_filetype()) \ 'New snippet file name: ', neosnippet#helpers#get_filetype())
if filename != '' if filename != ''
call neosnippet#commands#_edit('-runtime ' . filename) call neosnippet#commands#_edit('-runtime ' . filename)
endif endif
endfunction"}}} endfunction
function! s:get_snippet_candidates(dirs) abort "{{{ function! s:get_snippet_candidates(dirs) abort
let _ = [] let _ = []
for directory in a:dirs for directory in a:dirs
let _ += map(split(unite#util#substitute_path_separator( let _ += map(split(unite#util#substitute_path_separator(
@ -86,6 +86,4 @@ function! s:get_snippet_candidates(dirs) abort "{{{
endfor endfor
return _ return _
endfunction "}}} endfunction
" vim: foldmethod=marker

View File

@ -11,7 +11,7 @@ elseif v:version < 704
finish finish
endif endif
" Plugin key-mappings. "{{{ " Plugin key-mappings.
inoremap <silent><expr> <Plug>(neosnippet_expand_or_jump) inoremap <silent><expr> <Plug>(neosnippet_expand_or_jump)
\ neosnippet#mappings#expand_or_jump_impl() \ neosnippet#mappings#expand_or_jump_impl()
inoremap <silent><expr> <Plug>(neosnippet_jump_or_expand) inoremap <silent><expr> <Plug>(neosnippet_jump_or_expand)
@ -39,13 +39,13 @@ xnoremap <silent> <Plug>(neosnippet_register_oneshot_snippet)
inoremap <expr><silent> <Plug>(neosnippet_start_unite_snippet) inoremap <expr><silent> <Plug>(neosnippet_start_unite_snippet)
\ unite#sources#neosnippet#start_complete() \ unite#sources#neosnippet#start_complete()
"}}}
augroup neosnippet "{{{
augroup neosnippet
autocmd InsertEnter * call neosnippet#init#_initialize() autocmd InsertEnter * call neosnippet#init#_initialize()
augroup END"}}} augroup END
" Commands. "{{{ " Commands.
command! -nargs=? -bar command! -nargs=? -bar
\ -complete=customlist,neosnippet#commands#_edit_complete \ -complete=customlist,neosnippet#commands#_edit_complete
\ NeoSnippetEdit \ NeoSnippetEdit
@ -62,9 +62,6 @@ command! -nargs=1 -bar -complete=file
command! -bar NeoSnippetClearMarkers command! -bar NeoSnippetClearMarkers
\ call neosnippet#commands#_clear_markers() \ call neosnippet#commands#_clear_markers()
"}}}
let g:loaded_neosnippet = 1 let g:loaded_neosnippet = 1
" __END__
" vim: foldmethod=marker