F5 is to compile only.
This commit is contained in:
@@ -18,11 +18,11 @@ endif
|
|||||||
"
|
"
|
||||||
" Windows {{{1
|
" Windows {{{1
|
||||||
"
|
"
|
||||||
function! s:CompileMSVC() "{{{2
|
function! s:CompileMSVC(run) "{{{2
|
||||||
let exename=expand("%:p:r:s,$,.exe,")
|
let exename=expand("%:p:r:s,$,.exe,")
|
||||||
let srcname=expand("%")
|
let srcname=expand("%")
|
||||||
" compile it
|
" 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
|
echo ccline
|
||||||
let cout = system( ccline )
|
let cout = system( ccline )
|
||||||
if v:shell_error
|
if v:shell_error
|
||||||
@@ -31,14 +31,16 @@ function! s:CompileMSVC() "{{{2
|
|||||||
endif
|
endif
|
||||||
echo cout
|
echo cout
|
||||||
" run it
|
" run it
|
||||||
let cmdline="\"set PATH=".g:ldlibpath.$PATH." && ".exename." ".g:argv."\""
|
if a:run==1
|
||||||
echo exename." ".g:argv
|
let cmdline="\"set PATH=".g:ldlibpath.$PATH." && ".exename." ".g:argv."\""
|
||||||
"echo cmdline
|
echo exename." ".g:argv
|
||||||
let eout = system( cmdline )
|
"echo cmdline
|
||||||
echo eout
|
let eout = system( cmdline )
|
||||||
|
echo eout
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:CompileJava() "{{{2
|
function! s:CompileJava(run) "{{{2
|
||||||
" compile it
|
" compile it
|
||||||
let cmd = "javac " . g:javaflags . " " . expand("%")
|
let cmd = "javac " . g:javaflags . " " . expand("%")
|
||||||
echo cmd
|
echo cmd
|
||||||
@@ -56,20 +58,20 @@ function! s:CompileJava() "{{{2
|
|||||||
echo eout
|
echo eout
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:CompileWindows() "{{{2
|
function! s:CompileWindows(run) "{{{2
|
||||||
let ext=expand("%:e")
|
let ext=expand("%:e")
|
||||||
if ext=="java"
|
if ext=="java"
|
||||||
call s:CompileJava()
|
call s:CompileJava(a:run)
|
||||||
endif
|
endif
|
||||||
if ext=="cpp"
|
if ext=="cpp"
|
||||||
call s:CompileMSVC()
|
call s:CompileMSVC(a:run)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"
|
"
|
||||||
" Linux {{{1
|
" Linux {{{1
|
||||||
"
|
"
|
||||||
function! s:CompileGCC() "{{{2
|
function! s:CompileGCC(run) "{{{2
|
||||||
let exename=expand("%:p:r:s,$,.exe,")
|
let exename=expand("%:p:r:s,$,.exe,")
|
||||||
let srcname=expand("%")
|
let srcname=expand("%")
|
||||||
" compile it
|
" compile it
|
||||||
@@ -82,14 +84,16 @@ function! s:CompileGCC() "{{{2
|
|||||||
endif
|
endif
|
||||||
call s:appendOutput(cout)
|
call s:appendOutput(cout)
|
||||||
" run it
|
" run it
|
||||||
let cmdline="LD_LIBRARY_PATH=".g:ldlibpath.":".$LD_LIBRARY_PATH." ".exename." ".g:argv
|
if a:run == 1
|
||||||
call s:appendOutput(cmdline)
|
let cmdline="LD_LIBRARY_PATH=".g:ldlibpath.":".$LD_LIBRARY_PATH." ".exename." ".g:argv
|
||||||
let eout = system( cmdline )
|
call s:appendOutput(cmdline)
|
||||||
call s:appendOutput(eout)
|
let eout = system( cmdline )
|
||||||
|
call s:appendOutput(eout)
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:CompileLinux() "{{{2
|
function! s:CompileLinux(run) "{{{2
|
||||||
call s:CompileGCC()
|
call s:CompileGCC(a:run)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"
|
"
|
||||||
@@ -154,12 +158,14 @@ function! s:initDefaults()
|
|||||||
let g:wcppflags="/O2 /EHsc /DWIN32"
|
let g:wcppflags="/O2 /EHsc /DWIN32"
|
||||||
let g:lcppflags="-O2"
|
let g:lcppflags="-O2"
|
||||||
let g:ldflags=""
|
let g:ldflags=""
|
||||||
|
let g:wldflags=""
|
||||||
let g:ldlibpath=""
|
let g:ldlibpath=""
|
||||||
|
let g:cf5run=false
|
||||||
endfunction
|
endfunction
|
||||||
"
|
"
|
||||||
" Load compile instructions and call window or linux compiler. {{{1
|
" Load compile instructions and call window or linux compiler. {{{1
|
||||||
"
|
"
|
||||||
function! CF5Compile()
|
function! CF5Compile(run)
|
||||||
if &modified == 1
|
if &modified == 1
|
||||||
echo "The buffer is not saved. First save it."
|
echo "The buffer is not saved. First save it."
|
||||||
return
|
return
|
||||||
@@ -190,9 +196,9 @@ function! CF5Compile()
|
|||||||
" Compile.
|
" Compile.
|
||||||
"
|
"
|
||||||
if has("win32") || has("win64")
|
if has("win32") || has("win64")
|
||||||
call s:CompileWindows()
|
call s:CompileWindows(a:run)
|
||||||
else
|
else
|
||||||
call s:CompileLinux()
|
call s:CompileLinux(a:run)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
@@ -166,7 +166,8 @@ endfunction
|
|||||||
if !exists('*CF5Compile')
|
if !exists('*CF5Compile')
|
||||||
runtime plugin/cf5-compiler.vim
|
runtime plugin/cf5-compiler.vim
|
||||||
endif
|
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,
|
" 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.
|
" so that you can undo CTRL-U after inserting a line break.
|
||||||
|
|||||||
Reference in New Issue
Block a user