Previous | Gate

My vimrc file ( 2006.01.25 )

set go=M
au GUIEnter * simalt ~x

function Org()
        if has("gui_running")
                winpos 0 0
                if has("windows")
                        set lines=35 columns=80
                endif
        endif
endfunction
call Org()

function SetDevel(...)
        if a:0==0
                echo $MK_DEVEL
        else
                if a:1=="default"
                        call InitDevel()
                else
" TODO : platform free directory name
                        if( isdirectory(a:1) )
                                let $MK_DEVEL=a:1
                        else
                                echo "Invalid directory"
                                return
                        endif
                endif
" TODO : default devel path can allow ftp
                if filereadable($MK_DEVEL."/netrw.vim")
                        exe "source ".$MK_DEVEL."/netrw.vim"
                else
                        let $NETRW=""
                endif
                cd $MK_DEVEL
                echo $MK_DEVEL
        endif
endfunction

set vi=
set nocompatible
set nobackup
if has("mouse")
        set mouse=""
endif
syntax on
autocmd FileType * set noai nosi nocin nosta

set ruler
set backspace=indent,eol,start
set nowrap

if $HOSTNAME=="yopy"
        let $CVSROOT=':local:/home/cvs'
else
        if $USERNAME==""
                let username=$USER
        else
                let username=$USERNAME
        endif
        let $CVSROOT=':pserver:'.username.'@192.168.1.2:/home/cvs'
endif

if has("unix")
set fileencoding=korea
        if has("gui_running")
"               set imak=Hangul
        endif
set guifontset=-b&h-lucidatypewriter-medium-r-normal-*-*-180-*-*-m-*-iso8859-1,-baekmuk-gulim-medium-r-normal-*-*-180-*-*-m-*-ksx1001.1997-0
"set guifontset=-b&h-lucidatypewriter-medium-r-normal-*-*-160-*-*-m-*-iso8859-1,-baekmuk-gulim-medium-r-normal-*-*-160-*-*-m-*-ksx1001.1997-0

if $HOSTNAME=="yopy"
function InitDevel()
        let $MK_DEVEL='/home/devel'
endfunction
let $EXTRA='/home'
else
function InitDevel()
        let $MK_DEVEL='/mnt/core/devel'
endfunction
endif

call InitDevel()
let $MK_OS='unix'
let $MK_COMPILER='gcc'
let $MK_TEMPLATE_ROOT=$MK_DEVEL.'/make/template'
let $MK_OUT_ROOT=$EXTRA.'/devel/out'
let $MK_LIB_ROOT=$EXTRA.'/devel/lib'

set makeprg=make\ -C\ $MK_DEVEL/make\ -f\ $MK_TEMPLATE_ROOT/$MK_OS/$MK_COMPILER/makefile

let $PATH=$MK_OUT_ROOT.'/'.$MK_OS.':'.$PATH
let $LD_LIBRARY_PATH=$LD_LIBRARY_PATH.':'.$MK_LIB_ROOT.'/'.$MK_OS.'/shared'
let &path='/usr/include,'.$MK_DEVEL.',.'
let _='/'

function GetCygwinEnv(var)
        return a:var
endfunction

elseif has("windows")

if $OS==""
        set shell=cmd95\ /K\ doskey
else
        set shellpipe=>%s\ 2>&1
endif

function InitDevel()
        let $MK_DEVEL=$CORE.'\devel'
endfunction

call InitDevel()

let $MK_OS='win32'
let $MK_COMPILER='vcc'
let $MK_TEMPLATE_ROOT=$MK_DEVEL.'\make\template'
let $MK_OUT_ROOT=$EXTRA.'\devel\out'
let $MK_LIB_ROOT=$EXTRA.'\devel\lib'
let $ORIGPATH=$PATH

set makeprg=$CORE\\devel\\make\\make.bat

function SetBasePath()
        let msdev=$FILE.'\devel\msdev'
        let $PATH=msdev.'\vc98\bin;'.msdev.'\common\msdev98\bin;'.$FILE.'\devel\gcc\bin;'.$FILE.'\util\X11\X11R6\bin;'.$MK_OUT_ROOT.'\'.$MK_OS.';'.$MK_LIB_ROOT.'\'.$MK_OS.'\shared;'.$ORIGPATH
        if $MK_OS!="win32"
                " maintain the default system path
                let $PATH=$PATH.';'.$MK_OUT_ROOT.'\win32;'.$MK_LIB_ROOT.'\win32\shared'
        endif
        return msdev
endfunction

let msdev = SetBasePath()

