File: vimplate.vim

package info (click to toggle)
vim-scripts 20210124.4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,384 kB
  • sloc: perl: 420; xml: 95; makefile: 25
file content (37 lines) | stat: -rw-r--r-- 1,039 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""""""""""""""""""""""""""""""""""""""""""""
" vimplate - Template-Toolkit support for Vim
"""""""""""""""""""""""""""""""""""""""""""""
" please see:
"     :help vimplate
"   or
"     http://www.vim.org/scripts/script.php?script_id=1311
" Version:
"   vimplate 0.2.3
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" allow user to avoid loading this plugin and prevent loading twice
if exists ("loaded_vimplate")
    finish
endif
let loaded_vimplate = 1

let s:vimplate = Vimplate

function s:RunVimplate(template)
  let l:tmpfile = tempname()
  let l:cmd =  s:vimplate. " -out=" . l:tmpfile . " -template=" . a:template
  let l:line = line(".")
  execute "!" . l:cmd
  silent execute "read " . l:tmpfile
  execute delete(l:tmpfile)
  execute "normal " . l:line . "G"
  if getline(".") =~ "^$"
    execute "normal dd"
  endif
endfunction

function ListTemplates(...)
  return system(s:vimplate . " -listtemplates")
endfun

command! -complete=custom,ListTemplates -nargs=1 Vimplate call s:RunVimplate(<f-args>)