Quickrun で、複数の設定から選択してコンパイルする
SingleCompile の [:SCChooseCompiler] コマンドを Quickrun でも再現してみました。
複数のコンパイラ設定や、細かいオプションの違いなんかを予め複数設定しておいて、用途によって設定を切り替えます。
(特に C++ は、msvc と gcc で結果が違ったり、C++0x の有無があったりするので)
もっといい方法があるかも知れませんが、わたしにはこれが限界……。
方向性が間違っている気がしないでもない。
[Quickrun]
- v 0.5.0 dev
[_vimrc]
" QuickRun の呼び出しを行うキーバインド " とりあえず、ビルドと実行を分けて設定 let g:quickrun_compile_command="" " コンパイル nnoremap <C-F7> :execute ":QuickRun ".g:quickrun_compile_command<CR> " コンパイラの選択 command QRChoiceCompiler call QRChoiceCompiler(&filetype) " 設定を列挙して選択 function! QRChoiceCompiler(lang_name) let l:filetype=a:lang_name let l:choose_list=[] let l:choose_list_display = [] let l:count=1 for key in keys(g:quickrun_config) let l:value = g:quickrun_config[key] if exists("l:value.type") && l:value.type == l:filetype call add(l:choose_list, key) call add(l:choose_list_display, l:count.":".key) let l:count += 1 endif endfor if empty(l:choose_list) return endif let l:user_choose = inputlist( extend(["Detected compilers:"], \ l:choose_list_display)) if l:user_choose <= 0 return elseif l:user_choose > len(l:choose_list_display) return endif let g:quickrun_compile_command=get(l:choose_list,l:user_choose-1) endfunction
[コマンド]
:QRChooseCompiler | g:quickrun_config から filetype に一致する設定を列挙して設定 |
---|
[キーバインド]
選択されている設定で、Quickrun を実行 |
[使い方]
g:quickrun_config から {type} == filetype に一致する設定を列挙して選択します。
g:quickrun_config 以外に書かれている設定は参照していないので注意してください。
また、{type} を書いておく必要があります。
挙動自体は、殆ど SingleCompile からコピペしているので、 [:SCChooseCompiler] コマンドと変わらないと思います。
これで、簡単に Quickrun の設定を切り替えることが出来ます。
やったね!
しかし、Quickrun 的に間違っている気がしないでもない。
g:quickrun_config の使い方ってこれであってるんですかね。
誰かわたしに Quickrun の使い方を教えて下さい……。
あとついでに unite-quickrun-compiler みたいなのを書いてもいいかもしれない。
選択したファイルやバッファを Quickrun する unite-action-quickrun とかも。
やってみたいことが結構あって、ぐぬぬ……。