vimrc and the helper scripts
This commit is contained in:
84
vim/cf5-compiler.vim
Executable file
84
vim/cf5-compiler.vim
Executable file
@@ -0,0 +1,84 @@
|
||||
"
|
||||
" Functions to compile and link a single c/cpp file.
|
||||
"
|
||||
"if exists("g:loaded_vahagn_compiler") | finish | endif
|
||||
let g:loaded_vahagn_compiler = 1
|
||||
|
||||
"
|
||||
" Make sure let-modeline.vim is loaded.
|
||||
"
|
||||
if !exists('*FirstModeLine')
|
||||
runtime plugin/let-modeline.vim
|
||||
endif
|
||||
|
||||
"
|
||||
" Windows
|
||||
"
|
||||
let g:cppflags=" "
|
||||
let g:wcppflags="/O2 /EHsc"
|
||||
function! s:CompileMSVC()
|
||||
let exename=expand("%:p:r:s,$,.exe,")
|
||||
let srcname=expand("%")
|
||||
" compile it
|
||||
let ccline="cl ".g:cppflags." ".g:wcppflags." ".srcname." /Fe".exename
|
||||
echo ccline
|
||||
let cout = system( ccline )
|
||||
if v:shell_error
|
||||
echo cout
|
||||
return
|
||||
endif
|
||||
" run it
|
||||
echo exename
|
||||
let eout = system( exename )
|
||||
echo eout
|
||||
endfunction
|
||||
|
||||
function! s:CompileWindows()
|
||||
call s:CompileMSVC()
|
||||
endfunction
|
||||
|
||||
"
|
||||
" Linux
|
||||
"
|
||||
let g:lcppflags="-O2"
|
||||
function! s:CompileGCC()
|
||||
let exename=expand("%:p:r:s,$,.exe,")
|
||||
let srcname=expand("%")
|
||||
" compile it
|
||||
let ccline="g++ ".g:cppflags." ".g:lcppflags." ".srcname." -o".exename
|
||||
echo ccline
|
||||
let cout = system( ccline )
|
||||
if v:shell_error
|
||||
echo cout
|
||||
return
|
||||
endif
|
||||
echo cout
|
||||
" run it
|
||||
let cmdline="LD_LIBRARY_PATH=".g:ldlibrarypath.":".$LD_LIBRARY_PATH." ".exename
|
||||
echo cmdline
|
||||
let eout = system( cmdline )
|
||||
echo eout
|
||||
endfunction
|
||||
|
||||
function! s:CompileLinux()
|
||||
call s:CompileGCC()
|
||||
endfunction
|
||||
|
||||
"
|
||||
" Load compile instructions and call window or linux compiler.
|
||||
"
|
||||
function! CF5Compile()
|
||||
source expand("%:p:h")."/compile-opt.vim"
|
||||
call FirstModeLine()
|
||||
if exists("g:cf5script")
|
||||
execute g:cf5script
|
||||
endif
|
||||
if has("win32") || has("win64")
|
||||
call s:CompileWindows()
|
||||
else
|
||||
call s:CompileLinux()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user