unite.vim で quickrun_config の列挙
複数の処理系から1つを選んでスムーズに実行(コンパイル)を行います。
以前にも同様の事をやったんですが、これを unite.vim を使用して実装しました。
quickrun_config に現在の filetype と同じ filetype の設定があれば列挙して実行(コンパイル)出来るようにします。
[vimrc]
" filetype ごとに quickrun の config 名を設定する let g:quickrun_compile_command = {} " unite.vim の設定 let s:action = { \ 'description' : 'quickrun compile command', \ 'is_selectable' : 1, \ } function! s:action.func(candidates) for val in a:candidates let g:quickrun_compile_command[&filetype] = val.word endfor endfunction call unite#custom_action('common', 'quickrun_compile_command', s:action) unlet s:action let s:unite_source = { \ "name" : "quickrun-select", \ "default_action" : "quickrun_compile_command" \} function! s:unite_source.gather_candidates(args, context) let cmds = filter(deepcopy(g:quickrun_config), "exists('v:val.type') ? v:val.type == &filetype : 0") return sort(values(map(cmds, "{ \ 'word' : v:key, \ 'source' : 'quickrun-select', \ 'kind' : 'common', \ }"))) endfunction call unite#define_source(s:unite_source) " unite.vim を呼び出すキーマップ nnoremap <silent> <silent> <Space>qr :Unite quickrun-select<CR> " 実行(コンパイル)を行うキーマップ nnoremap <silent> <C-F7> :execute ":QuickRun ".g:quickrun_compile_command[&filetype]<CR>
quickrun 用の unite-kind も用意したほうがいいかも。