function GetCygwinEnv(var)
        return substitute(substitute(substitute(a:var,"\\","/","g"),"\\(.\\):","/cygdrive/\\1","g"),";",":","g")
endfunction

let $cl='/nologo /W3 /link /SUBSYSTEM:CONSOLE /out:a.exe'
let $link='/nologo /SUBSYSTEM:CONSOLE'
let $C_INCLUDE_PATH=GetCygwinEnv($MK_DEVEL.';'.$FILE.'\devel\gcc\include')
let $CPLUS_INCLUDE_PATH=$C_INCLUDE_PATH.':'.GetCygwinEnv($FILE.'/devel/gcc/include/cxx')
let $LIBRARY_PATH=GetCygwinEnv($MK_LIB_ROOT.'\win32\cygnus;'.$FILE.'\devel\gcc\lib')
let $INCLUDE=$MK_DEVEL.';'.msdev.'\vc98\include;'.msdev.'\vc98\mfc\include;'.msdev.'\vc98\atl\include'
let $LIB=$MK_LIB_ROOT.'\win32\vcc;'.msdev.'\vc98\lib;'.msdev.'\vc98\mfc\lib'
let &path=substitute($INCLUDE,';',',','g').',.'
let _='\\'

if filereadable($MK_DEVEL."/etc/config.vim")
        exe "source ".$MK_DEVEL."/etc/config.vim"
else
        let resolution = "HIGH"
endif

if resolution=="LOW"
        set guifont=Lucida_Console:w6:h11:cANSI
elseif resolution=="MEDIUM"
        set guifont=Lucida_Console:w7.5:h13:cANSI
else
        set guifont=Lucida_Console:w9.5:h16:cANSI
endif

endif


cd $MK_DEVEL
let $CVS_RSH='ssh'


"set foldmethod=syntax

function C_init()
        setlocal ts=4
        setlocal sw=4
        " folding
