Vim Templte-Toolkit Compiler Plugin
先日の Vim YAML Compiler Plugin に引き続き、Template-Toolkit の Compiler Plugin。
TT2 syntax と一緒に使うといい感じ。
Perl と Template-Toolkit が必要。
if exists("current_compiler") finish endif let current_compiler = "tt2" let s:savecpo = &cpo set cpo&vim if exists(":CompilerSet") != 2 " older Vim always used :setlocal command -nargs=* CompilerSet setlocal <args> endif CompilerSet makeprg=perl\ -MTemplate\ -e\ '$f=shift\ or\ die\ qq/No\ input\ file.\\n/;$t=Template->new;if($t->process($f)){warn\ qq/$f\ syntax\ OK\\n/}else{warn\ $t->error.qq/\\n$f\ had\ compilation\ errors.\\n/}'\ % CompilerSet errorformat= \%Efile\ error\ -\ parse\ error\ -\ %f\ line\ %l:\ %m, \%C%.%#\ had\ compilation\ errors., \%-G%.%#syntax\ OK, \%Z,%-C%.%# let &cpo = s:savecpo unlet s:savecpo
これを ~/.vim/compiler/tt2.vim に作る。
発想は Vim YAML Compiler Plugin とほぼ同じ。
こっちは process を呼んでいるので、なにかを update したりしている場合に注意が必要。
何にもパラメータを渡してないので大丈夫だと思うけど。
あと、INCLUDE とかしているとエラーになる(INCLUDE_PATH を設定できないので)。
パスが固定の人は、makeprj に足しちゃえばいいかも。
TT2 の 設定はこんな感じにしている。
autocmd BufNewFile,BufRead *.tt set filetype=tt2html autocmd BufNewFile,BufRead view/**/*.html set filetype=tt2html autocmd BufNewFile,BufRead view/**/*.eml set filetype=tt2 autocmd FileType tt2,tt2html compiler tt2 autocmd FileType tt2,tt2html set ts=4 sw=2 sts=2 autocmd FileType tt2,tt2html set indentexpr=