引っ越し後の日記はコチラです
tokoromのその他の日記
- iPhoneアプリ開発関連: iPhoneアプリ開発まっしぐら★
- それ以外: 寄り道ばかりの お勉強日記★
2012-02-26
vim-quickrunで実行したRSpecの結果にレッドバー/グリーンバーを表示する
基本、
を参考にさせていただいたのですが、1点、色付けのところは普通にVimのsyntaxファイルで設定したいという思いがあり、そこだけカスタマイズしたという話です。
vimrcのRSpecに関する設定
augroup AddFileType " *_rspec.rbなファイルはファイルタイプを「ruby.rspec」にする autocmd BufWinEnter,BufNewFile *_spec.rb set filetype=ruby.rspec augroup END " quickrunの設定 let g:quickrun_config = {} let g:quickrun_config['*'] = {'runmode': "async:remote:vimproc", 'split': 'below'} let g:quickrun_config['ruby.rspec'] = {'command': 'rspec', 'cmdopt': '--format progress -I .', 'exec': ['bundle exec %c %o %s %a'], 'output_filetype': 'rspec-result'}
この最終行の
'output_filetype': 'rspec-result'
という設定が、vim-quickrunをカスタマイズして追加した項目で、quickrunで実行した結果を表示するバッファのファイルタイプを 'rspec-result' とするという設定になります。
カスタマイズしたvim-quickrun
に置いてあります。
syntaxファイルの追加
最後に、上記で設定した 'rspec-result' というファイルタイプに対するsyntaxファイルを設置します。
● .vim/syntax/rspec-result.vim
if exists("b:current_syntax") finish endif if !exists("main_syntax") let main_syntax = 'rspec-result' endif syntax case match syntax match RSpecGreen /^\.*$/ syntax match RSpecRed /^[F.]*F[F.]*$/ syntax match RSpecGreen /^.* 0 failure.*$/ syntax match RSpecRed /^.* [1-9][0-9]* failure.*$/ highlight RSpecGreen ctermfg=White ctermbg=Green guifg=White guibg=Green highlight RSpecRed ctermfg=White ctermbg=Red guifg=White guibg=Red "unlet b:current_syntax let b:current_syntax = 'rspec-result' if main_syntax == 'rspec-result' unlet main_syntax endif
実行結果
これらを設定してRSpecをquickrunで実行すると、
● レッドバー
● グリーンバー
といった感じにレッドバー/グリーンバーが表示されて気分良くTDDできそうです。
syntaxファイルはお好みでご調整ください。
2012/03/13 追記
ちなみに、本家の v0.6.0 で以下のようにconfigで'filetype'を指定することで、同様に quickrun output のfiletypeを指定できるようになるようです。
let g:quickrun_config['ruby.rspec'] = {'command': 'rspec', 'cmdopt': '--format progress -I .', 'exec': ['bundle exec %c %o %s %a'], 'filetype': 'rspec-result'}
本家を使いたい人は上記がmasterに取り込まれるのを待つか、v0.6.0devブランチを直接指定して使いましょう。
kano42012/02/27 11:01なるほど。今まで.vimrcが汚くなっていやだったんですが、色付けはsyntaxファイルに切りだしちゃえばスッキリするんですね。参考になります!
Buakaw2012/06/28 22:21Knowledge wants to be free, just like these airtlces!
qmiiwns2012/06/30 08:30tFkhjR , [url=http://gkvhwrhxcbyb.com/]gkvhwrhxcbyb[/url], [link=http://jqmkauvlnlkx.com/]jqmkauvlnlkx[/link], http://ccjfhdzgtbew.com/
Joni2016/05/04 16:15No quesoitn this is the place to get this info, thanks y'all.
Cami2016/05/06 10:58All McDonalds restaurants in Ireland have had free wifi for years. It’s provided through Cisco AP and use a voucher <a href="http://zpzwxyo.com">auocintihatetn</a> system.Uptake is low. I have never seen anyone (apart from myself) use it and most of the staff seem to be unaware of it. The fact that the vouchers are stored in the managers office instead of being kept at the checkout doesn’t help either. It’s step in the right direction though…
Maggie2016/05/08 03:04Koz, l’édition dans les minutes qui suivent la rédaction d’un commentaire n’est plus active? C’est embarrassant pour les fautes découvertes a por3eriosiRt0; http://rdalkuegvz.com [url=http://ozjlxe.com]ozjlxe[/url] [link=http://emzduejwq.com]emzduejwq[/link]
Sable2016/05/08 06:41Well, this just made me homesick! I'm originally from Atlanta, though I have to admit that if I had to choose somewhere to live that it would probably be right where we are in <a href="http://ehsvbpzllvg.com">Coehepagnn.</a> Next on my list would be Spain again or maybe Seattle in the States.
Adelaide2016/05/09 16:27Today, taking into coteadsrinion the fast chosen lifestyle that everyone leads, credit cards get this amazing demand throughout the economy. Persons throughout every area are using the credit card and people who are not using the credit card have made arrangements to apply for one in particular. Thanks for spreading your ideas in credit cards. http://bmomexylk.com [url=http://jksmzecykkh.com]jksmzecykkh[/url] [link=http://cfllzirirc.com]cfllzirirc[/link]
enebexah2019/03/29 21:47http://theprettyguineapig.com/amoxicillin/ - 18 <a href="http://theprettyguineapig.com/amoxicillin/">Amoxil</a> wjo.aeit.vim.g.hatena.ne.jp.vfv.rq http://theprettyguineapig.com/amoxicillin/
ijefoluc2019/03/29 22:27http://theprettyguineapig.com/amoxicillin/ - Amoxicillin Online <a href="http://theprettyguineapig.com/amoxicillin/">Amoxicillin 500 Mg</a> jvy.glwc.vim.g.hatena.ne.jp.myy.iy http://theprettyguineapig.com/amoxicillin/
ofoletava2019/03/30 00:17http://theprettyguineapig.com/amoxicillin/ - Amoxicillin <a href="http://theprettyguineapig.com/amoxicillin/">Amoxicillin</a> ygp.fcdz.vim.g.hatena.ne.jp.cyh.gq http://theprettyguineapig.com/amoxicillin/
ipxeleni2019/03/30 01:02http://theprettyguineapig.com/amoxicillin/ - Amoxicillin <a href="http://theprettyguineapig.com/amoxicillin/">Buy Amoxicillin Online</a> nei.gegj.vim.g.hatena.ne.jp.ozg.ch http://theprettyguineapig.com/amoxicillin/