aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattn <mattn.jp@gmail.com>2011-10-28 10:46:10 +0900
committermattn <mattn.jp@gmail.com>2011-10-28 10:46:10 +0900
commitb0a78235099adb8ca9fe0b0def31cafedf99cb14 (patch)
tree71d1586f3d9a6597ec291a371234ee492ad318a8
parent65d61396541c563ede37de7abd052453af5e5648 (diff)
downloadvim-sonictemplate-b0a78235099adb8ca9fe0b0def31cafedf99cb14.tar.gz
vim-sonictemplate-b0a78235099adb8ca9fe0b0def31cafedf99cb14.tar.bz2
vim-sonictemplate-b0a78235099adb8ca9fe0b0def31cafedf99cb14.zip
mapping.
-rw-r--r--plugin/template.vim22
1 files changed, 9 insertions, 13 deletions
diff --git a/plugin/template.vim b/plugin/template.vim
index dd742a5..5991c41 100644
--- a/plugin/template.vim
+++ b/plugin/template.vim
@@ -3,22 +3,10 @@
" This filetype plugin adds one command for the buffers:
"
" :Template {name}
-"
" Load template named as {name} in the current buffer.
-" Template file is stored in ~/.vim/template.
-" If you are using pathogen.vim, template folder is located at following.
-"
-" ~/.vim/bundle/template-vim
-" plugin
-" template.vim # This file.
-" template
-" main.go
-" package.go
-" package.perl
-" script.perl
-"
command! -nargs=1 -complete=customlist,TemplateComplete Template call s:Template(<f-args>)
+inoremap <c-y>t <esc>:call TemplateSelect()<cr>
if exists('g:template_vim_template_dir')
let s:tmpldir = g:template_vim_template_dir
@@ -26,6 +14,14 @@ else
let s:tmpldir = expand('<sfile>:p:h:h') . '/template/'
endif
+function! TemplateSelect() abort
+ let name = input(':Template ', '', 'customlist,TemplateComplete')
+ if name == ''
+ return
+ endif
+ call s:Template(name)
+endfunction
+
function! TemplateComplete(lead, cmdline, curpos) abort
if search('[^ \t]', 'wn')
return map(split(globpath(join([s:tmpldir, &ft], '/'), 'snip-' . a:lead . '*.*'), "\n"), 'fnamemodify(v:val, ":t:r")[5:]')