quickrun.vimで実行したPHPUnitの結果にグリーンバーを出す

Vimテクニックバイブル ?作業効率をカイゼンする150の技

Vimテクニックバイブル ?作業効率をカイゼンする150の技


待ちに待ったVimテクニックバイブルで今までの環境を一気に変え始めています
TDDBCでid:t-wadaさんに道具の大切を教わったので
プログラマの命とも言えるエディタを鍛えていきます!


とりあえずVundleでプラグインをガンガン入れていたのですが
quickrun.vimPHPUnitの設定をしていると、、
テスト結果にグリーンバーが見えない。。。


色々格闘した挙句
自分でoutputterを書けば良い!ということで
以下の感じになりました

"" vim-quickrun
" init
let g:quickrun_config = {}

" set for phpunit
augroup QuickRunPHPUnit
  autocmd!
  autocmd BufWinEnter,BufNewFile *Test.php set filetype=php.unit
augroup END

" make outputter for coloring output message.
let phpunit_outputter = quickrun#outputter#buffer#new()
function! phpunit_outputter.init(session)
  " call original process
  call call(quickrun#outputter#buffer#new().init, [a:session], self)
endfunction

function! phpunit_outputter.finish(session)
  " set color 
  highlight default PhpUnitOK         ctermbg=Green ctermfg=White
  highlight default PhpUnitFail       ctermbg=Red   ctermfg=White
  highlight default PhpUnitAssertFail ctermfg=Red
  call matchadd("PhpUnitFail","^FAILURES.*$")
  call matchadd("PhpUnitOK","^OK.*$")
  call matchadd("PhpUnitAssertFail","^Failed.*$")
  call call(quickrun#outputter#buffer#new().finish, [a:session], self)
endfunction

" regist outputter to quickrun
call quickrun#register_outputter("phpunit_outputter", phpunit_outputter)

" PHPUNIT
let g:quickrun_config['php.unit'] = {
      \ 'command': 'phpunit',
      \ 'outputter': 'phpunit_outputter',
      \ }

*Test.phpに該当するスクリプトを編集中に
quickrun.vimを実行するとグリーンバー、レッドバーが出現します!
難しいことは特にやっていなくてhiglightのところを変えれば好きな色がだせます


今書いているvimrcはgithubで管理しているので
興味ある方は覗いてみてください


https://github.com/ukoasis/dotfiles


いや〜環境見なおすの大事ですね〜
次は何から手をつけようか。。