Skip to content

Instantly share code, notes, and snippets.

@osyo-manga
Created June 16, 2011 17:11
Show Gist options
  • Save osyo-manga/1029711 to your computer and use it in GitHub Desktop.
Save osyo-manga/1029711 to your computer and use it in GitHub Desktop.
" g:quickrun_config の初期化
if !exists("g:quickrun_config")
let g:quickrun_config={}
endif
" デフォルトの設定
let g:quickrun_config["_"] = {
\ "runner/vimproc/updatetime" : 100,
\ "split": "{'rightbelow 8sp'}"
\ }
" 実行
let g:quickrun_config["run/vimproc"] = {
\ "exec": "%s:p:r %a",
\ "output_encode" : "utf-8",
\ "runner" : "system",
\ "outputter" : "buffer"
\ }
" QuickRun の呼び出しを行うキーバインド
" とりあえず、ビルドと実行を分けて設定
let g:quickrun_build_command=""
let g:quickrun_run_command="run/vimproc"
" コンパイル
nnoremap <C-F7> :execute ":QuickRun ".g:quickrun_build_command<CR>
" 実行
nnoremap <C-F5> :execute ":QuickRun ".g:quickrun_run_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)
call s:ShowMessage(
\'No compiler is available for this language!')
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)
echo ' '
call s:ShowMessage(
\'The number you have chosen is invalid.')
return
endif
let g:quickrun_build_command=get(l:choose_list,l:user_choose-1)
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment