aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattn <mattn.jp@gmail.com>2014-08-01 11:40:41 +0900
committermattn <mattn.jp@gmail.com>2014-08-01 11:40:41 +0900
commit1786d7d8fce44fceaa4f255aba6005bb07e31de9 (patch)
tree65a9008ed7f062d84e755b0eea126c285f1e3710
parente253ae8a6075772da96081ab8b6c360ea77e6288 (diff)
downloadvim-sonictemplate-1786d7d8fce44fceaa4f255aba6005bb07e31de9.tar.gz
vim-sonictemplate-1786d7d8fce44fceaa4f255aba6005bb07e31de9.tar.bz2
vim-sonictemplate-1786d7d8fce44fceaa4f255aba6005bb07e31de9.zip
file- prefix
-rw-r--r--autoload/sonictemplate.vim26
1 files changed, 20 insertions, 6 deletions
diff --git a/autoload/sonictemplate.vim b/autoload/sonictemplate.vim
index b1fe31e..4eb2887 100644
--- a/autoload/sonictemplate.vim
+++ b/autoload/sonictemplate.vim
@@ -76,6 +76,11 @@ function! s:get_candidate(fts, lead)
catch
endtry
let tmp = []
+ if prefix == 'base'
+ for tmpldir in s:tmpldir
+ let tmp += map(split(globpath(join([tmpldir, ft], '/'), 'file-' . expand('%:t:r') . '*.*'), "\n"), 'fnamemodify(v:val, ":t:r")[5:]')
+ endfor
+ endif
for tmpldir in s:tmpldir
for ft in fts
let tmp += sort(map(split(globpath(join([tmpldir, ft], '/'), prefix . '-' . a:lead . '*.*'), "\n"), 'fnamemodify(v:val, ":t:r")[5:]'))
@@ -163,13 +168,22 @@ function! sonictemplate#apply(name, mode, ...) abort
else
let fts = [ft]
endif
- for tmpldir in s:tmpldir
- for ft in fts
- if len(ft) > 0
- let fs += sort(split(globpath(join([tmpldir, ft], '/'), prefix . '-' . name . '.*'), "\n"))
- endif
+ if prefix == 'base'
+ for tmpldir in s:tmpldir
+ for ft in fts
+ let fs += sort(split(globpath(join([tmpldir, ft], '/'), 'file-' . name . '.*'), "\n"))
+ endfor
endfor
- endfor
+ endif
+ if len(fs) == 0
+ for tmpldir in s:tmpldir
+ for ft in fts
+ if len(ft) > 0
+ let fs += sort(split(globpath(join([tmpldir, ft], '/'), prefix . '-' . name . '.*'), "\n"))
+ endif
+ endfor
+ endfor
+ endif
if len(fs) == 0
echomsg 'Template '.name.' is not exists.'
return