aboutsummaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorkmnk <kmnknmk+com-github@gmail.com>2012-03-08 08:15:32 +0900
committermattn <mattn.jp@gmail.com>2013-05-09 16:45:21 +0900
commitfb7c68116c686e816e6027d93b7eae9473bf6873 (patch)
tree9a4d28d4d1a7fb1ed49390198063ec9e1b2d8834 /autoload
parent751a067c55aa15a4a019cc92552843f1da3d77cc (diff)
downloadvim-sonictemplate-fb7c68116c686e816e6027d93b7eae9473bf6873.tar.gz
vim-sonictemplate-fb7c68116c686e816e6027d93b7eae9473bf6873.tar.bz2
vim-sonictemplate-fb7c68116c686e816e6027d93b7eae9473bf6873.zip
put a high priority on pre defined template
Diffstat (limited to 'autoload')
-rw-r--r--autoload/unite/sources/sonictemplate.vim27
1 files changed, 21 insertions, 6 deletions
diff --git a/autoload/unite/sources/sonictemplate.vim b/autoload/unite/sources/sonictemplate.vim
index 1b07584..dea3092 100644
--- a/autoload/unite/sources/sonictemplate.vim
+++ b/autoload/unite/sources/sonictemplate.vim
@@ -17,15 +17,30 @@ let s:source = {
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"
-\ }')
+ return map(
+\ s:uniq(map(sonictemplate#templates(), 's:to_template_name(v:val)')), '{
+\ "word" : v:val,
+\ "source" : s:source.name,
+\ "kind" : s:source.name,
+\ "action__mode" : len(a:args) > 0 ? args[0] : "n"
+\ }'
+\ )
endfunction"}}}
" local functions {{{
+function! s:uniq(list)
+ let has = {}
+ let uniq_list = []
+ for i in a:list
+ if exists(printf("has['%s']", i))
+ continue
+ endif
+ let has[i] = 1
+ call add(uniq_list, i)
+ endfor
+ return uniq_list
+endfunction
+
function! s:to_template_name(path)
return substitute(fnamemodify(a:path, ':t:r'), '^\%(base\|snip\)-', '', '')
endfunction