errormarker.vim を使って flymake っぽくするやつを試してみた
smjs のコマンドラインオプション修正。詳しくはコメント欄参照。
ruby 用の設定を追記
dann@catalyst - Catalystグループを参考に書き直し。グローバル変数がなくなったよ!
ついでに、ファイルをまとめてみた。
ファイルタイプごとに共通なところは、もっとまとめたりできそうですね。
errormarker.vim - Highlights and sets error markers for lines with compile errors : vim onlineをインストールした後の話
for perl
まず、perl 用の設定 (ref: errormarker.vim で flymake(Emacsの) る - #生存戦略 、それは - subtech)
cp /usr/share/vim/vim71/tools/efm_perl.pl ~/.vim/vimparse.pl
setlocal makeprg=$HOME/.vim/vimparse.pl\ -c\ %\ $* setlocal errorformat=%f:%l:%m au BufWritePost <buffer> silent make
~/.vim/ftplugin/perl/flyquickfixmake.vim に
setlocal makeprg=$HOME/.vim/vimparse.pl\ -c\ %\ $* setlocal errorformat=%f:%l:%m if !exists("g:perl_flyquickfixmake") let g:perl_flyquickfixmake = 1 au BufWritePost *.pm,*.pl,*.t silent make endif
for JavaScript
次、JavaScript 用の設定 (ref: errormaker.vim と JS の syntax error 検知 - 冬通りに消え行く制服ガールは✖夢物語にリアルを求めない。 - subtech)
sudo aptitude install spidermonkey-bin
~/.vim/ftplugin/javascript.vim に
"" for spidermonkey setlocal makeprg=smjs\ -w\ -s\ -C\ % setlocal errorformat=%f:%l:%m " "" for rhino " setlocal makeprg=rhino\ -w\ -strict\ -debug\ % " setlocal errorformat="js: %f, line %l:%m" au BufWritePost <buffer> silent make
~/.vim/vimparse.js に
#!/bin/sh ## for rhino # rhino -w -strict -debug $* ## for spidermonkey ## sudo aptitude install spidermonkey-bin smjs -wsC $*
~/.vim/ftplugin/javascript/flyquickfixmake.vim に
setlocal makeprg=$HOME/.vim/vimparse.js\ %\ $* "" for rhino " setlocal errorformat="js: %f, line %l:%m" "" for spidermonkey setlocal errorformat=%f:%l:%m if !exists("g:javascript_flyquickfixmake") let g:javascript_flyquickfixmake = 1 au BufWritePost *.js silent make endif
smjs のコマンドラインオプションの詳細が不明だったので調べたけど、それらしい情報を発見できず...。
じゃぁってことで、コマンドラインオプション解析部分のコードを読んでみた結果、以下のような感じらしい。
v | バージョン情報表示 |
w | 警告 on |
W | 警告 off |
s | strict on |
x | xml on? |
P | ??? |
b | branch limit |
c | stack chunk size |
f | ファイル指定 |
e | コマンドラインであたえたものを、そのまま実行 |
C | compile only |
i | interactive mode |
S | max stack size |
z | ??? |
ところで、初めは smjs の代わりに rhino を使ってみたんだけど、この用途では断然 smjs の方が軽いので smjs を使うことにした。
% time smjs -wsC test.user.j test.user.js:11: SyntaxError: missing ; before statement: test.user.js:11: va r Class = function() { return function() { this.initialize.apply(this, arguments) } }; test.user.js:11: .......^ [2] 5723 exit 3 smjs -wsC test.user.j smjs -wsC test.user.js 0.00s user 0.00s system 0% cpu 0.017 total
% time rhino -w -strict -debug test.user.j js: "test.user.js", line 11: missing ; before statement js: va r Class = function() { return function() { this.initialize.apply(this, arguments) } }; js: ........^ js: "test.user.js", line 1: Compilation produced 1 syntax errors. [2] 5590 exit 3 rhino -w -strict -debug test.user.j rhino -w -strict -debug test.user.js 0.27s user 0.02s system 88% cpu 0.334 total
for ruby
""" for error marker setlocal makeprg=ruby\ -cdw\ % setlocal errorformat=%f:%l:%m au BufWritePost <buffer> silent make
~/.vim/ftplugin/ruby/flyquickfixmake.vim に
setlocal makeprg=ruby\ -cdw\ % setlocal errorformat=%f:%l:%m if !exists("g:ruby_flyquickfixmake") let g:ruby_flyquickfixmake = 1 au BufWritePost *.rb silent make endif