"       setlocal foldmethod=syntax
"       syn region cfComment start=+/\*+ end=+\*/+ transparent keepend extend fold 
"       syn region cfCode start="[^#]*{" end="}" transparent fold
"       syn region cfStruct start="^DECLARE_.*(.*)" end="DECLARE_END" transparent fold
"       syn region cfParam start="P_1" end="P_E" transparent fold
endfunction

au FileType c,cpp call C_init()

function MakeEcho()
        echo "Current project : [" $MK_MAKEFILE "] [" $MK_MODE "]"
endfunction

function MakeCurrent(...)
        if $HOSTNAME=="yopy" && $USER!="devel"
                echo "Invalid user"
        else
                if a:0<2
                        call MakeEcho()
                else
                        if !filereadable($MK_DEVEL."/make/".a:1.".mk")
                                let $MK_MAKEFILE=''
                                let $MK_MODE=''
                                echo "Invalid make file :" a:1
                                return
                        endif
                        if a:2!="d" && a:2!="r"
                                let $MK_MAKEFILE=''
                                let $MK_MODE=''
                                echo "Invalid build mode :" a:2
                                return
                        endif
                        let $MK_MAKEFILE=a:1
                        let $MK_MODE=a:2
                        call MakeEcho()
                endif
        endif
endfunction

function MakeOpen(...)
        if a:0<1
                let make_name=$MK_MAKEFILE
        else
                let make_name=a:1
        endif
        let make_file=$MK_DEVEL."/make/".make_name.".mk"
        if !filereadable(make_file)
                echo "Invalid make file :" make_name
                return
        endif
        exe "e" make_file
        unlet make_file
        unlet make_name
endfunction

function SetCompiler(...)
        if a:0<1
                echo $MK_COMPILER $MK_OS
        else
                let compiler=a:1
                if a:0>1
                        let os=a:2
                else
                        let os=$MK_OS
                endif
                let p = $MK_TEMPLATE_ROOT."/".os."/".compiler
                if !isdirectory(p)
                        echo "Unavailable."
                        return
                endif
                " change envvar first so that SetBasePath works correctly
                let $MK_OS = os
                let $MK_COMPILER = compiler
                call SetBasePath()
                let p = p."/compiler.vim"
                if filereadable(p)
                        exe "source" p
                        echo "Configured."
                endif
        endif
endfunction

function GrepOption(...)
        let &grepprg='grep -H -n'
        if a:0>0
                let i = 1
                while i<=a:0
                        let &grepprg=&grepprg.' '.a:{i}
                        let i = i + 1
                endwhile
        endif
endfunction

call GrepOption()

function SetFindFilter(...)

        if a:0<1
                echo $FINDFILTER
                return
        endif

        if has("unix")
                let filter = ' \('
                let close = ' \)'
        else
                let filter = ' ('
                let close = ' )'
        endif

        if a:1=="default"
                let filter = filter.' -iname "*.c" -or -iname "*.h" -or -iname "*.cpp" -or -iname "*.htm" -or -iname "*.html" -or -iname "*.xml" -or -iname "*.txt" -or -iname "*.tex" -or -iname "*.mk" -or -iname "*.d"'.close
        else
                let i = 1
                while i<=a:0
                        if i>1
                                let filter = filter.' -or'
                        endif
                        let filter = filter.' -iname "'.a:{i}.'"'
                        let i = i + 1
                endwhile
                let filter = filter.close
        endif
        let $FINDFILTER=filter
endfunction

call SetFindFilter( "default" )

function RecursiveGrep(...)
        let expr=a:1
        let old_grepprg=&grepprg
        if a:0<2
                let path=expand("%:p:h")
        else
                let path=a:2
        endif
        if( isdirectory(path) )
                if has("unix")
                        let &grepprg='find '.path.$FINDFILTER.' -exec '.&grepprg.' "'.expr.'" \{\} \;'
                else
                        let &grepprg='find '.path.$FINDFILTER.' -exec '.&grepprg.' "'.expr.'" {} ;'
                endif
        else
                let &grepprg=&grepprg.' "'.expr.'" '.path
        endif
        " don't remove the blank after grep : it's a parameter for it
        grep
"       grep "" <--- win98 ???
        let &grepprg=old_grepprg
endfunction

function GetFileName(path)
        " TODO: is there a function which multiple tokens can be supplied ?
        " is there the string array to store tokens ?
        let cnt=0
        while cnt<2
                if cnt==0
                        let token="/"
                else
                        let token="\\"
                endif
                let index=strridx(a:path,token)
                if index!=-1
                        return strpart(a:path,index+1)
                endif
                let cnt = cnt+1
        endwhile
        return a:path
endfunction

function CvsSetPath(path)
        let fullpath=$MK_DEVEL."/".a:path
        if isdirectory(fullpath)
                let curpath=getcwd()
                exe "cd" fullpath
                return curpath
        endif
        echo "Invalid directory."
        return ""
endfunction

"function CvsEndPath

function CvsSession(...)
        let session = 'test*$CORE/devel/cvstest*:local:$EXTRA/devel/cvstest*kldp*$CORE/devel/kldp.net*:ext:chessman@cvs.kldp.net:/cvsroot/coral*'
        let cnt = 0
        while 1
                let len = stridx(session,'*')
                if len==-1
                        break
                endif

                if cnt==0
                        let id=strpart(session,0,len)
                elseif cnt==1
                        let mkdevel=strpart(session,0,len)
                else
                        let cvsroot=strpart(session,0,len)
                endif

                let session = strpart(session,len+1)

                let cnt = cnt + 1

                if cnt>=3
                        let cnt = 0
                        if a:0<1
                                if expand($MK_DEVEL)==expand(mkdevel)
                                        echo id
                                        return
                                endif
                        else
                                if a:1==id
                                        let $MK_DEVEL=expand(mkdevel)
                                        if stridx(cvsroot,":local:")>=0
                                                let $CVSROOT=":local:".GetCygwinEnv(strpart(expand(cvsroot),7))
                                        else
                                                let $CVSROOT=cvsroot
                                        endif

                                        return
                                endif
                        endif
                endif

        endwhile

        if a:0<1
                echo "default"
        else
                if a:1=="default"
                        call InitDevel()
                else
                        echo "Unknown session '".a:1."'"
                endif
        endif
endfunction


function CvsImport(path)
        let curpath=CvsSetPath(a:path)
        if curpath != ""
                let name=GetFileName(a:path)
                exe "!cvs import -m" "\"".name."\"" a:path "orion unknown"
                exe "cd" curpath
        endif
endfunction

function CvsExport(target,path)
"       let curpath=CvsSetPath(a:path)
"       if curpath!=""
        exe "!cvs export -d ".$MK_DEVEL."/".a:path." -D now" a:target
"               exe "cd" curpath
"       endif
endfunction

function CvsCheckOut(target)
        let curpath=CvsSetPath("")
        if curpath!=""
                exe "!cvs checkout " a:target
                exe "cd" curpath
        endif
endfunction

function CvsCmd( cmdcnt, ... )
        if a:0>a:cmdcnt
                let i = a:cmdcnt+1
                let curfile=""
                while i<=a:0
                        if a:{i}=="."
                                let curfile=curfile." ".expand("%:p:h")
                        else
                                let curfile=curfile." ".a:{i}
                        endif
                        let i = i+1
                endwhile
                let newpath=$MK_DEVEL
        else
                let curfile=" ".expand("%:t")
                let newpath=expand("%:p:h")
        endif

        if curfile!=""
                let curpath=getcwd()
                exe "cd" newpath

                if curfile==" /"
                        let curfile=""
                endif

                let i = 1
                while i<=a:cmdcnt
                        exe "!".a:{i}.curfile
"> test.txt"
"view test.txt
                        let i=i+1
                endwhile

                exe "cd" curpath
        else
                echo "File was not opened."
        endif
endfunction


function EditStream( cmd, ... )
        if a:0<1
                let filename = expand("%")
        else
                if isdirectory(a:1)
                        let curpath=getcwd()
                        exe "!find ".a:1.$FINDFILTER." -mindepth 1 -exec sh ".$MK_TEMPLATE_ROOT."/etc/util/replace '".a:cmd."' \{\} \;"
                        return
                endif
                let filename = a:1
        endif
        exe "!sh ".$MK_TEMPLATE_ROOT."/etc/util/replace '".a:cmd."' ".filename
endfunction

function Copy( path, ... )
        if a:0<1
                let mkdevel = $MK_DEVEL
                let cvsroot = $CVSROOT
                call InitDevel()
                let filename = GetCygwinEnv(expand("%:p"))
                exe "!cp -f ".filename a:path.substitute(filename,GetCygwinEnv($MK_DEVEL),"","")
                let $MK_DEVEL=mkdevel
                let $CVSROOT=cvsroot
        else
                let i=1
                while i<=a:0
                        exe "!cp -f ".a:{i} a:path."/".a:{i}
                        let i=i+1
                endwhile
        endif
endfunction

function NetRW(op)
"       Sample NETRW envvar formats
"       let $NETRW="ftp://machine"
"       let $NETRW="scp://user@machine"

        if $NETRW!=""
                let filename = expand("%")
                if filename==""
                        echo "Nothing to transfer."
                else
                        let filename = GetCygwinEnv(substitute(filename,$MK_DEVEL,"",""))
                        let l = line(".")
                        let c = col(".")
                        exe a:op." ".$NETRW."/".filename
                        call cursor( l, c )
                        echo "O.K"
                endif
        else
                echo "NETRW is not allowed for this source tree."
        endif
endfunction

function Date()
        let lc_time=v:lc_time
        "change the current time language to English
        language EN
        put=strftime('%p %I:%M %Y.%m.%d')
        "recover the current time language
        exe "language ".lc_time
endfunction

command -nargs=0 ORG : call Org()
command -nargs=* DEVEL : call SetDevel(<f-args>)
command -nargs=* MAKE : call MakeCurrent(<f-args>)
command -nargs=* MAKEFILE : call MakeOpen(<f-args>)
command -nargs=* COMPILER : call SetCompiler(<f-args>)
command -nargs=* GREPOPTION : call GrepOption(<f-args>)
command -nargs=+ RGREP : call RecursiveGrep(<f-args>)
command -nargs=+ SED : call EditStream(<f-args>)
command -nargs=? CVSSESSION : call CvsSession(<f-args>)
command -nargs=1 CVSIMPORT : call CvsImport(<f-args>)
command -nargs=* CVSEXPORT : call CvsExport(<f-args>)
command -nargs=1 CVSCHECKOUT : call CvsCheckOut(<f-args>)
command -nargs=? CVSEDIT : call CvsCmd(1,"cvs edit",<f-args>)
command -nargs=? CVSUNEDIT : call CvsCmd(1,"cvs unedit",<f-args>)
command -nargs=? CVSCOMMIT : call CvsCmd(1,"cvs commit -m \"\"",<f-args>)
command -nargs=? CVSADD : call CvsCmd(1,"cvs add -m \"\"",<f-args>)
command -nargs=? CVSDELETE : call CvsCmd(2,"rm -f", "cvs delete",<f-args>)
command -nargs=? CVSDIFF : call CvsCmd(1,"cvs diff",<f-args>)
command -nargs=? CVSBDIFF : call CvsCmd(1,"cvs -Q diff --brief",<f-args>)
command -nargs=? CVSWATCHERS : call CvsCmd(1,"cvs watchers",<f-args>)
command -nargs=? CVSUPDATE : call CvsCmd(1,"cvs update",<f-args>)
command -nargs=? CVSUNDO : call CvsCmd(2,"rm -f","cvs update",<f-args>)
" call CvsCmd(1,$MK_TEMPLATE_ROOT._."etc"._."util"._."cvsundo",<f-args>)
command -nargs=* COPY : call Copy(<f-args>)
command -nargs=* FINDFILTER : call SetFindFilter(<f-args>)
command -nargs=0 PUT : call NetRW("Nwrite")
command -nargs=0 GET : call NetRW("Nread")
command -nargs=0 DATE : call Date()


map <PageUp> <C-U><C-U>
map <PageDown> <C-D><C-D>
map! <PageUp> <C-O><C-U><C-O><C-U>
map! <PageDown> <C-O><C-D><C-O><C-D>

map <C-b> <C-U><C-U>
map <C-f> <C-D><C-D>
map! <C-b> <C-O><C-U><C-O><C-U>
map! <C-f> <C-O><C-D><C-O><C-D>

set fileformats=unix,dos,mac

if $HOSTNAME=="yopy"
        set dir=$EXTRA/devel/temp
else
        set dir=$EXTRA/temp/volatile
endif



hi Normal                 guifg=white  guibg=black
hi Scrollbar      guifg=darkcyan guibg=cyan
hi Menu                   guifg=black guibg=cyan
hi SpecialKey     term=bold  cterm=bold  ctermfg=darkred  guifg=Blue
hi NonText                term=bold  cterm=bold  ctermfg=darkred  gui=bold      guifg=Blue
hi Directory      term=bold  cterm=bold  ctermfg=lightblue      guifg=lightBlue
hi ErrorMsg               term=standout  cterm=bold  ctermfg=grey  ctermbg=blue  guifg=White  guibg=Red
hi Search                 term=reverse  ctermfg=white  ctermbg=red      guifg=white  guibg=Red
hi MoreMsg                term=bold  cterm=bold  ctermfg=darkgreen      gui=bold  guifg=SeaGreen
hi ModeMsg                term=bold  cterm=bold  gui=bold  guifg=White  guibg=Blue
hi LineNr                 term=underline  cterm=bold  ctermfg=darkcyan  guifg=Yellow
hi Question               term=standout  cterm=bold  ctermfg=darkgreen  gui=bold  guifg=Green
hi StatusLine     term=bold,reverse  cterm=bold ctermfg=lightblue ctermbg=white gui=bold guifg=blue guibg=white
hi StatusLineNC   term=reverse  ctermfg=white ctermbg=lightblue guifg=white guibg=blue
hi Title                  term=bold  cterm=bold  ctermfg=darkmagenta  gui=bold  guifg=Magenta
hi Visual                 term=reverse  cterm=reverse  gui=reverse
hi WarningMsg     term=standout  cterm=bold  ctermfg=darkblue  guifg=Red
hi Cursor                 guifg=bg      guibg=White
hi Comment                term=bold  cterm=bold ctermfg=darkcyan  guifg=#80a0ff
hi Constant               term=underline  cterm=bold ctermfg=magenta  guifg=#ffa0a0
hi Special                term=bold  cterm=bold ctermfg=red  guifg=Orange
hi Identifier     term=underline   ctermfg=brown  guifg=#40ffff
hi Statement      term=bold  cterm=bold ctermfg=yellow  gui=bold  guifg=#ffff60
"hi PreProc               term=underline  ctermfg=darkblue      guifg=#ff80ff
hi PreProc                term=underline  ctermfg=blue  guifg=#ff80ff
hi Type                   term=underline  cterm=bold ctermfg=lightgreen  gui=bold  guifg=#60ff60
hi Error                  term=reverse  ctermfg=darkcyan  ctermbg=black  guifg=Red      guibg=Black
hi Todo                   term=standout  ctermfg=black  ctermbg=darkcyan  guifg=Blue  guibg=Yellow
hi link IncSearch               Visual
hi link String                  Constant
hi link Character               Constant
hi link Number                  Constant
hi link Boolean                 Constant
hi link Float                   Number
hi link Function                Identifier
hi link Conditional             Statement
hi link Repeat                  Statement
hi link Label                   Statement
hi link Operator                Statement
hi link Keyword                 Statement
hi link Exception               Statement
hi link Include                 PreProc
hi link Define                  PreProc
hi link Macro                   PreProc
hi link PreCondit               PreProc
hi link StorageClass    Type
hi link Structure               Type
hi link Typedef                 Type
hi link Tag                             Special
hi link SpecialChar             Special
hi link Delimiter               Special
hi link SpecialComment  Special
hi link Debug                   Special







Previous | Gate