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

@@ -4,7 +4,7 @@
" License: MIT license
"=============================================================================
function! unite#sources#neosnippet#define() abort "{{{
function! unite#sources#neosnippet#define() abort
let kind = {
\ 'name' : 'neosnippet',
\ 'default_action' : 'expand',
@@ -15,7 +15,7 @@ function! unite#sources#neosnippet#define() abort "{{{
call unite#define_kind(kind)
return s:source
endfunction "}}}
endfunction
" neosnippet source.
let s:source = {
@@ -24,14 +24,14 @@ let s:source = {
\ '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 =
\ s:get_keyword_pos(neosnippet#util#get_cur_text())
let a:context.source__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), "{
\ 'word' : v:val.word,
\ '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_ref' : v:val,
\ }")
endfunction "}}}
endfunction
" Actions "{{{
" Actions
let s:action_table = {}
let s:action_table.expand = {
\ '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_keyword_str = matchstr(cur_text, '\S\+$')
let context = unite#get_context()
call neosnippet#view#_expand(
\ cur_text . a:candidate.action__complete_word[len(cur_keyword_str)],
\ context.col, a:candidate.action__complete_word)
endfunction"}}}
endfunction
let s:action_table.preview = {
\ 'description' : 'preview snippet',
\ 'is_selectable' : 1,
\ 'is_quit' : 0,
\ }
function! s:action_table.preview.func(candidates) abort "{{{
function! s:action_table.preview.func(candidates) abort
for snip in a:candidates
echohl String
echo snip.action__complete_word
@@ -74,13 +74,13 @@ function! s:action_table.preview.func(candidates) abort "{{{
echo snip.source__snip
echo ' '
endfor
endfunction"}}}
endfunction
let s:action_table.unite__new_candidate = {
\ 'description' : 'add new snippet',
\ '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: ')
if trigger == ''
echo 'Canceled.'
@@ -107,14 +107,14 @@ function! s:action_table.unite__new_candidate.func(candidate) abort "{{{
call cursor(line('$'), 0)
call cursor(0, col('$'))
endfunction"}}}
endfunction
let s:source.action_table = s:action_table
unlet! s:action_table
"}}}
function! unite#sources#neosnippet#start_complete() abort "{{{
function! unite#sources#neosnippet#start_complete() abort
if !exists(':Unite')
call neosnippet#util#print_error(
\ 'unite.vim is not installed.')
@@ -125,9 +125,9 @@ function! unite#sources#neosnippet#start_complete() abort "{{{
return unite#start_complete(['neosnippet'],
\ { '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\+$')
if cur_keyword_pos < 0
" Empty string.
@@ -135,6 +135,4 @@ function! s:get_keyword_pos(cur_text) abort "{{{
endif
return cur_keyword_pos
endfunction"}}}
" vim: foldmethod=marker
endfunction

View File

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