From 1d6feb78c99b98f51624322b344b280b9e0c5880 Mon Sep 17 00:00:00 2001 From: Vahagn Khachatryan Date: Tue, 9 Jul 2013 14:48:58 +0400 Subject: [PATCH] F5 is to compile only. --- vim/cf5-compiler.vim | 48 +++++++++++++++++++++++++------------------- vim/vimrc | 3 ++- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/vim/cf5-compiler.vim b/vim/cf5-compiler.vim index fb92c57..1357af4 100755 --- a/vim/cf5-compiler.vim +++ b/vim/cf5-compiler.vim @@ -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 - let cmdline="\"set PATH=".g:ldlibpath.$PATH." && ".exename." ".g:argv."\"" - echo exename." ".g:argv - "echo cmdline - let eout = system( cmdline ) - echo eout + 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 - 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) + 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 diff --git a/vim/vimrc b/vim/vimrc index 11f2001..a6028a3 100755 --- a/vim/vimrc +++ b/vim/vimrc @@ -166,7 +166,8 @@ endfunction if !exists('*CF5Compile') runtime plugin/cf5-compiler.vim endif -map :call CF5Compile() +map :call CF5Compile(1) +map :call CF5Compile(0) " " 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.