cf5 elaborated. p4 shortcuts added
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
*.swp
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
"
|
" {{{1
|
||||||
" Functions to compile and link a single c/cpp file.
|
" Functions to compile and link a single c/cpp file.
|
||||||
"
|
"
|
||||||
|
" let g:cf5output
|
||||||
|
" =0 - no output window opened.
|
||||||
|
" =1 - ouput window opened.
|
||||||
|
"
|
||||||
"if exists("g:loaded_vahagn_compiler") | finish | endif
|
"if exists("g:loaded_vahagn_compiler") | finish | endif
|
||||||
let g:loaded_vahagn_compiler = 1
|
let g:loaded_vahagn_compiler = 1
|
||||||
|
|
||||||
@@ -12,12 +16,9 @@ if !exists('*FirstModeLine')
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
"
|
"
|
||||||
" Windows
|
" Windows {{{1
|
||||||
"
|
"
|
||||||
let g:argv=""
|
function! s:CompileMSVC() "{{{2
|
||||||
let g:cppflags=""
|
|
||||||
let g:wcppflags="/O2 /EHsc /DWIN32"
|
|
||||||
function! s:CompileMSVC()
|
|
||||||
let exename=expand("%:p:r:s,$,.exe,")
|
let exename=expand("%:p:r:s,$,.exe,")
|
||||||
let srcname=expand("%")
|
let srcname=expand("%")
|
||||||
" compile it
|
" compile it
|
||||||
@@ -36,7 +37,7 @@ function! s:CompileMSVC()
|
|||||||
echo eout
|
echo eout
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:CompileJava()
|
function! s:CompileJava() "{{{2
|
||||||
" compile it
|
" compile it
|
||||||
let cmd = "javac " . g:javaflags . " " . expand("%")
|
let cmd = "javac " . g:javaflags . " " . expand("%")
|
||||||
echo cmd
|
echo cmd
|
||||||
@@ -54,7 +55,7 @@ function! s:CompileJava()
|
|||||||
echo eout
|
echo eout
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:CompileWindows()
|
function! s:CompileWindows() "{{{2
|
||||||
let ext=expand("%:e")
|
let ext=expand("%:e")
|
||||||
if ext=="java"
|
if ext=="java"
|
||||||
call s:CompileJava()
|
call s:CompileJava()
|
||||||
@@ -64,43 +65,109 @@ function! s:CompileWindows()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
"
|
||||||
|
" Linux {{{1
|
||||||
"
|
"
|
||||||
" Linux
|
function! s:CompileGCC() "{{{2
|
||||||
"
|
|
||||||
let g:lcppflags="-O2"
|
|
||||||
function! s:CompileGCC()
|
|
||||||
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="g++ ".g:cppflags." ".g:lcppflags." ".srcname." -o".exename
|
let ccline="g++ ".g:cppflags." ".g:lcppflags." ".srcname." -o".exename
|
||||||
echo ccline
|
call s:appendOutput(ccline)
|
||||||
let cout = system( ccline )
|
let cout = system( ccline )
|
||||||
if v:shell_error
|
if v:shell_error
|
||||||
echo cout
|
call s:appendOutput(cout)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
echo cout
|
call s:appendOutput(cout)
|
||||||
" run it
|
" run it
|
||||||
let cmdline="LD_LIBRARY_PATH=".g:ldlibrarypath.":".$LD_LIBRARY_PATH." ".exename
|
let cmdline="LD_LIBRARY_PATH=".g:ldlibpath.":".$LD_LIBRARY_PATH." ".exename." ".g:argv
|
||||||
echo cmdline
|
call s:appendOutput(cmdline)
|
||||||
let eout = system( cmdline )
|
let eout = system( cmdline )
|
||||||
echo eout
|
call s:appendOutput(eout)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:CompileLinux()
|
function! s:CompileLinux() "{{{2
|
||||||
call s:CompileGCC()
|
call s:CompileGCC()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"
|
"
|
||||||
" Load compile instructions and call window or linux compiler.
|
" Output Window {{{1
|
||||||
|
"
|
||||||
|
" Create output window. {{{2
|
||||||
|
"
|
||||||
|
function! s:getOutputWindow()
|
||||||
|
if !exists("w:outputwin")
|
||||||
|
let w:outputwin=tempname().'_output'
|
||||||
|
endif
|
||||||
|
let obuff = w:outputwin
|
||||||
|
|
||||||
|
let winnr = bufwinnr('^'.obuff.'$')
|
||||||
|
|
||||||
|
if (winnr < 0)
|
||||||
|
execute "below 10new ".obuff
|
||||||
|
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap
|
||||||
|
" setlocal nomodifiable
|
||||||
|
let winnr = bufwinnr('^'.obuff.'$')
|
||||||
|
endif
|
||||||
|
|
||||||
|
return winnr
|
||||||
|
endfunction
|
||||||
|
"
|
||||||
|
" Append text to output window. {{{2
|
||||||
|
"
|
||||||
|
function! s:appendOutput( text )
|
||||||
|
if exists("g:cf5output") && (g:cf5output==1)
|
||||||
|
let cwinnr = winnr()
|
||||||
|
let owinnr = s:getOutputWindow()
|
||||||
|
" setlocal modifiable
|
||||||
|
execute owinnr . 'wincmd w'
|
||||||
|
execute 'normal! Go'.a:text
|
||||||
|
" setlocal nomodifiable
|
||||||
|
execute cwinnr.'wincmd w'
|
||||||
|
else
|
||||||
|
echo a:text
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
"
|
||||||
|
" Clear text from output window. {{{2
|
||||||
|
"
|
||||||
|
function! s:clearOutputWindow()
|
||||||
|
if exists("g:cf5output") && (g:cf5output==1)
|
||||||
|
let cwinnr = winnr()
|
||||||
|
let owinnr = s:getOutputWindow()
|
||||||
|
" setlocal modifiable
|
||||||
|
execute owinnr . 'wincmd w'
|
||||||
|
execute 'normal ggdG'
|
||||||
|
" setlocal nomodifiable
|
||||||
|
execute cwinnr . 'wincmd w'
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
"
|
||||||
|
" Init global variables with default values. {{{1
|
||||||
|
"
|
||||||
|
function! s:initDefaults()
|
||||||
|
let g:cf5output=0
|
||||||
|
let g:argv=""
|
||||||
|
let g:cppflags=""
|
||||||
|
let g:wcppflags="/O2 /EHsc /DWIN32"
|
||||||
|
let g:lcppflags="-O2"
|
||||||
|
let g:ldlibpath=""
|
||||||
|
endfunction
|
||||||
|
"
|
||||||
|
" Load compile instructions and call window or linux compiler. {{{1
|
||||||
"
|
"
|
||||||
function! CF5Compile()
|
function! CF5Compile()
|
||||||
|
"
|
||||||
|
" First init global variables to let cf5-opt override it.
|
||||||
|
"
|
||||||
|
call s:initDefaults()
|
||||||
"
|
"
|
||||||
" Source compile-opt.vim if exists.
|
" Source compile-opt.vim if exists.
|
||||||
"
|
"
|
||||||
let copt=expand("%:p:h")."/compile-opt.vim"
|
verbose let l:copt=expand("%:p:h")."/cf5-opt.vim"
|
||||||
if filereadable(copt)
|
if filereadable(l:copt)
|
||||||
source copt
|
exec ":source ".l:copt
|
||||||
endif
|
endif
|
||||||
"
|
"
|
||||||
" Set source specific compiler options.
|
" Set source specific compiler options.
|
||||||
@@ -110,6 +177,10 @@ function! CF5Compile()
|
|||||||
" execute g:cf5script
|
" execute g:cf5script
|
||||||
"endif
|
"endif
|
||||||
"
|
"
|
||||||
|
" Clear output window
|
||||||
|
"
|
||||||
|
call s:clearOutputWindow()
|
||||||
|
"
|
||||||
" Compile.
|
" Compile.
|
||||||
"
|
"
|
||||||
if has("win32") || has("win64")
|
if has("win32") || has("win64")
|
||||||
@@ -119,5 +190,3 @@ function! CF5Compile()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
26
vim/vimrc
26
vim/vimrc
@@ -73,7 +73,27 @@ if exists('&modeline')
|
|||||||
set modeline
|
set modeline
|
||||||
set modelines=10
|
set modelines=10
|
||||||
endif
|
endif
|
||||||
|
"
|
||||||
|
" Set fold method if supported
|
||||||
|
"
|
||||||
|
if has('folding')
|
||||||
|
set nofoldenable
|
||||||
|
set foldmethod=indent "fold based on indent
|
||||||
|
set foldnestmax=5
|
||||||
|
set foldlevel=1
|
||||||
|
if has("autocmd")
|
||||||
|
autocmd FileType vim setlocal foldmethod=marker
|
||||||
|
autocmd FileType c setlocal foldmethod=syntax
|
||||||
|
autocmd FileType h setlocal foldmethod=syntax
|
||||||
|
autocmd FileType cpp setlocal foldmethod=syntax
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
"
|
||||||
|
" P4
|
||||||
|
"
|
||||||
|
command! -nargs=* PFedit :!p4 edit <args> %
|
||||||
|
command! -nargs=* PFrevert :!p4 revert <args> %
|
||||||
|
command! -nargs=* PFdiff :!p4 diff <args> %
|
||||||
" Only do this part when compiled with support for autocommands.
|
" Only do this part when compiled with support for autocommands.
|
||||||
if has("autocmd")
|
if has("autocmd")
|
||||||
|
|
||||||
@@ -194,6 +214,8 @@ if has("gui_running")
|
|||||||
\set showtabline=1 <Bar>
|
\set showtabline=1 <Bar>
|
||||||
\endif <CR>
|
\endif <CR>
|
||||||
|
|
||||||
" Open fine in a new tab.
|
" Open file in a new tab.
|
||||||
map <silent> <C-F3> :browse tabnew %:p:h<CR>
|
map <silent> <C-F3> :browse tabnew %:p:h<CR>
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user