F5 is to compile only.

This commit is contained in:
2013-07-09 14:48:58 +04:00
parent 0c99ee6dfd
commit 1d6feb78c9
2 changed files with 29 additions and 22 deletions

View File

@@ -18,11 +18,11 @@ endif
"
" Windows {{{1
"
function! s:CompileMSVC() "{{{2
function! s:CompileMSVC(run) "{{{2
let exename=expand("%:p:r:s,$,.exe,")
let srcname=expand("%")
" compile it
let ccline="cl ".g:cppflags." ".g:wcppflags." ".srcname." /Fe".exename." /link ".g:ldflags
let ccline="cl ".g:cppflags." ".g:wcppflags." ".srcname." /Fe".exename." /link ".g:ldflags. " ".g:wldflags
echo ccline
let cout = system( ccline )
if v:shell_error
@@ -31,14 +31,16 @@ function! s:CompileMSVC() "{{{2
endif
echo cout
" run it
if a:run==1
let cmdline="\"set PATH=".g:ldlibpath.$PATH." && ".exename." ".g:argv."\""
echo exename." ".g:argv
"echo cmdline
let eout = system( cmdline )
echo eout
endif
endfunction
function! s:CompileJava() "{{{2
function! s:CompileJava(run) "{{{2
" compile it
let cmd = "javac " . g:javaflags . " " . expand("%")
echo cmd
@@ -56,20 +58,20 @@ function! s:CompileJava() "{{{2
echo eout
endfunction
function! s:CompileWindows() "{{{2
function! s:CompileWindows(run) "{{{2
let ext=expand("%:e")
if ext=="java"
call s:CompileJava()
call s:CompileJava(a:run)
endif
if ext=="cpp"
call s:CompileMSVC()
call s:CompileMSVC(a:run)
endif
endfunction
"
" Linux {{{1
"
function! s:CompileGCC() "{{{2
function! s:CompileGCC(run) "{{{2
let exename=expand("%:p:r:s,$,.exe,")
let srcname=expand("%")
" compile it
@@ -82,14 +84,16 @@ function! s:CompileGCC() "{{{2
endif
call s:appendOutput(cout)
" run it
if a:run == 1
let cmdline="LD_LIBRARY_PATH=".g:ldlibpath.":".$LD_LIBRARY_PATH." ".exename." ".g:argv
call s:appendOutput(cmdline)
let eout = system( cmdline )
call s:appendOutput(eout)
endif
endfunction
function! s:CompileLinux() "{{{2
call s:CompileGCC()
function! s:CompileLinux(run) "{{{2
call s:CompileGCC(a:run)
endfunction
"
@@ -154,12 +158,14 @@ function! s:initDefaults()
let g:wcppflags="/O2 /EHsc /DWIN32"
let g:lcppflags="-O2"
let g:ldflags=""
let g:wldflags=""
let g:ldlibpath=""
let g:cf5run=false
endfunction
"
" Load compile instructions and call window or linux compiler. {{{1
"
function! CF5Compile()
function! CF5Compile(run)
if &modified == 1
echo "The buffer is not saved. First save it."
return
@@ -190,9 +196,9 @@ function! CF5Compile()
" Compile.
"
if has("win32") || has("win64")
call s:CompileWindows()
call s:CompileWindows(a:run)
else
call s:CompileLinux()
call s:CompileLinux(a:run)
endif
endfunction

View File

@@ -166,7 +166,8 @@ endfunction
if !exists('*CF5Compile')
runtime plugin/cf5-compiler.vim
endif
map <silent> <C-F5> :call CF5Compile()<CR>
map <silent> <C-F5> :call CF5Compile(1)<CR>
map <silent> <F5> :call CF5Compile(0)<CR>
"
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.