OmniSharp を使用して quickrun.vim する

最近何かと話題の OmniSharp ですが OmniSharp を利用して quickrun.vim でプロジェクトのビルドを行えるような設定を書いてみました。

[ソース]

" quickrun-omnisharp {{{
let s:hook = {
\   "name" : "omnisharp",
\   "kind" : "hook",
\   "config" : {
\       "enable" : 0,
\   },
\}

function! s:hook.on_module_loaded(session, context)
    python buildcommand()
    let command = substitute(b:buildcommand, '\\', '\/', 'g')

    if type(a:session.config.exec) == type([])
        let a:session.config.exec[0] = command
    else
        let a:session.config.exec = command
    endif
endfunction

call quickrun#module#register(s:hook, 1)
unlet s:hook
" }}}


let g:quickrun_config = {
\   '_' : {
\       "runner" : "vimproc",
\       "runner/vimproc/updatetime" : 60,
\       "runner/vimproc/sleep" : 10,
\   },
\   'cs/omnisharp' : {
\       "hook/omnisharp/enable" : 1,
\       "hook/output_encode/encoding" : "sjis",
\       "outputter/quickfix/errorformat" : '%f(%l\\,%c):\ error\ CS%n:\ %m',
\       "outputter" : "quickfix",
\   },
\}

こんな感じです。
実装は python buildcommand() + b:buildcommand でビルド用のコマンドが取得できるのでそれを動的に quickrun.vim へと設定しているだけですね。
quickrun.vim を使用できるので当然、vimproc を使用した非同期ビルドを行えることもできますし、出力先の設定や hook なども行えることが出来ます。
便利ですね。