Merge branch 'master' of bitbucket.org:vishap/scripts
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
"
|
"
|
||||||
"
|
"
|
||||||
" {{{1
|
|
||||||
" Functions to compile and link a single c/cpp/java files.
|
" Functions to compile and link a single c/cpp/java files.
|
||||||
"
|
"
|
||||||
" let g:cf5output
|
" let g:cf5output
|
||||||
@@ -20,7 +19,22 @@ if !exists('*FirstModeLine')
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
"
|
"
|
||||||
" Windows {{{1
|
" Init global variables with default values.
|
||||||
|
"
|
||||||
|
function! s:initDefaults()
|
||||||
|
let g:cf5output=0
|
||||||
|
let g:argv=""
|
||||||
|
let g:pyflags=""
|
||||||
|
let g:cppflags=""
|
||||||
|
let g:wcppflags="/O2 /EHsc /DWIN32"
|
||||||
|
let g:lcppflags="-O2"
|
||||||
|
let g:ldflags=""
|
||||||
|
let g:wldflags=""
|
||||||
|
let g:ldlibpath=""
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
"
|
||||||
|
" Microsoft Visual C++
|
||||||
"
|
"
|
||||||
function! s:CompileMSVC(run) "{{{2
|
function! s:CompileMSVC(run) "{{{2
|
||||||
let exename=expand("%:p:r:s,$,.exe,")
|
let exename=expand("%:p:r:s,$,.exe,")
|
||||||
@@ -35,62 +49,24 @@ function! s:CompileMSVC(run) "{{{2
|
|||||||
endif
|
endif
|
||||||
echo cout
|
echo cout
|
||||||
" run it
|
" run it
|
||||||
if a:run==1
|
if a:run==1
|
||||||
let cmdline="\"set PATH=".g:ldlibpath.$PATH." && ".exename." ".g:argv."\""
|
let en = "set PATH=\"".g:ldlibpath."%PATH%\""
|
||||||
echo exename." ".g:argv
|
let cmdline=exename." ".g:argv
|
||||||
"echo cmdline
|
let cont = [ en, cmdline ]
|
||||||
let eout = system( cmdline )
|
let tf = tempname()
|
||||||
|
let tf = fnamemodify( tf, ":p:r")
|
||||||
|
let tf = tf.".bat"
|
||||||
|
call writefile( cont, tf )
|
||||||
|
|
||||||
|
let eout = system( tf )
|
||||||
echo eout
|
echo eout
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:CompileJava(run) "{{{2
|
call delete( tf )
|
||||||
" compile it
|
|
||||||
let cmd = "javac " . g:javaflags . " " . expand("%")
|
|
||||||
echo cmd
|
|
||||||
let cout = system( cmd )
|
|
||||||
echo cout
|
|
||||||
if v:shell_error
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
" run it
|
|
||||||
"let classpath=expand("%:p:r")
|
|
||||||
let exename=expand("%:r")
|
|
||||||
let cmd = "java " . exename . " " . g:argv
|
|
||||||
echo cmd
|
|
||||||
let eout = system( cmd )
|
|
||||||
echo eout
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:InterpretPython(run) "{{{2
|
|
||||||
" Interpret it
|
|
||||||
let cmd = "python " . g:pyflags . " " . expand("%") . ' ' . g:argv
|
|
||||||
echo cmd
|
|
||||||
let cout = system( cmd )
|
|
||||||
echo cout
|
|
||||||
if v:shell_error
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:CompileWindows(run) "{{{2
|
|
||||||
let ext=expand("%:e")
|
|
||||||
if ext=="java"
|
|
||||||
call s:CompileJava(a:run)
|
|
||||||
endif
|
|
||||||
if ext=="cpp"
|
|
||||||
call s:CompileMSVC(a:run)
|
|
||||||
endif
|
|
||||||
if ext=="c"
|
|
||||||
call s:CompileMSVC(a:run)
|
|
||||||
endif
|
|
||||||
if ext=="py"
|
|
||||||
call s:InterpretPython(a:run)
|
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"
|
"
|
||||||
" Linux {{{1
|
" GCC
|
||||||
"
|
"
|
||||||
function! s:CompileGCC(run) "{{{2
|
function! s:CompileGCC(run) "{{{2
|
||||||
let exename=expand("%:p:r:s,$,.exe,")
|
let exename=expand("%:p:r:s,$,.exe,")
|
||||||
@@ -114,20 +90,49 @@ function! s:CompileGCC(run) "{{{2
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:CompileLinux(run) "{{{2
|
function! s:CompileJava(run) "{{{2
|
||||||
let ext=expand("%:e")
|
" compile it
|
||||||
if ext=="java"
|
let cmd = "javac " . g:javaflags . " " . expand("%")
|
||||||
call s:CompileJava(a:run)
|
echo cmd
|
||||||
|
let cout = system( cmd )
|
||||||
|
echo cout
|
||||||
|
if v:shell_error
|
||||||
|
return
|
||||||
endif
|
endif
|
||||||
if ext=="cpp"
|
" run it
|
||||||
call s:CompileGCC(a:run)
|
"let classpath=expand("%:p:r")
|
||||||
|
let exename=expand("%:r")
|
||||||
|
let cmd = "java " . exename . " " . g:argv
|
||||||
|
echo cmd
|
||||||
|
let eout = system( cmd )
|
||||||
|
echo eout
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:InterpretPython(run)
|
||||||
|
" Interpret it
|
||||||
|
let cmd = "python " . g:pyflags . " " . expand("%") . ' ' . g:argv
|
||||||
|
echo cmd
|
||||||
|
let cout = system( cmd )
|
||||||
|
echo cout
|
||||||
|
if v:shell_error
|
||||||
|
return
|
||||||
endif
|
endif
|
||||||
if ext=="c"
|
endfunction
|
||||||
call s:CompileGCC(a:run)
|
|
||||||
|
function! s:Compile(run)
|
||||||
|
if &filetype=="c" || &filetype=="cpp"
|
||||||
|
if has("win32") || has("win64")
|
||||||
|
call s:CompileMSVC(a:run)
|
||||||
|
else
|
||||||
|
call s:CompileGCC(a:run)
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
if ext=="py"
|
if &filetype=="python"
|
||||||
call s:InterpretPython(a:run)
|
call s:InterpretPython(a:run)
|
||||||
endif
|
endif
|
||||||
|
if &filetype=="java"
|
||||||
|
call s:CompileJava(a:run)
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"
|
"
|
||||||
@@ -183,23 +188,13 @@ function! s:clearOutputWindow()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
"
|
"
|
||||||
" Init global variables with default values. {{{1
|
|
||||||
"
|
|
||||||
function! s:initDefaults()
|
|
||||||
let g:cf5output=0
|
|
||||||
let g:argv=""
|
|
||||||
let g:pyflags=""
|
|
||||||
let g:cppflags=""
|
|
||||||
let g:wcppflags="/O2 /EHsc /DWIN32"
|
|
||||||
let g:lcppflags="-O2"
|
|
||||||
let g:ldflags=""
|
|
||||||
let g:wldflags=""
|
|
||||||
let g:ldlibpath=""
|
|
||||||
endfunction
|
|
||||||
"
|
|
||||||
" Load compile instructions and call window or linux compiler. {{{1
|
" Load compile instructions and call window or linux compiler. {{{1
|
||||||
"
|
"
|
||||||
function! CF5Compile(run)
|
function! CF5Compile(run)
|
||||||
|
"
|
||||||
|
" Interpreters and compilers don't work with buffers, but ratter they run
|
||||||
|
" on files. So, make sure that the file is updated.
|
||||||
|
"
|
||||||
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
|
||||||
@@ -212,9 +207,6 @@ function! CF5Compile(run)
|
|||||||
" Set source specific compiler options.
|
" Set source specific compiler options.
|
||||||
"
|
"
|
||||||
call FirstModeLine()
|
call FirstModeLine()
|
||||||
"if exists("g:cf5script")
|
|
||||||
" execute g:cf5script
|
|
||||||
"endif
|
|
||||||
"
|
"
|
||||||
" Clear output window
|
" Clear output window
|
||||||
"
|
"
|
||||||
@@ -222,10 +214,6 @@ function! CF5Compile(run)
|
|||||||
"
|
"
|
||||||
" Compile.
|
" Compile.
|
||||||
"
|
"
|
||||||
if has("win32") || has("win64")
|
call s:Compile(a:run)
|
||||||
call s:CompileWindows(a:run)
|
|
||||||
else
|
|
||||||
call s:CompileLinux(a:run)
|
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
@@ -38,16 +38,24 @@ function s:LoadConfig()
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
let l:paths = []
|
||||||
let l:pathp = ""
|
let l:pathp = ""
|
||||||
while !filereadable(l:path.'/.vimrc') && l:pathp != l:path
|
while l:pathp != l:path
|
||||||
|
let l:vimrc = l:path.'/.vimrc.local'
|
||||||
|
if filereadable(l:vimrc) && l:vimrc != $MYVIMRC
|
||||||
|
let l:paths = [ l:vimrc ] + l:paths
|
||||||
|
endif
|
||||||
|
"echo 'try'.l:path
|
||||||
|
|
||||||
let l:pathp = l:path
|
let l:pathp = l:path
|
||||||
let l:path = fnamemodify(l:path, ":h")
|
let l:path = fnamemodify(l:path, ":h")
|
||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
|
"echo l:paths
|
||||||
|
for vimrc in l:paths
|
||||||
|
exec ":source " . vimrc
|
||||||
|
endfor
|
||||||
|
|
||||||
let l:vimrc = l:path . '/.vimrc'
|
|
||||||
if filereadable(l:vimrc) && l:vimrc != $MYVIMRC
|
|
||||||
exec ":source " . l:vimrc
|
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Section: Plugin completion
|
" Section: Plugin completion
|
||||||
|
|||||||
Reference in New Issue
Block a user