aboutsummaryrefslogtreecommitdiff
path: root/autoload/unite
diff options
context:
space:
mode:
authorkmnk <kmnknmk+com-github@gmail.com>2012-03-07 23:43:41 +0900
committermattn <mattn.jp@gmail.com>2013-05-09 16:40:01 +0900
commita05828ce6d0958e0677b97172a9abbbb48660527 (patch)
tree9c3706a6fa5eee9b4b0ca0d08ce4f2c961d42013 /autoload/unite
parent10653f02a6c9ff5e8c58b87b574b08b38f40260e (diff)
downloadvim-sonictemplate-a05828ce6d0958e0677b97172a9abbbb48660527.tar.gz
vim-sonictemplate-a05828ce6d0958e0677b97172a9abbbb48660527.tar.bz2
vim-sonictemplate-a05828ce6d0958e0677b97172a9abbbb48660527.zip
source and kind for unite
Diffstat (limited to 'autoload/unite')
-rw-r--r--autoload/unite/kinds/sonictemplate.vim39
-rw-r--r--autoload/unite/sources/sonictemplate.vim36
2 files changed, 75 insertions, 0 deletions
diff --git a/autoload/unite/kinds/sonictemplate.vim b/autoload/unite/kinds/sonictemplate.vim
new file mode 100644
index 0000000..8879d09
--- /dev/null
+++ b/autoload/unite/kinds/sonictemplate.vim
@@ -0,0 +1,39 @@
+" File: sonictemplate
+" Author: kmnk <kmnknmk+vim@gmail.com>
+" Version: 0.1.0
+" License: BSD style license
+
+let s:save_cpo = &cpo
+set cpo&vim
+
+function! unite#kinds#sonictemplate#define()"{{{
+ return s:kind
+endfunction"}}}
+
+let s:kind = {
+\ 'name' : 'sonictemplate',
+\ 'default_action' : 'insert',
+\ 'action_table' : {},
+\ 'alias_table' : {},
+\}
+
+let s:kind.action_table.insert = {
+\ 'description' : 'insert this template',
+\ 'is_selectable' : 0,
+\ 'is_quit' : 1,
+\ 'is_invalidate_cache' : 0,
+\ 'is_listed' : 1,
+\}
+function! s:kind.action_table.insert.func(candidate)"{{{
+ call sonictemplate#apply(
+\ a:candidate.word,
+\ a:candidate.action__mode,
+\ )
+endfunction"}}}
+
+" local functions {{{
+" }}}
+
+let &cpo = s:save_cpo
+unlet s:save_cpo
+" __END__
diff --git a/autoload/unite/sources/sonictemplate.vim b/autoload/unite/sources/sonictemplate.vim
new file mode 100644
index 0000000..778c19b
--- /dev/null
+++ b/autoload/unite/sources/sonictemplate.vim
@@ -0,0 +1,36 @@
+" File: sonictemplate
+" Author: kmnk <kmnknmk+vim@gmail.com>
+" Version: 0.1.0
+" License: BSD style license
+
+let s:save_cpo = &cpo
+set cpo&vim
+
+function! unite#sources#sonictemplate#define()"{{{
+ return s:source
+endfunction"}}}
+
+let s:source = {
+\ 'name' : 'sonictemplate',
+\ 'description' : 'disp templates for sonictemplate',
+\}
+
+function! s:source.gather_candidates(args, context)"{{{
+ call unite#print_message('[sonictemplate]')
+ return map(sonictemplate#templates(), '{
+\ "word" : s:to_template_name(v:val),
+\ "source" : s:source.name,
+\ "kind" : s:source.name,
+\ "action__mode" : len(a:args) > 0 ? args[0] : "n"
+\ }')
+endfunction"}}}
+
+" local functions {{{
+function! s:to_template_name(path)
+ return substitute(fnamemodify(a:path, ':t:r'), '^\%(base\|snip\)-', '', '')
+endfunction
+" }}}
+
+let &cpo = s:save_cpo
+unlet s:save_cpo
+" __END__