mirror of https://github.com/akelge/vim
Removed oldStyle stuff
This commit is contained in:
parent
deabd49a22
commit
573c1cc337
|
@ -1,12 +0,0 @@
|
||||||
ScriptID SourceID Filename
|
|
||||||
--------------------------
|
|
||||||
910 18164 :AutoInstall: pydoc.vim
|
|
||||||
2771 16279 :AutoInstall: conque_term.vim
|
|
||||||
294 19633 :AutoInstall: Align.vim
|
|
||||||
1066 7618 :AutoInstall: cecutil.vim
|
|
||||||
642 15781 :AutoInstall: getscript.vim
|
|
||||||
2324 9247 :AutoInstall: TextFormat
|
|
||||||
1658 17123 :AutoInstall: NERD_tree.vim
|
|
||||||
1218 14455 :AutoInstall: NERD_commenter.vim
|
|
||||||
90 19809 :AutoInstall: vcscommand.vim
|
|
||||||
2896 11941 :AutoInstall: open_terminal.vim
|
|
|
@ -1,18 +0,0 @@
|
||||||
ScriptID SourceID Filename
|
|
||||||
--------------------------
|
|
||||||
294 1 Align.vim
|
|
||||||
302 2 AnsiEsc.vim
|
|
||||||
122 3 astronaut.vim
|
|
||||||
104 4 blockhl.vim
|
|
||||||
120 5 decho.vim
|
|
||||||
40 6 DrawIt.tar.gz
|
|
||||||
451 7 EasyAccents.vim
|
|
||||||
195 8 engspchk.vim
|
|
||||||
642 9 GetLatestVimScripts.vim
|
|
||||||
489 10 Manpageview.vim
|
|
||||||
551 11 Mines.vim
|
|
||||||
514 12 mrswin.vim
|
|
||||||
670 13 visincr.vim
|
|
||||||
628 14 SeeTab.vim
|
|
||||||
508 15 ZoomWin.vim
|
|
||||||
877 16 gvcolor.vim
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,401 +0,0 @@
|
||||||
" AlignMaps.vim : support functions for AlignMaps
|
|
||||||
" Author: Charles E. Campbell
|
|
||||||
" Date: Mar 12, 2013
|
|
||||||
" Version: 43
|
|
||||||
" Copyright: Copyright (C) 1999-2012 Charles E. Campbell {{{1
|
|
||||||
" Permission is hereby granted to use and distribute this code,
|
|
||||||
" with or without modifications, provided that this copyright
|
|
||||||
" notice is copied with it. Like anything else that's free,
|
|
||||||
" Align.vim is provided *as is* and comes with no warranty
|
|
||||||
" of any kind, either expressed or implied. By using this
|
|
||||||
" plugin, you agree that in no event will the copyright
|
|
||||||
" holder be liable for any damages resulting from the use
|
|
||||||
"redraw!|call DechoSep()|call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" Load Once: {{{1
|
|
||||||
if &cp || exists("g:loaded_AlignMaps")
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
let g:loaded_AlignMaps= "v43"
|
|
||||||
let s:keepcpo = &cpo
|
|
||||||
set cpo&vim
|
|
||||||
"DechoTabOn
|
|
||||||
|
|
||||||
" =====================================================================
|
|
||||||
" Functions: {{{1
|
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" AlignMaps#WrapperStart: {{{2
|
|
||||||
fun! AlignMaps#WrapperStart(vis) range
|
|
||||||
" call Dfunc("AlignMaps#WrapperStart(vis=".a:vis.")")
|
|
||||||
|
|
||||||
if a:vis
|
|
||||||
keepj norm! '<ma'>
|
|
||||||
endif
|
|
||||||
|
|
||||||
if line("'y") == 0 || line("'z") == 0 || !exists("s:alignmaps_wrapcnt") || s:alignmaps_wrapcnt <= 0
|
|
||||||
" call Decho("wrapper initialization")
|
|
||||||
let s:alignmaps_wrapcnt = 1
|
|
||||||
let s:alignmaps_keepgd = &gdefault
|
|
||||||
let s:alignmaps_keepsearch = @/
|
|
||||||
let s:alignmaps_keepch = &ch
|
|
||||||
let s:alignmaps_keepmy = SaveMark("'y")
|
|
||||||
let s:alignmaps_keepmz = SaveMark("'z")
|
|
||||||
let s:alignmaps_posn = SaveWinPosn(0)
|
|
||||||
" set up fencepost blank lines
|
|
||||||
put =''
|
|
||||||
keepj norm! mz'a
|
|
||||||
put! =''
|
|
||||||
ky
|
|
||||||
let s:alignmaps_zline = line("'z")
|
|
||||||
exe "keepj 'y,'zs/@/\177/ge"
|
|
||||||
else
|
|
||||||
" call Decho("embedded wrapper")
|
|
||||||
let s:alignmaps_wrapcnt = s:alignmaps_wrapcnt + 1
|
|
||||||
keepj norm! 'yjma'zk
|
|
||||||
endif
|
|
||||||
|
|
||||||
" change some settings to align-standard values
|
|
||||||
set nogd
|
|
||||||
set ch=2
|
|
||||||
AlignPush
|
|
||||||
keepj norm! 'zk
|
|
||||||
" call Dret("AlignMaps#WrapperStart : alignmaps_wrapcnt=".s:alignmaps_wrapcnt." my=".line("'y")." mz=".line("'z"))
|
|
||||||
endfun
|
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" AlignMaps#WrapperEnd: {{{2
|
|
||||||
fun! AlignMaps#WrapperEnd() range
|
|
||||||
" call Dfunc("AlignMaps#WrapperEnd() alignmaps_wrapcnt=".s:alignmaps_wrapcnt." my=".line("'y")." mz=".line("'z"))
|
|
||||||
|
|
||||||
" remove trailing white space introduced by whatever in the modification zone
|
|
||||||
keepj 'y,'zs/ \+$//e
|
|
||||||
|
|
||||||
" restore AlignCtrl settings
|
|
||||||
AlignPop
|
|
||||||
|
|
||||||
let s:alignmaps_wrapcnt= s:alignmaps_wrapcnt - 1
|
|
||||||
if s:alignmaps_wrapcnt <= 0
|
|
||||||
" initial wrapper ending
|
|
||||||
exe "keepj 'y,'zs/\177/@/ge"
|
|
||||||
|
|
||||||
" if the 'z line hasn't moved, then go ahead and restore window position
|
|
||||||
let zstationary= s:alignmaps_zline == line("'z")
|
|
||||||
|
|
||||||
" remove fencepost blank lines.
|
|
||||||
" restore 'a
|
|
||||||
keepj norm! 'yjmakdd'zdd
|
|
||||||
|
|
||||||
" restore original 'y, 'z, and window positioning
|
|
||||||
call RestoreMark(s:alignmaps_keepmy)
|
|
||||||
call RestoreMark(s:alignmaps_keepmz)
|
|
||||||
if zstationary > 0
|
|
||||||
call RestoreWinPosn(s:alignmaps_posn)
|
|
||||||
" call Decho("restored window positioning")
|
|
||||||
endif
|
|
||||||
|
|
||||||
" restoration of options
|
|
||||||
let &gd= s:alignmaps_keepgd
|
|
||||||
let &ch= s:alignmaps_keepch
|
|
||||||
let @/ = s:alignmaps_keepsearch
|
|
||||||
|
|
||||||
" remove script variables
|
|
||||||
unlet s:alignmaps_keepch
|
|
||||||
unlet s:alignmaps_keepsearch
|
|
||||||
unlet s:alignmaps_keepmy
|
|
||||||
unlet s:alignmaps_keepmz
|
|
||||||
unlet s:alignmaps_keepgd
|
|
||||||
unlet s:alignmaps_posn
|
|
||||||
endif
|
|
||||||
|
|
||||||
" call Dret("AlignMaps#WrapperEnd : alignmaps_wrapcnt=".s:alignmaps_wrapcnt." my=".line("'y")." mz=".line("'z"))
|
|
||||||
endfun
|
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" AlignMaps#MakeMap: make both a normal-mode and a visual mode map for mapname {{{2
|
|
||||||
fun! AlignMaps#MakeMap(mapname)
|
|
||||||
if exists("g:maplocalleader")
|
|
||||||
let maplead= g:maplocalleader
|
|
||||||
elseif exists("g:mapleader")
|
|
||||||
let maplead= g:mapleader
|
|
||||||
else
|
|
||||||
let maplead= '\'
|
|
||||||
endif
|
|
||||||
exe "nmap <unique> ".maplead.a:mapname." <Plug>AM_".a:mapname
|
|
||||||
exe "vmap <silent> ".maplead.a:mapname.' :call AlignMaps#Vis("'.a:mapname.'")'."<cr>"
|
|
||||||
endfun
|
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" AlignMaps#StdAlign: some semi-standard align calls {{{2
|
|
||||||
fun! AlignMaps#StdAlign(mode) range
|
|
||||||
" call Dfunc("AlignMaps#StdAlign(mode=".a:mode.")")
|
|
||||||
if a:mode == 1
|
|
||||||
" align on @
|
|
||||||
" call Decho("align on @")
|
|
||||||
AlignCtrl mIp1P1=l @
|
|
||||||
'a,.Align
|
|
||||||
elseif a:mode == 2
|
|
||||||
" align on @, retaining all initial white space on each line
|
|
||||||
" call Decho("align on @, retaining all initial white space on each line")
|
|
||||||
AlignCtrl mWp1P1=l @
|
|
||||||
'a,.Align
|
|
||||||
elseif a:mode == 3
|
|
||||||
" like mode 2, but ignore /* */-style comments
|
|
||||||
" call Decho("like mode 2, but ignore /* */-style comments")
|
|
||||||
AlignCtrl v ^\s*/[/*]
|
|
||||||
AlignCtrl mWp1P1=l @
|
|
||||||
'a,.Align
|
|
||||||
else
|
|
||||||
echoerr "(AlignMaps) AlignMaps#StdAlign doesn't support mode#".a:mode
|
|
||||||
endif
|
|
||||||
" call Dret("AlignMaps#StdAlign")
|
|
||||||
endfun
|
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" AlignMaps#CharJoiner: joins lines which end in the given character (spaces {{{2
|
|
||||||
" at end are ignored)
|
|
||||||
fun! AlignMaps#CharJoiner(chr)
|
|
||||||
" call Dfunc("AlignMaps#CharJoiner(chr=".a:chr.")")
|
|
||||||
let aline = line("'a")
|
|
||||||
let rep = line(".") - aline
|
|
||||||
while rep > 0
|
|
||||||
keepj norm! 'a
|
|
||||||
while match(getline(aline),a:chr . "\s*$") != -1 && rep >= 0
|
|
||||||
" while = at end-of-line, delete it and join with next
|
|
||||||
keepj norm! 'a$
|
|
||||||
j!
|
|
||||||
let rep = rep - 1
|
|
||||||
endwhile
|
|
||||||
" update rep(eat) count
|
|
||||||
let rep = rep - 1
|
|
||||||
if rep <= 0
|
|
||||||
" terminate loop if at end-of-block
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
" prepare for next line
|
|
||||||
keepj norm! jma
|
|
||||||
let aline = line("'a")
|
|
||||||
endwhile
|
|
||||||
" call Dret("AlignMaps#CharJoiner")
|
|
||||||
endfun
|
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" AlignMaps#Equals: supports \t= and \T= {{{2
|
|
||||||
fun! AlignMaps#Equals() range
|
|
||||||
" call Dfunc("AlignMaps#Equals()")
|
|
||||||
keepj 'a,'zs/\s\+\([.*/+\-%|&\~^]\==\)/ \1/e
|
|
||||||
keepj 'a,'zs@ \+\([.*/+\-%|&\~^]\)=@\1=@ge
|
|
||||||
keepj 'a,'zs/==/\="\<Char-0x0f>\<Char-0x0f>"/ge
|
|
||||||
keepj 'a,'zs/\([!<>:]\)=/\=submatch(1)."\<Char-0x0f>"/ge
|
|
||||||
keepj norm g'zk
|
|
||||||
AlignCtrl mIp1P1=l =
|
|
||||||
AlignCtrl g =
|
|
||||||
keepj 'a,'z-1Align
|
|
||||||
keepj 'a,'z-1s@\([.*/%|&\~^!=]\)\( \+\)=@\2\1=@ge
|
|
||||||
keepj 'a,'z-1s@[^+\-]\zs\([+\-]\)\( \+\)=@\2\1=@ge
|
|
||||||
keepj 'a,'z-1s/\( \+\);/;\1/ge
|
|
||||||
if &ft == "c" || &ft == "cpp"
|
|
||||||
" call Decho("exception for ".&ft)
|
|
||||||
keepj 'a,'z-1v/^\s*\/[*/]/s/\/[*/]/@&@/e
|
|
||||||
keepj 'a,'z-1v/^\s*\/[*/]/s/\*\//@&/e
|
|
||||||
if exists("g:mapleader")
|
|
||||||
exe "keepj norm 'zk"
|
|
||||||
call AlignMaps#StdAlign(1)
|
|
||||||
else
|
|
||||||
exe "keepj norm 'zk"
|
|
||||||
call AlignMaps#StdAlign(1)
|
|
||||||
endif
|
|
||||||
keepj 'y,'zs/^\(\s*\) @/\1/e
|
|
||||||
endif
|
|
||||||
keepj 'a,'z-1s/\%x0f/=/ge
|
|
||||||
keepj 'y,'zs/ @//eg
|
|
||||||
" call Dret("AlignMaps#Equals")
|
|
||||||
endfun
|
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" AlignMaps#Afnc: useful for splitting one-line function beginnings {{{2
|
|
||||||
" into one line per argument format
|
|
||||||
fun! AlignMaps#Afnc()
|
|
||||||
" call Dfunc("AlignMaps#Afnc()")
|
|
||||||
|
|
||||||
" keep display quiet
|
|
||||||
let chkeep = &l:ch
|
|
||||||
let gdkeep = &l:gd
|
|
||||||
let wwkeep = &l:ww
|
|
||||||
let vekeep = &l:ve
|
|
||||||
setlocal ch=2 nogd ve= ww=b,s,<,>,[,]
|
|
||||||
|
|
||||||
" will use marks y,z ; save current values
|
|
||||||
let mykeep = SaveMark("'y")
|
|
||||||
let mzkeep = SaveMark("'z")
|
|
||||||
|
|
||||||
" Find beginning of function -- be careful to skip over comments
|
|
||||||
let cmmntid = synIDtrans(hlID("Comment"))
|
|
||||||
let stringid = synIDtrans(hlID("String"))
|
|
||||||
exe "keepj norm! ]]"
|
|
||||||
while search(")","bW") != 0
|
|
||||||
" call Decho("line=".line(".")." col=".col("."))
|
|
||||||
let parenid= synIDtrans(synID(line("."),col("."),1))
|
|
||||||
if parenid != cmmntid && parenid != stringid
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
keepj norm! %my
|
|
||||||
keepj s/(\s*\(\S\)/(\r \1/e
|
|
||||||
exe "keepj norm! `y%"
|
|
||||||
keepj s/)\s*\(\/[*/]\)/)\r\1/e
|
|
||||||
exe "keepj norm! `y%mz"
|
|
||||||
keepj 'y,'zs/\s\+$//e
|
|
||||||
keepj 'y,'zs/^\s\+//e
|
|
||||||
keepj 'y+1,'zs/^/ /
|
|
||||||
|
|
||||||
" insert newline after every comma only one parenthesis deep
|
|
||||||
exe "sil! keepj norm! `y\<right>h"
|
|
||||||
let parens = 1
|
|
||||||
let cmmnt = 0
|
|
||||||
let cmmntline= -1
|
|
||||||
while parens >= 1
|
|
||||||
exe 'keepj norm! ma "ay`a '
|
|
||||||
" call Decho("parens=".parens." cmmnt=".cmmnt." cmmntline=".cmmntline." line(.)=".line(".")." @a<".@a."> line<".getline(".").">")
|
|
||||||
if @a == "("
|
|
||||||
let parens= parens + 1
|
|
||||||
elseif @a == ")"
|
|
||||||
let parens= parens - 1
|
|
||||||
|
|
||||||
" comment bypass: /* ... */ or //...
|
|
||||||
elseif cmmnt == 0 && @a == '/'
|
|
||||||
let cmmnt= 1
|
|
||||||
elseif cmmnt == 1
|
|
||||||
if @a == '/'
|
|
||||||
let cmmnt = 2 " //...
|
|
||||||
let cmmntline= line(".")
|
|
||||||
elseif @a == '*'
|
|
||||||
let cmmnt= 3 " /*...
|
|
||||||
else
|
|
||||||
let cmmnt= 0
|
|
||||||
endif
|
|
||||||
elseif cmmnt == 2 && line(".") != cmmntline
|
|
||||||
let cmmnt = 0
|
|
||||||
let cmmntline= -1
|
|
||||||
elseif cmmnt == 3 && @a == '*'
|
|
||||||
let cmmnt= 4
|
|
||||||
elseif cmmnt == 4
|
|
||||||
if @a == '/'
|
|
||||||
let cmmnt= 0 " ...*/
|
|
||||||
elseif @a != '*'
|
|
||||||
let cmmnt= 3
|
|
||||||
endif
|
|
||||||
|
|
||||||
elseif @a == "," && parens == 1 && cmmnt == 0
|
|
||||||
exe "keepj norm! i\<CR>\<Esc>"
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
sil! keepj norm! `y%mz%
|
|
||||||
sil! keepj 'y,'zg/^\s*$/d
|
|
||||||
|
|
||||||
" perform substitutes to mark fields for Align
|
|
||||||
sil! keepj 'y+1,'zv/^\//s/^\s\+\(\S\)/ \1/e
|
|
||||||
sil! keepj 'y+1,'zv/^\//s/\(\S\)\s\+/\1 /eg
|
|
||||||
sil! keepj 'y+1,'zv/^\//s/\* \+/*/ge
|
|
||||||
sil! keepj 'y+1,'zv/^\//s/\w\zs\s*\*/ */ge
|
|
||||||
" func
|
|
||||||
" ws <- declaration -> <-ptr -> <-var-> <-[array][] -> <-glop-> <-end->
|
|
||||||
sil! keepj 'y+1,'zv/^\//s/^\s*\(\(\K\k*\s*\)\+\)\s\+\([(*]*\)\s*\(\K\k*\)\s*\(\(\[.\{-}]\)*\)\s*\(.\{-}\)\=\s*\([,)]\)\s*$/ \1@#\3@\4\5@\7\8/e
|
|
||||||
sil! keepj 'y+1,'z+1g/^\s*\/[*/]/norm! kJ
|
|
||||||
sil! keepj 'y+1,'z+1s%/[*/]%@&@%ge
|
|
||||||
sil! keepj 'y+1,'z+1s%*/%@&%ge
|
|
||||||
AlignCtrl mIp0P0=l @
|
|
||||||
sil! keepj 'y+1,'zAlign
|
|
||||||
sil! keepj 'y,'zs%@\(/[*/]\)@%\t\1 %e
|
|
||||||
sil! keepj 'y,'zs%@\*/% */%e
|
|
||||||
sil! keepj 'y,'zs/@\([,)]\)/\1/
|
|
||||||
sil! keepj 'y,'zs/@/ /
|
|
||||||
AlignCtrl mIlrp0P0= # @
|
|
||||||
sil! keepj 'y+1,'zAlign
|
|
||||||
sil! keepj 'y+1,'zs/#/ /
|
|
||||||
sil! keepj 'y+1,'zs/@//
|
|
||||||
sil! keepj 'y+1,'zs/\(\s\+\)\([,)]\)/\2\1/e
|
|
||||||
|
|
||||||
" Restore
|
|
||||||
call RestoreMark(mykeep)
|
|
||||||
call RestoreMark(mzkeep)
|
|
||||||
let &l:ch= chkeep
|
|
||||||
let &l:gd= gdkeep
|
|
||||||
let &l:ww= wwkeep
|
|
||||||
let &l:ve= vekeep
|
|
||||||
|
|
||||||
" call Dret("AlignMaps#Afnc")
|
|
||||||
endfun
|
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" AlignMaps#FixMultiDec: converts a type arg,arg,arg; line to multiple lines {{{2
|
|
||||||
fun! AlignMaps#FixMultiDec()
|
|
||||||
" call Dfunc("AlignMaps#FixMultiDec()")
|
|
||||||
|
|
||||||
" save register x
|
|
||||||
let xkeep = @x
|
|
||||||
let curline = getline(".")
|
|
||||||
" call Decho("curline<".curline.">")
|
|
||||||
|
|
||||||
let @x=substitute(curline,'^\(\s*[a-zA-Z_ \t][a-zA-Z0-9<>_ \t]*\)\s\+[(*]*\h.*$','\1','')
|
|
||||||
" call Decho("@x<".@x.">")
|
|
||||||
|
|
||||||
" transform line
|
|
||||||
exe 'keepj s/,/;\r'.@x.' /ge'
|
|
||||||
|
|
||||||
"restore register x
|
|
||||||
let @x= xkeep
|
|
||||||
|
|
||||||
" call Dret("AlignMaps#FixMultiDec : my=".line("'y")." mz=".line("'z"))
|
|
||||||
endfun
|
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" AlignMaps#AlignMapsClean: this function removes the AlignMaps plugin {{{2
|
|
||||||
fun! AlignMaps#AlignMapsClean()
|
|
||||||
" call Dfunc("AlignMaps#AlignMapsClean()")
|
|
||||||
for home in split(&rtp,',') + ['']
|
|
||||||
" call Decho("considering home<".home.">")
|
|
||||||
if isdirectory(home)
|
|
||||||
if filereadable(home."/autoload/AlignMaps.vim")
|
|
||||||
" call Decho("deleting ".home."/autoload/AlignMaps.vim")
|
|
||||||
call delete(home."/autoload/AlignMaps.vim")
|
|
||||||
endif
|
|
||||||
if filereadable(home."/plugin/AlignMapsPlugin.vim")
|
|
||||||
" call Decho("deleting ".home."/plugin/AlignMapsPlugin.vim")
|
|
||||||
call delete(home."/plugin/AlignMapsPlugin.vim")
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
" call Dret("AlignMaps#AlignMapsClean")
|
|
||||||
endfun
|
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" AlignMaps#Vis: interfaces with visual maps {{{2
|
|
||||||
fun! AlignMaps#Vis(plugmap) range
|
|
||||||
" call Dfunc("AlignMaps#VisCall(plugmap<".a:plugmap.">) ".a:firstline.",".a:lastline)
|
|
||||||
|
|
||||||
let amark= SaveMark("a")
|
|
||||||
exe a:firstline
|
|
||||||
ka
|
|
||||||
exe a:lastline
|
|
||||||
|
|
||||||
if exists("g:maplocalleader")
|
|
||||||
let maplead= g:maplocalleader
|
|
||||||
elseif exists("g:mapleader")
|
|
||||||
let maplead= g:mapleader
|
|
||||||
else
|
|
||||||
let maplead= '\'
|
|
||||||
endif
|
|
||||||
|
|
||||||
" call Decho("exe norm ".maplead.a:plugmap)
|
|
||||||
exe " norm ".maplead.a:plugmap
|
|
||||||
|
|
||||||
call RestoreMark(amark)
|
|
||||||
" call Dret("AlignMaps#VisCall")
|
|
||||||
endfun
|
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" Restore: {{{1
|
|
||||||
let &cpo= s:keepcpo
|
|
||||||
unlet s:keepcpo
|
|
||||||
" vim: ts=4 fdm=marker
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,213 +0,0 @@
|
||||||
" FILE: plugin/conque_term.vim {{{
|
|
||||||
" AUTHOR: Nico Raffo <nicoraffo@gmail.com>
|
|
||||||
" WEBSITE: http://conque.googlecode.com
|
|
||||||
" MODIFIED: 2011-08-12
|
|
||||||
" VERSION: 2.2, for Vim 7.0
|
|
||||||
" LICENSE:
|
|
||||||
" Conque - Vim terminal/console emulator
|
|
||||||
" Copyright (C) 2009-__YEAR__ Nico Raffo
|
|
||||||
"
|
|
||||||
" MIT License
|
|
||||||
"
|
|
||||||
" Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
" of this software and associated documentation files (the "Software"), to deal
|
|
||||||
" in the Software without restriction, including without limitation the rights
|
|
||||||
" to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
" copies of the Software, and to permit persons to whom the Software is
|
|
||||||
" furnished to do so, subject to the following conditions:
|
|
||||||
"
|
|
||||||
" The above copyright notice and this permission notice shall be included in
|
|
||||||
" all copies or substantial portions of the Software.
|
|
||||||
"
|
|
||||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
" OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
" THE SOFTWARE.
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" See docs/conque_term.txt for help or type :help ConqueTerm
|
|
||||||
|
|
||||||
if exists('g:ConqueTerm_Loaded') || v:version < 700
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
" **********************************************************************************************************
|
|
||||||
" **** CONFIGURATION ***************************************************************************************
|
|
||||||
" **********************************************************************************************************
|
|
||||||
|
|
||||||
" {{{
|
|
||||||
|
|
||||||
" Fast mode {{{
|
|
||||||
" Disables all features which could cause Conque to run slowly, including:
|
|
||||||
" * Disables terminal colors
|
|
||||||
" * Disables some multi-byte character handling
|
|
||||||
if !exists('g:ConqueTerm_FastMode')
|
|
||||||
let g:ConqueTerm_FastMode = 0
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" automatically go into insert mode when entering buffer {{{
|
|
||||||
if !exists('g:ConqueTerm_InsertOnEnter')
|
|
||||||
let g:ConqueTerm_InsertOnEnter = 0
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" Allow user to use <C-w> keys to switch window in insert mode. {{{
|
|
||||||
if !exists('g:ConqueTerm_CWInsert')
|
|
||||||
let g:ConqueTerm_CWInsert = 0
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" Choose key mapping to leave insert mode {{{
|
|
||||||
" If you choose something other than '<Esc>', then <Esc> will be sent to terminal
|
|
||||||
" Using a different key will usually fix Alt/Meta key issues
|
|
||||||
if !exists('g:ConqueTerm_EscKey')
|
|
||||||
let g:ConqueTerm_EscKey = '<Esc>'
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" Use this key to execute the current file in a split window. {{{
|
|
||||||
" THIS IS A GLOBAL KEY MAPPING
|
|
||||||
if !exists('g:ConqueTerm_ExecFileKey')
|
|
||||||
let g:ConqueTerm_ExecFileKey = '<F11>'
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" Use this key to send the current file contents to conque. {{{
|
|
||||||
" THIS IS A GLOBAL KEY MAPPING
|
|
||||||
if !exists('g:ConqueTerm_SendFileKey')
|
|
||||||
let g:ConqueTerm_SendFileKey = '<F10>'
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" Use this key to send selected text to conque. {{{
|
|
||||||
" THIS IS A GLOBAL KEY MAPPING
|
|
||||||
if !exists('g:ConqueTerm_SendVisKey')
|
|
||||||
let g:ConqueTerm_SendVisKey = '<F9>'
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" Use this key to toggle terminal key mappings. {{{
|
|
||||||
" Only mapped inside of Conque buffers.
|
|
||||||
if !exists('g:ConqueTerm_ToggleKey')
|
|
||||||
let g:ConqueTerm_ToggleKey = '<F8>'
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" Enable color. {{{
|
|
||||||
" If your apps use a lot of color it will slow down the shell.
|
|
||||||
" 0 - no terminal colors. You still will see Vim syntax highlighting.
|
|
||||||
" 1 - limited terminal colors (recommended). Past terminal color history cleared regularly.
|
|
||||||
" 2 - all terminal colors. Terminal color history never cleared.
|
|
||||||
if !exists('g:ConqueTerm_Color')
|
|
||||||
let g:ConqueTerm_Color = 1
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" Color mode. Windows ONLY {{{
|
|
||||||
" Set this variable to 'conceal' to use Vim's conceal mode for terminal colors.
|
|
||||||
" This makes colors render much faster, but has some odd baggage.
|
|
||||||
if !exists('g:ConqueTerm_ColorMode')
|
|
||||||
let g:ConqueTerm_ColorMode = ''
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" TERM environment setting {{{
|
|
||||||
if !exists('g:ConqueTerm_TERM')
|
|
||||||
let g:ConqueTerm_TERM = 'vt100'
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" Syntax for your buffer {{{
|
|
||||||
if !exists('g:ConqueTerm_Syntax')
|
|
||||||
let g:ConqueTerm_Syntax = 'conque_term'
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" Keep on updating the shell window after you've switched to another buffer {{{
|
|
||||||
if !exists('g:ConqueTerm_ReadUnfocused')
|
|
||||||
let g:ConqueTerm_ReadUnfocused = 0
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" Use this regular expression to highlight prompt {{{
|
|
||||||
if !exists('g:ConqueTerm_PromptRegex')
|
|
||||||
let g:ConqueTerm_PromptRegex = '^\w\+@[0-9A-Za-z_.-]\+:[0-9A-Za-z_./\~,:-]\+\$'
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" Choose which Python version to attempt to load first {{{
|
|
||||||
" Valid values are 2, 3 or 0 (no preference)
|
|
||||||
if !exists('g:ConqueTerm_PyVersion')
|
|
||||||
let g:ConqueTerm_PyVersion = 2
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" Path to python.exe. (Windows only) {{{
|
|
||||||
" By default, Conque will check C:\PythonNN\python.exe then will search system path
|
|
||||||
" If you have installed Python in an unusual location and it's not in your path, fill in the full path below
|
|
||||||
" E.g. 'C:\Program Files\Python\Python27\python.exe'
|
|
||||||
if !exists('g:ConqueTerm_PyExe')
|
|
||||||
let g:ConqueTerm_PyExe = ''
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" Automatically close buffer when program exits {{{
|
|
||||||
if !exists('g:ConqueTerm_CloseOnEnd')
|
|
||||||
let g:ConqueTerm_CloseOnEnd = 0
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" Send function key presses to terminal {{{
|
|
||||||
if !exists('g:ConqueTerm_SendFunctionKeys')
|
|
||||||
let g:ConqueTerm_SendFunctionKeys = 0
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" Session support {{{
|
|
||||||
if !exists('g:ConqueTerm_SessionSupport')
|
|
||||||
let g:ConqueTerm_SessionSupport = 0
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" hide Conque startup messages {{{
|
|
||||||
" messages should only appear the first 3 times you start Vim with a new version of Conque
|
|
||||||
" and include important Conque feature and option descriptions
|
|
||||||
" TODO - disabled and unused for now
|
|
||||||
if !exists('g:ConqueTerm_StartMessages')
|
|
||||||
let g:ConqueTerm_StartMessages = 1
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" Windows character code page {{{
|
|
||||||
" Leave at 0 to use current environment code page.
|
|
||||||
" Use 65001 for utf-8, although many console apps do not support it.
|
|
||||||
if !exists('g:ConqueTerm_CodePage')
|
|
||||||
let g:ConqueTerm_CodePage = 0
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" InsertCharPre support {{{
|
|
||||||
" Disable this feature by default, still in Beta
|
|
||||||
if !exists('g:ConqueTerm_InsertCharPre')
|
|
||||||
let g:ConqueTerm_InsertCharPre = 0
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" **********************************************************************************************************
|
|
||||||
" **** Startup *********************************************************************************************
|
|
||||||
" **********************************************************************************************************
|
|
||||||
|
|
||||||
" Startup {{{
|
|
||||||
|
|
||||||
let g:ConqueTerm_Loaded = 1
|
|
||||||
let g:ConqueTerm_Idx = 0
|
|
||||||
let g:ConqueTerm_Version = 210
|
|
||||||
|
|
||||||
command! -nargs=+ -complete=shellcmd ConqueTerm call conque_term#open(<q-args>)
|
|
||||||
command! -nargs=+ -complete=shellcmd ConqueTermSplit call conque_term#open(<q-args>, ['belowright split'])
|
|
||||||
command! -nargs=+ -complete=shellcmd ConqueTermVSplit call conque_term#open(<q-args>, ['belowright vsplit'])
|
|
||||||
command! -nargs=+ -complete=shellcmd ConqueTermTab call conque_term#open(<q-args>, ['tabnew'])
|
|
||||||
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" **********************************************************************************************************
|
|
||||||
" **** Global Mappings & Autocommands **********************************************************************
|
|
||||||
" **********************************************************************************************************
|
|
||||||
|
|
||||||
" Startup {{{
|
|
||||||
|
|
||||||
if exists('g:ConqueTerm_SessionSupport') && g:ConqueTerm_SessionSupport == 1
|
|
||||||
autocmd SessionLoadPost * call conque_term#resume_session()
|
|
||||||
endif
|
|
||||||
|
|
||||||
if maparg(g:ConqueTerm_ExecFileKey, 'n') == ''
|
|
||||||
exe 'nnoremap <silent> ' . g:ConqueTerm_ExecFileKey . ' :call conque_term#exec_file()<CR>'
|
|
||||||
endif
|
|
||||||
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" vim:foldmethod=marker
|
|
|
@ -1,629 +0,0 @@
|
||||||
if &cp || exists("loaded_jsbeautify")
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
let loaded_jsbeautify = 3
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function! s:trim_output()
|
|
||||||
while len(s:output) > 0 && (s:output[len(s:output)-1] == " " || s:output[len(s:output)-1] == s:indent_string)
|
|
||||||
call remove(s:output, -1)
|
|
||||||
endwhile
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:print_newline(ignore_repeated)
|
|
||||||
let s:if_line_flag = 0
|
|
||||||
call s:trim_output()
|
|
||||||
if len(s:output)==0
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
if s:output[len(s:output)-1] != "\n" || !a:ignore_repeated
|
|
||||||
call add(s:output, "\n")
|
|
||||||
endif
|
|
||||||
let index = 0
|
|
||||||
while index < s:indent_level
|
|
||||||
call add(s:output, s:indent_string)
|
|
||||||
let index += 1
|
|
||||||
endwhile
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:print_space()
|
|
||||||
let last_output = " "
|
|
||||||
if len(s:output) > 0
|
|
||||||
let last_output = s:output[len(s:output) - 1]
|
|
||||||
endif
|
|
||||||
if last_output != " " && last_output != "\n" && last_output != s:indent_string
|
|
||||||
call add(s:output, " ")
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:print_token()
|
|
||||||
call add(s:output, s:token_text)
|
|
||||||
endfunctio
|
|
||||||
|
|
||||||
function! s:indent()
|
|
||||||
let s:indent_level += 1
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:unindent()
|
|
||||||
if s:indent_level
|
|
||||||
let s:indent_level -= 1
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:remove_indent()
|
|
||||||
if len(s:output)>0 && s:output[len(s:output) -1] == s:indent_string
|
|
||||||
call remove(s:output, -1)
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:set_mode(mode)
|
|
||||||
call add(s:modes, s:current_mode)
|
|
||||||
let s:current_mode = a:mode
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:restore_mode()
|
|
||||||
if s:current_mode == "DO_BLOCK"
|
|
||||||
let s:do_block_just_closed = 1
|
|
||||||
else
|
|
||||||
let s:do_block_just_closed = 0
|
|
||||||
endif
|
|
||||||
let s:current_mode = remove(s:modes, -1)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:in_array(what, arr)
|
|
||||||
return index(a:arr, a:what) != -1
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:get_next_token()
|
|
||||||
let n_newlines = 0
|
|
||||||
|
|
||||||
if s:parser_pos >= len(s:input)
|
|
||||||
return ["", "TK_EOF"]
|
|
||||||
endif
|
|
||||||
|
|
||||||
let c = s:input[s:parser_pos]
|
|
||||||
let s:parser_pos += 1
|
|
||||||
|
|
||||||
while s:in_array(c, s:whitespace)
|
|
||||||
if s:parser_pos >= len(s:input)
|
|
||||||
return ["", "TK_EOF"]
|
|
||||||
endif
|
|
||||||
|
|
||||||
if c == "\n"
|
|
||||||
let n_newlines += 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
let c = s:input[s:parser_pos]
|
|
||||||
let s:parser_pos += 1
|
|
||||||
endwhile
|
|
||||||
|
|
||||||
let wanted_newline = 0
|
|
||||||
|
|
||||||
if s:opt_preserve_newlines
|
|
||||||
if n_newlines > 1
|
|
||||||
for i in [0, 1]
|
|
||||||
call s:print_newline(i==0)
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
let wanted_newline = n_newlines == 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
if s:in_array(c, s:wordchar)
|
|
||||||
if s:parser_pos < len(s:input)
|
|
||||||
while s:in_array(s:input[s:parser_pos], s:wordchar)
|
|
||||||
let c .= s:input[s:parser_pos]
|
|
||||||
let s:parser_pos += 1
|
|
||||||
if s:parser_pos == len(s:input)
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
endif
|
|
||||||
|
|
||||||
"if s:parser_pos != len(s:input) && c =~ /^[0-9]+[Ee]$/ && (s:input[s:parser_pos] == "-" || s:input[s:parser_pos] == "+")
|
|
||||||
"let sign = s:input[s:parser_pos]
|
|
||||||
"let s:parser_pos += 1
|
|
||||||
|
|
||||||
"let t = get_next_token(s:parser_pos)
|
|
||||||
"let c .= sign . t[0]
|
|
||||||
"return [c, "TK_WORD"]
|
|
||||||
" endif
|
|
||||||
|
|
||||||
if c == "in"
|
|
||||||
return [c, "TK_OPERATOR"]
|
|
||||||
endif
|
|
||||||
if wanted_newline && s:last_type != "TK_OPERATOR" && !s:if_line_flag
|
|
||||||
call s:print_newline(1)
|
|
||||||
endif
|
|
||||||
return [c, "TK_WORD"]
|
|
||||||
endif
|
|
||||||
if c == "(" || c == "["
|
|
||||||
return [c, "TK_START_EXPR"]
|
|
||||||
endif
|
|
||||||
|
|
||||||
if c == ")" || c == "]"
|
|
||||||
return [c, "TK_END_EXPR"]
|
|
||||||
endif
|
|
||||||
|
|
||||||
if c == "{"
|
|
||||||
return [c, "TK_START_BLOCK"]
|
|
||||||
endif
|
|
||||||
|
|
||||||
if c == "}"
|
|
||||||
return [c, "TK_END_BLOCK"]
|
|
||||||
endif
|
|
||||||
|
|
||||||
if c == ";"
|
|
||||||
return [c, "TK_SEMICOLON"]
|
|
||||||
endif
|
|
||||||
|
|
||||||
if c == "/"
|
|
||||||
let comment = ""
|
|
||||||
if s:input[s:parser_pos] == "*"
|
|
||||||
let s:parser_pos += 1
|
|
||||||
if s:parser_pos < len(s:input)
|
|
||||||
while !(s:input[s:parser_pos] == "*" && s:parser_pos + 1 < len(s:input) && s:input[s:parser_pos + 1] == "/" && s:parser_pos < len(s:input))
|
|
||||||
let comment .= s:input[s:parser_pos]
|
|
||||||
let s:parser_pos += 1
|
|
||||||
if s:parser_pos >= len(s:input)
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
endif
|
|
||||||
let s:parser_pos += 2
|
|
||||||
return ['/*' . comment . '*/', 'TK_BLOCK_COMMENT']
|
|
||||||
endif
|
|
||||||
|
|
||||||
" peek for comment // ...
|
|
||||||
if s:input[s:parser_pos] == "/"
|
|
||||||
let comment = c
|
|
||||||
while s:input[s:parser_pos] != "\r" && s:input[s:parser_pos] != "\n"
|
|
||||||
let comment .= s:input[s:parser_pos]
|
|
||||||
let s:parser_pos += 1
|
|
||||||
if s:parser_pos >= len(s:input)
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
let s:parser_pos += 1
|
|
||||||
if wanted_newline
|
|
||||||
call s:print_newline(1)
|
|
||||||
endif
|
|
||||||
return [comment, "TK_COMMENT"]
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
if c == "'" || c =='"' || (c == "/" && ((s:last_type == "TK_WORD" && s:last_text == "return") || (s:last_type == "TK_START_EXPR" || s:last_type == "TK_START_BLOCK" || s:last_type == "TK_END_BLOCK" || s:last_type == "TK_OPERATOR" || s:last_type == "TK_EOF" || s:last_type == "TK_SEMICOLON")))
|
|
||||||
let sep = c
|
|
||||||
let esc = 0
|
|
||||||
let resulting_string = c
|
|
||||||
|
|
||||||
if s:parser_pos < len(s:input)
|
|
||||||
while esc || s:input[s:parser_pos] != sep
|
|
||||||
let resulting_string .= s:input[s:parser_pos]
|
|
||||||
if !esc
|
|
||||||
let esc = s:input[s:parser_pos] == "\\"
|
|
||||||
else
|
|
||||||
let esc = 0
|
|
||||||
endif
|
|
||||||
let s:parser_pos += 1
|
|
||||||
if s:parser_pos >= len(s:input)
|
|
||||||
return [resulting_string, "TK_STRING"]
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
endif
|
|
||||||
|
|
||||||
let s:parser_pos += 1
|
|
||||||
|
|
||||||
let resulting_string .= sep
|
|
||||||
|
|
||||||
if sep == "/"
|
|
||||||
|
|
||||||
while s:parser_pos < len(s:input) && s:in_array(s:input[s:parser_pos], s:wordchar)
|
|
||||||
let resulting_string .= s:input[s:parser_pos]
|
|
||||||
let s:parser_pos += 1
|
|
||||||
endwhile
|
|
||||||
endif
|
|
||||||
return [resulting_string, "TK_STRING"]
|
|
||||||
endif
|
|
||||||
|
|
||||||
if c == "#"
|
|
||||||
let sharp = "#"
|
|
||||||
if s:parser_pos < len(s:input) && s:in_array(s:input[s:parser_pos], s:digits)
|
|
||||||
let c = s:input[s:parser_pos]
|
|
||||||
let sharp .= c
|
|
||||||
let s:parser_pos += 1
|
|
||||||
|
|
||||||
while s:parser_pos < len(s:input) && c != "#" && c !="="
|
|
||||||
let c = s:input[s:parser_pos]
|
|
||||||
let sharp .= c
|
|
||||||
let s:parser_pos += 1
|
|
||||||
endwhile
|
|
||||||
|
|
||||||
if c == "#"
|
|
||||||
return [sharp, "TK_WORD"]
|
|
||||||
else
|
|
||||||
return [sharp, "TK_OPERATOR"]
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
if c == "<" && s:input[s:parser_pos-1 : s:parser_pos+3] == "<!--"
|
|
||||||
let s:parser_pos += 3
|
|
||||||
return ["<!--", "TK_COMMENT"]
|
|
||||||
endif
|
|
||||||
|
|
||||||
if c == "-" && s:input[s:parser_pos-1 : s:parser_pos+2] == "-->"
|
|
||||||
let s:parser_pos += 2
|
|
||||||
if wanted_newline
|
|
||||||
call s:print_newline(1)
|
|
||||||
endif
|
|
||||||
return ["-->", "TK_COMMENT"]
|
|
||||||
endif
|
|
||||||
|
|
||||||
if s:in_array(c, s:punct)
|
|
||||||
while s:parser_pos < len(s:input) && s:in_array(c . s:input[s:parser_pos], s:punct)
|
|
||||||
let c .= s:input[s:parser_pos]
|
|
||||||
let s:parser_pos += 1
|
|
||||||
if s:parser_pos >= len(s:input)
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
|
|
||||||
return [c, "TK_OPERATOR"]
|
|
||||||
endif
|
|
||||||
|
|
||||||
return [c, "TK_UNKNOWN"]
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:is_js()
|
|
||||||
return expand("%:e") == "js"
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
"function! g:Jsbeautify(js_source_text, options)
|
|
||||||
function! g:Jsbeautify()
|
|
||||||
if !s:is_js()
|
|
||||||
echo "Not a JS file."
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
"let a:options = {}
|
|
||||||
let s:opt_indent_size = 1
|
|
||||||
let s:opt_indent_char = " "
|
|
||||||
let s:opt_preserve_newlines = 1
|
|
||||||
let s:opt_indent_level = 0
|
|
||||||
|
|
||||||
let s:if_line_flag = 0
|
|
||||||
"--------------------------------
|
|
||||||
|
|
||||||
let s:indent_string = ""
|
|
||||||
while s:opt_indent_size > 0
|
|
||||||
let s:indent_string .= s:opt_indent_char
|
|
||||||
let s:opt_indent_size -= 1
|
|
||||||
endwhile
|
|
||||||
|
|
||||||
let s:indent_level = s:opt_indent_level
|
|
||||||
|
|
||||||
let lines = getline(1, "$")
|
|
||||||
let s:input = join(lines, "\n")
|
|
||||||
"let s:input = a:js_source_text
|
|
||||||
|
|
||||||
let s:last_word = "" "last 'TK_WORD' passed
|
|
||||||
let s:last_type = "TK_START_EXPR" "last token type
|
|
||||||
let s:last_text = "" "last token text
|
|
||||||
let s:output = []
|
|
||||||
|
|
||||||
let s:do_block_just_closed = 0
|
|
||||||
let s:var_line = 0
|
|
||||||
let s:var_line_tainted = 0
|
|
||||||
|
|
||||||
let s:whitespace = ["\n", "\r", "\t", " "]
|
|
||||||
let s:wordchar = split("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$", '\zs')
|
|
||||||
let s:digits = split("0123456789", '\zs')
|
|
||||||
|
|
||||||
"<!-- is a special case (ok, it"s a minor hack actually)
|
|
||||||
let s:punct = split("+ - * / % & ++ -- = += -= *= /= %= == === != !== > < >= <= >> << >>> >>>= >>= <<= && &= | || ! !! , : ? ^ ^= |= ::", " ")
|
|
||||||
|
|
||||||
let s:line_starters = split("continue,try,throw,return,var,if,switch,case,default,for,while,break", ",")
|
|
||||||
|
|
||||||
let s:current_mode = "BLOCK"
|
|
||||||
let s:modes = [s:current_mode]
|
|
||||||
|
|
||||||
let s:parser_pos = 0
|
|
||||||
let s:in_case = 0
|
|
||||||
while 1
|
|
||||||
let t = s:get_next_token()
|
|
||||||
let s:token_text = t[0]
|
|
||||||
let s:token_type = t[1]
|
|
||||||
if s:token_type == "TK_EOF"
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
|
|
||||||
try
|
|
||||||
if s:token_type == "TK_START_EXPR"
|
|
||||||
let s:var_line = 0
|
|
||||||
call s:set_mode("EXPRESSION")
|
|
||||||
if s:last_text == ";"
|
|
||||||
call s:print_newline(1)
|
|
||||||
elseif s:last_type == "TK_END_EXPR" || s:last_type == "TK_START_EXPR"
|
|
||||||
" do nothing on (( and )( and ][ and ]( ..
|
|
||||||
elseif s:last_type != "TK_WORD" && s:last_type != "TK_OPERATOR"
|
|
||||||
call s:print_space()
|
|
||||||
elseif s:in_array(s:last_word, s:line_starters)
|
|
||||||
call s:print_space()
|
|
||||||
endif
|
|
||||||
|
|
||||||
call s:print_token()
|
|
||||||
|
|
||||||
elseif s:token_type == "TK_END_EXPR"
|
|
||||||
call s:print_token()
|
|
||||||
call s:restore_mode()
|
|
||||||
elseif s:token_type == "TK_START_BLOCK"
|
|
||||||
|
|
||||||
if s:last_word == "do"
|
|
||||||
call s:set_mode("DO_BLOCK")
|
|
||||||
else
|
|
||||||
call s:set_mode("BLOCK")
|
|
||||||
endif
|
|
||||||
if s:last_type != "TK_OPERATOR" && s:last_type != "TK_START_EXPR"
|
|
||||||
if s:last_type == "TK_START_BLOCK"
|
|
||||||
call s:print_newline(1)
|
|
||||||
else
|
|
||||||
call s:print_space()
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
call s:print_token()
|
|
||||||
call s:indent()
|
|
||||||
elseif s:token_type == "TK_END_BLOCK"
|
|
||||||
if s:last_type == "TK_START_BLOCK"
|
|
||||||
call s:remove_indent()
|
|
||||||
call s:unindent()
|
|
||||||
else
|
|
||||||
call s:unindent()
|
|
||||||
call s:print_newline(1)
|
|
||||||
endif
|
|
||||||
call s:print_token()
|
|
||||||
call s:restore_mode()
|
|
||||||
|
|
||||||
elseif s:token_type == "TK_WORD"
|
|
||||||
if s:do_block_just_closed
|
|
||||||
" do {} ## while ()
|
|
||||||
call s:print_space()
|
|
||||||
call s:print_token()
|
|
||||||
call s:print_space()
|
|
||||||
let s:do_block_just_closed = 0
|
|
||||||
throw "jump out"
|
|
||||||
endif
|
|
||||||
if s:token_text == "case" || s:token_text == "default"
|
|
||||||
if s:last_text == ":"
|
|
||||||
"switch cases following one another
|
|
||||||
call s:remove_indent()
|
|
||||||
else
|
|
||||||
" case statement starts in the same line where switch
|
|
||||||
call s:unindent()
|
|
||||||
call s:print_newline(1)
|
|
||||||
call s:indent()
|
|
||||||
endif
|
|
||||||
call s:print_token()
|
|
||||||
let s:in_case = 1
|
|
||||||
throw "jump out"
|
|
||||||
endif
|
|
||||||
|
|
||||||
let s:prefix = "NONE"
|
|
||||||
|
|
||||||
if s:last_type == "TK_END_BLOCK"
|
|
||||||
if !s:in_array(tolower(s:token_text), ["else", "catch", "finally"])
|
|
||||||
let s:prefix = "NEWLINE"
|
|
||||||
else
|
|
||||||
let s:prefix = "SPACE"
|
|
||||||
call s:print_space()
|
|
||||||
endif
|
|
||||||
elseif s:last_type == "TK_SEMICOLON" && (s:current_mode == "BLOCK" || s:current_mode == "DO_BLOCK")
|
|
||||||
let s:prefix = "NEWLINE"
|
|
||||||
elseif s:last_type == "TK_SEMICOLON" && s:current_mode == "EXPRESSION"
|
|
||||||
let s:prefix = "SPACE"
|
|
||||||
elseif s:last_type == "TK_STRING"
|
|
||||||
let s:prefix = "NEWLINE"
|
|
||||||
elseif s:last_type == "TK_WORD"
|
|
||||||
let s:prefix = "SPACE"
|
|
||||||
elseif s:last_type == "TK_START_BLOCK"
|
|
||||||
let s:prefix = "NEWLINE"
|
|
||||||
elseif s:last_type == "TK_END_EXPR"
|
|
||||||
call s:print_space()
|
|
||||||
let s:prefix = "NEWLINE"
|
|
||||||
endif
|
|
||||||
|
|
||||||
if s:last_type != "TK_END_BLOCK" && s:in_array(tolower(s:token_text), ["else", "catch", "finally"])
|
|
||||||
call s:print_newline(1)
|
|
||||||
elseif s:in_array(s:token_text, s:line_starters) || s:prefix == "NEWLINE"
|
|
||||||
if s:last_text == "else"
|
|
||||||
call s:print_space()
|
|
||||||
elseif (s:last_type == "TK_START_EXPR" || s:last_text == "=" || s:last_text == ",") && s:token_text == "function"
|
|
||||||
" no need to force newline on "function":
|
|
||||||
" DONOTHINT
|
|
||||||
elseif s:last_type == "TK_WORD" && (s:last_text == "return" || s:last_text == "throw")
|
|
||||||
" no newline between "return nnn"
|
|
||||||
call s:print_space()
|
|
||||||
elseif s:last_type != "TK_END_EXPR"
|
|
||||||
if (s:last_type != "TK_START_EXPR" || s:token_text != "var") && s:last_text != ":"
|
|
||||||
" no need to force newline on "var": for (var
|
|
||||||
" x = 0...)
|
|
||||||
if s:token_text == "if" && s:last_type == "TK_WORD" && s:last_word == "else"
|
|
||||||
" no newline for } else if {
|
|
||||||
call s:print_space()
|
|
||||||
else
|
|
||||||
call s:print_newline(1)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
if s:in_array(s:token_text, s:line_starters) && s:last_text != ")"
|
|
||||||
call s:print_newline(1)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
elseif s:prefix == "SPACE"
|
|
||||||
call s:print_space()
|
|
||||||
endif
|
|
||||||
call s:print_token()
|
|
||||||
let s:last_word = s:token_text
|
|
||||||
|
|
||||||
if s:token_text == "var"
|
|
||||||
let s:var_line = 1
|
|
||||||
let s:var_line_tainted = 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
if s:token_text == "if" || s:token_text == "else"
|
|
||||||
let s:if_line_flag = 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
elseif s:token_type == "TK_SEMICOLON"
|
|
||||||
call s:print_token()
|
|
||||||
let s:var_line = 0
|
|
||||||
|
|
||||||
elseif s:token_type == "TK_STRING"
|
|
||||||
if s:last_type == "TK_START_BLOCK" || s:last_type == "TK_END_BLOCK" || s:last_type == "TK_SEMICOLON"
|
|
||||||
call s:print_newline(1)
|
|
||||||
elseif s:last_type == "TK_WORD"
|
|
||||||
call s:print_space()
|
|
||||||
endif
|
|
||||||
call s:print_token()
|
|
||||||
|
|
||||||
elseif s:token_type == "TK_OPERATOR"
|
|
||||||
|
|
||||||
let start_delim = 1
|
|
||||||
let end_delim = 1
|
|
||||||
if s:var_line && s:token_text != ","
|
|
||||||
let s:var_line_tainted = 1
|
|
||||||
if s:token_text == ":"
|
|
||||||
let s:var_line = 0
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
if s:var_line && s:token_text=="," && s:current_mode == "EXPRESSION"
|
|
||||||
" do not break on comma, for(var a = 1, b = 2)
|
|
||||||
let s:var_line_tainted = 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
if s:token_text == ":" && s:in_case
|
|
||||||
call s:print_token()
|
|
||||||
call s:print_newline(1)
|
|
||||||
throw "jump out"
|
|
||||||
endif
|
|
||||||
|
|
||||||
if s:token_text == "::"
|
|
||||||
" no spaces around exotic namespacing syntax operator
|
|
||||||
call s:print_token()
|
|
||||||
throw "jump out"
|
|
||||||
endif
|
|
||||||
|
|
||||||
let s:in_case = 0
|
|
||||||
|
|
||||||
if s:token_text == ","
|
|
||||||
if s:var_line
|
|
||||||
if s:var_line_tainted
|
|
||||||
call s:print_token()
|
|
||||||
call s:print_newline(1)
|
|
||||||
let s:var_line_tainted = 0
|
|
||||||
else
|
|
||||||
call s:print_token()
|
|
||||||
call s:print_space()
|
|
||||||
endif
|
|
||||||
elseif s:last_type == "TK_END_BLOCK"
|
|
||||||
call s:print_token()
|
|
||||||
call s:print_newline(1)
|
|
||||||
else
|
|
||||||
if s:current_mode == "BLOCK"
|
|
||||||
call s:print_token()
|
|
||||||
call s:print_newline(1)
|
|
||||||
else
|
|
||||||
" EXPR od DO_BLOCK
|
|
||||||
call s:print_token()
|
|
||||||
call s:print_space()
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
throw "jump out"
|
|
||||||
elseif s:token_text == "--" || s:token_text == "++" " unary operators special case
|
|
||||||
if s:last_text == ";"
|
|
||||||
" space for (;; ++i)
|
|
||||||
let start_delim = 1
|
|
||||||
let end_delim = 0
|
|
||||||
else
|
|
||||||
let start_delim = 0
|
|
||||||
let end_delim = 0
|
|
||||||
endif
|
|
||||||
elseif s:token_text == "!" && s:last_type == "TK_START_EXPR"
|
|
||||||
" special case handling: if (!a)
|
|
||||||
let start_delim = 0
|
|
||||||
let end_delim = 0
|
|
||||||
elseif s:last_type == "TK_OPERATOR"
|
|
||||||
let s:start_delim = 0
|
|
||||||
let s:end_delim = 0
|
|
||||||
elseif s:last_type == "TK_END_EXPR"
|
|
||||||
let s:start_delim = 1
|
|
||||||
let s:end_delim = 1
|
|
||||||
elseif s:token_text == "."
|
|
||||||
" decimal digits or object.property
|
|
||||||
let start_delim = 0
|
|
||||||
let end_delim = 0
|
|
||||||
elseif s:token_text == ":"
|
|
||||||
" zz: xx
|
|
||||||
" can"t differentiate ternary op, so for now it"s a ? b:
|
|
||||||
" c;without space before colon
|
|
||||||
if s:last_text =~ '/^\d+$/'
|
|
||||||
" a little help for ternary a ? 1 : 0
|
|
||||||
let start_delim = 1
|
|
||||||
else
|
|
||||||
let start_delim = 0
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
if start_delim
|
|
||||||
call s:print_space()
|
|
||||||
endif
|
|
||||||
|
|
||||||
call s:print_token()
|
|
||||||
|
|
||||||
if end_delim
|
|
||||||
call s:print_space()
|
|
||||||
endif
|
|
||||||
throw "jump out"
|
|
||||||
|
|
||||||
elseif s:token_type == "TK_BLOCK_COMMENT"
|
|
||||||
call s:print_newline(1)
|
|
||||||
call s:print_token()
|
|
||||||
call s:print_newline(1)
|
|
||||||
|
|
||||||
elseif s:token_type == "TK_COMMENT"
|
|
||||||
|
|
||||||
"call s:print_newline(1)
|
|
||||||
call s:print_space()
|
|
||||||
call s:print_token()
|
|
||||||
call s:print_newline(1)
|
|
||||||
|
|
||||||
elseif s:token_type == "TK_UNKNOWN"
|
|
||||||
call s:print_token()
|
|
||||||
throw "jump out"
|
|
||||||
endif
|
|
||||||
catch /.*/
|
|
||||||
if v:exception != 'jump out'
|
|
||||||
echo "exception caught: " v:exception
|
|
||||||
endif
|
|
||||||
endtry
|
|
||||||
|
|
||||||
let s:last_type = s:token_type
|
|
||||||
let s:last_text = s:token_text
|
|
||||||
endwhile
|
|
||||||
|
|
||||||
" mark position
|
|
||||||
let save_cursor = getpos(".")
|
|
||||||
|
|
||||||
let ret = join(s:output, "")
|
|
||||||
:g/.*/d
|
|
||||||
let @0 = ret
|
|
||||||
:put!0
|
|
||||||
|
|
||||||
" go back
|
|
||||||
call setpos('.', save_cursor)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
nnoremap <silent> <leader>ff :call g:Jsbeautify()<cr>
|
|
|
@ -1,108 +0,0 @@
|
||||||
"
|
|
||||||
" File: open_terminal.vim
|
|
||||||
"
|
|
||||||
" Requires:
|
|
||||||
" platform Terminal File manager
|
|
||||||
" Mac Terminal.app Finder
|
|
||||||
" (with Applescript)
|
|
||||||
" Gnome gnome-terminal nautilus
|
|
||||||
" KDE konsole konqueror
|
|
||||||
" Windows cmd explorer
|
|
||||||
" (with start)
|
|
||||||
" cygwin bash explorer
|
|
||||||
"
|
|
||||||
" Example:
|
|
||||||
" nnoremap <silent> <F9> :OpenTerminal<CR>
|
|
||||||
" nnoremap <silent> <F10> :OpenFilemanager<CR><CR>
|
|
||||||
"
|
|
||||||
" Commands:
|
|
||||||
" OpenTerminal
|
|
||||||
" OpenFilemanager
|
|
||||||
"
|
|
||||||
|
|
||||||
" OpenTerminal {{{1
|
|
||||||
function! s:open_terminal()
|
|
||||||
let l:current_dir = getcwd()
|
|
||||||
execute("chdir " . escape(expand("%:p:h"), " \"'"))
|
|
||||||
|
|
||||||
if has("mac")
|
|
||||||
let l:cmd = "
|
|
||||||
\ tell application 'System Events' \n
|
|
||||||
\ set is_term_running to exists application process '$Terminal' \n
|
|
||||||
\ end tell \n
|
|
||||||
\
|
|
||||||
\ set cmd to 'cd $current_path' \n
|
|
||||||
\ tell application '$Terminal' \n
|
|
||||||
\ activate \n
|
|
||||||
\ if is_term_running is true then \n
|
|
||||||
\ do script with command cmd \n
|
|
||||||
\ else \n
|
|
||||||
\ do script with command cmd in window 1 \n
|
|
||||||
\ end if \n
|
|
||||||
\ end tell \n
|
|
||||||
\ "
|
|
||||||
let l:cmd = substitute(l:cmd, "'", '\\"', 'g')
|
|
||||||
let l:cmd = substitute( l:cmd, "$Terminal", "Terminal", "g" )
|
|
||||||
let l:cmd = substitute( l:cmd, "$current_path", "'" . expand("%:p:h") . "'" , "g")
|
|
||||||
call system('osascript -e " ' . l:cmd . '"')
|
|
||||||
|
|
||||||
elseif has("gui_gnome") && executable("gnome-terminal")
|
|
||||||
call system("gnome-terminal &")
|
|
||||||
elseif has("gui_gnome") && executable("konsole")
|
|
||||||
call system("konsole &")
|
|
||||||
elseif has("gui_win32")
|
|
||||||
try
|
|
||||||
call system("start cmd")
|
|
||||||
catch /E484:/
|
|
||||||
echo "Ignore E484 error in Windows platform"
|
|
||||||
endtry
|
|
||||||
elseif executable("bash")
|
|
||||||
!bash
|
|
||||||
elseif has("win32")
|
|
||||||
stop
|
|
||||||
endif
|
|
||||||
|
|
||||||
execute("chdir " . escape(l:current_dir, " \"'"))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
command! -nargs=0 -bar OpenTerminal call s:open_terminal()
|
|
||||||
|
|
||||||
"}}}1
|
|
||||||
|
|
||||||
" OpenFilemanager {{{1
|
|
||||||
function! s:open_filemanager()
|
|
||||||
let l:cmd = "$cmd ."
|
|
||||||
|
|
||||||
let l:current_dir = getcwd()
|
|
||||||
execute("chdir " . escape(expand("%:p:h"), " \"'"))
|
|
||||||
|
|
||||||
if has("mac")
|
|
||||||
call system("open .")
|
|
||||||
elseif has("gui_gnome") && executable("nautilus")
|
|
||||||
call system("nautilus .")
|
|
||||||
elseif has("gui_gnome") && executable("konqueror")
|
|
||||||
call system("konqueror .")
|
|
||||||
elseif has("gui_win32") || has("win32")
|
|
||||||
call system("explorer .")
|
|
||||||
elseif executable("bash")
|
|
||||||
!bash
|
|
||||||
endif
|
|
||||||
|
|
||||||
execute("chdir " . escape(l:current_dir, " \"'"))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
command! -nargs=0 -bar OpenFilemanager call s:open_filemanager()
|
|
||||||
" }}}1
|
|
||||||
|
|
||||||
" About file info {{{1
|
|
||||||
"=============================================================================
|
|
||||||
" Copyright (c) 2009 by neocoin
|
|
||||||
" File: open_terminal.vim
|
|
||||||
" Author: Sangmin Ryu (neocoin@gmail.com)
|
|
||||||
" Date: Tue Dec 22 13:33:32 PST 2009
|
|
||||||
" License: The MIT License
|
|
||||||
" Version: 0.1
|
|
||||||
"=============================================================================
|
|
||||||
" }}}1
|
|
||||||
|
|
||||||
" vim: set fdm=marker:
|
|
|
@ -1,75 +0,0 @@
|
||||||
" Copyright by Andrea Mistrali <am@am.cx>
|
|
||||||
" First version: Who knows?
|
|
||||||
" Last modified: 2009-04-28T17:26 CEST (+0200)
|
|
||||||
"
|
|
||||||
" Synopsis: Templating system for vim
|
|
||||||
"
|
|
||||||
" Remember to define in your vimrc the following var
|
|
||||||
" let g:fullname = 'Your Full Name'
|
|
||||||
" let g:email = 'your.email@address'
|
|
||||||
"
|
|
||||||
" Skeleton files could contain (in the first 20 lines) the following
|
|
||||||
" 'vars':
|
|
||||||
" @@LONGNAME@@ - replaced by g:fullname
|
|
||||||
" @@EMAIL@@ - replaced by g:email
|
|
||||||
" @@DESCR@@ - Synopsis of file (asked by this plugin)
|
|
||||||
" @@crdate@@ - replaced by creation date
|
|
||||||
|
|
||||||
" Define template directory
|
|
||||||
let g:skeletons = '~/.vim/templates'
|
|
||||||
let s:timeFormat= "%FT%H:%M %Z (%z)"
|
|
||||||
|
|
||||||
" Preserve template files
|
|
||||||
augroup newfiles
|
|
||||||
" First we load templates for the file type
|
|
||||||
autocmd BufNewFile * ks|call OpenFile()|'s
|
|
||||||
|
|
||||||
" Update of "Last Modified" date on writing
|
|
||||||
" autocmd BufWritePre,FileWritePre * ks|call LastMod()|'s
|
|
||||||
|
|
||||||
" Protect templates and plugin, removing write commands
|
|
||||||
autocmd BufRead,BufNewFile ~/.vim/templates/* au! newfiles
|
|
||||||
autocmd BufRead,BufNewFile */skeleton.vim au! newfiles
|
|
||||||
autocmd BufWritePre,FileWritePre */skeleton.vim au! newfiles
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
|
|
||||||
" Function to modify "Last Modified" date. Works on first N lines
|
|
||||||
function! LastMod()
|
|
||||||
if line("$") > 20
|
|
||||||
let l = 20
|
|
||||||
else
|
|
||||||
let l = line("$")
|
|
||||||
endif
|
|
||||||
execute "1," . l . "s/Last modified: .*/Last modified: " .
|
|
||||||
\ strftime(s:timeFormat) . "/e"
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function to open a file and set some defaults
|
|
||||||
function! OpenFile()
|
|
||||||
let s:filename=expand("<afile>")
|
|
||||||
let l:ext=fnamemodify(s:filename, ":e")
|
|
||||||
let l:skel = g:skeletons."/skeleton.".l:ext
|
|
||||||
if filereadable(fnamemodify(l:skel,":p"))
|
|
||||||
let s:doit=input("Perform auto insert (y/n)? ")
|
|
||||||
if s:doit == 'n' || s:doit == 'N'
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
execute "0r" l:skel
|
|
||||||
let s:syn=input("Synopsis: ")
|
|
||||||
if line("$") > 20
|
|
||||||
let l = 20
|
|
||||||
else
|
|
||||||
let l = line("$")
|
|
||||||
endif
|
|
||||||
execute "1," . l . "s/@@DESCR@@/" .
|
|
||||||
\ s:syn
|
|
||||||
execute "1," . l . "s/@@crdate@@/" .
|
|
||||||
\ strftime(s:timeFormat) . "/e"
|
|
||||||
execute "1," . l . "s/@@LONGNAME@@/" .
|
|
||||||
\ g:fullname . "/e"
|
|
||||||
execute "1," . l . "s/@@EMAIL@@/" .
|
|
||||||
\ g:email . "/e"
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
|
@ -1,94 +0,0 @@
|
||||||
" """"""""""""
|
|
||||||
" Status Line
|
|
||||||
" """"""""""""
|
|
||||||
" Some useful functions
|
|
||||||
"return the syntax highlight group under the cursor ''
|
|
||||||
function! StatuslineCurrentHighlight()
|
|
||||||
let name = synIDattr(synID(line('.'),col('.'),1),'name')
|
|
||||||
if name == ''
|
|
||||||
return ''
|
|
||||||
else
|
|
||||||
return '[' . name . ']'
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
"recalculate the tab warning flag when idle and after writing
|
|
||||||
autocmd cursorhold,bufwritepost * unlet! b:statusline_tab_warning
|
|
||||||
"
|
|
||||||
"return '[&et]' if &et is set wrong
|
|
||||||
"return '[mixed-indenting]' if spaces and tabs are used to indent
|
|
||||||
"return an empty string if everything is fine
|
|
||||||
function! StatuslineTabWarning()
|
|
||||||
if !exists("b:statusline_tab_warning")
|
|
||||||
let tabs = search('^\t', 'nw') != 0
|
|
||||||
let spaces = search('^ ', 'nw') != 0
|
|
||||||
|
|
||||||
if tabs && spaces
|
|
||||||
let b:statusline_tab_warning = '[mixed-indenting]'
|
|
||||||
elseif (spaces && !&et) || (tabs && &et)
|
|
||||||
let b:statusline_tab_warning = '[&et]'
|
|
||||||
else
|
|
||||||
let b:statusline_tab_warning = ''
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
return b:statusline_tab_warning
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
"recalculate the trailing whitespace warning when idle, and after saving
|
|
||||||
autocmd cursorhold,bufwritepost * unlet! b:statusline_trailing_space_warning
|
|
||||||
|
|
||||||
"return '[\s]' if trailing white space is detected
|
|
||||||
"return '' otherwise
|
|
||||||
function! StatuslineTrailingSpaceWarning()
|
|
||||||
if !exists("b:statusline_trailing_space_warning")
|
|
||||||
if search('\s\+$', 'nw') != 0
|
|
||||||
let b:statusline_trailing_space_warning = '[\s]'
|
|
||||||
else
|
|
||||||
let b:statusline_trailing_space_warning = ''
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
return b:statusline_trailing_space_warning
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
|
|
||||||
" Real Status line definition
|
|
||||||
set statusline=%t\ "tail of the filename
|
|
||||||
|
|
||||||
"display a warning if fileformat isnt unix
|
|
||||||
set statusline+=%#warningmsg#
|
|
||||||
set statusline+=%{&ff!='unix'?'['.&ff.']':''}
|
|
||||||
set statusline+=%*
|
|
||||||
|
|
||||||
"display a warning if file encoding isnt utf-8
|
|
||||||
set statusline+=%#warningmsg#
|
|
||||||
set statusline+=%{(&fenc!='utf-8'&&&fenc!='')?'['.&fenc.']':''}
|
|
||||||
set statusline+=%*
|
|
||||||
|
|
||||||
set statusline+=%h "help file flag
|
|
||||||
set statusline+=%y "filetype
|
|
||||||
set statusline+=%r "read only flag
|
|
||||||
set statusline+=%m "modified flag
|
|
||||||
|
|
||||||
"display a warning if &et is wrong, or we have mixed-indenting
|
|
||||||
set statusline+=%#error#
|
|
||||||
set statusline+=%{StatuslineTabWarning()}
|
|
||||||
set statusline+=%*
|
|
||||||
|
|
||||||
set statusline+=%{StatuslineTrailingSpaceWarning()}
|
|
||||||
|
|
||||||
"display a warning if &paste is set
|
|
||||||
set statusline+=%#error#
|
|
||||||
set statusline+=%{&paste?'[paste]':'[nopaste]'}
|
|
||||||
set statusline+=%*
|
|
||||||
|
|
||||||
" set statusline+=%=
|
|
||||||
|
|
||||||
set statusline+=%= "left/right separator
|
|
||||||
set statusline+=%{StatuslineCurrentHighlight()}\ \ "current highlight
|
|
||||||
set statusline+=\ tw%{&tw}\
|
|
||||||
set statusline+=%02c, "cursor column
|
|
||||||
set statusline+=%03l/%03L "cursor line/total lines
|
|
||||||
set statusline+=\ hex:\ 0x%02B
|
|
||||||
set statusline+=\ %P "percent through file
|
|
||||||
|
|
||||||
" vim: set ts=4 sw=4 tw=78 ft=vim :
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,66 +0,0 @@
|
||||||
" Text formatter plugin for Vim text editor
|
|
||||||
"
|
|
||||||
" Version: 2.1
|
|
||||||
" Last Change: 2008-09-13
|
|
||||||
" Maintainer: Teemu Likonen <tlikonen@iki.fi>
|
|
||||||
" License: This file is placed in the public domain.
|
|
||||||
" GetLatestVimScripts: 2324 1 :AutoInstall: TextFormat
|
|
||||||
|
|
||||||
"{{{1 The beginning stuff
|
|
||||||
if &compatible || exists('g:loaded_textformat')
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
let s:save_cpo = &cpo
|
|
||||||
set cpo&vim
|
|
||||||
"}}}1
|
|
||||||
|
|
||||||
if v:version < 700
|
|
||||||
echohl ErrorMsg
|
|
||||||
echomsg 'TextFormat plugin needs Vim version 7.0 or later. Sorry.'
|
|
||||||
echohl None
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists(':AlignLeft')
|
|
||||||
command -nargs=? -range AlignLeft <line1>,<line2>call textformat#Align_Command('left',<args>)
|
|
||||||
endif
|
|
||||||
if !exists(':AlignRight')
|
|
||||||
command -nargs=? -range AlignRight <line1>,<line2>call textformat#Align_Command('right',<args>)
|
|
||||||
endif
|
|
||||||
if !exists(':AlignJustify')
|
|
||||||
command -nargs=? -range AlignJustify <line1>,<line2>call textformat#Align_Command('justify',<args>)
|
|
||||||
endif
|
|
||||||
if !exists(':AlignCenter')
|
|
||||||
command -nargs=? -range AlignCenter <line1>,<line2>call textformat#Align_Command('center',<args>)
|
|
||||||
endif
|
|
||||||
|
|
||||||
nnoremap <silent> <Plug>Quick_Align_Paragraph_Left :call textformat#Quick_Align_Left()<CR>
|
|
||||||
nnoremap <silent> <Plug>Quick_Align_Paragraph_Right :call textformat#Quick_Align_Right()<CR>
|
|
||||||
nnoremap <silent> <Plug>Quick_Align_Paragraph_Justify :call textformat#Quick_Align_Justify()<CR>
|
|
||||||
nnoremap <silent> <Plug>Quick_Align_Paragraph_Center :call textformat#Quick_Align_Center()<CR>
|
|
||||||
|
|
||||||
vnoremap <silent> <Plug>Align_Range_Left :call textformat#Visual_Align_Left()<CR>
|
|
||||||
vnoremap <silent> <Plug>Align_Range_Right :call textformat#Visual_Align_Right()<CR>
|
|
||||||
vnoremap <silent> <Plug>Align_Range_Justify :call textformat#Visual_Align_Justify()<CR>
|
|
||||||
vnoremap <silent> <Plug>Align_Range_Center :call textformat#Visual_Align_Center()<CR>
|
|
||||||
|
|
||||||
function! s:Add_Mapping(mode, lhs, rhs)
|
|
||||||
if maparg(a:lhs, a:mode) == '' && !hasmapto(a:rhs, a:mode)
|
|
||||||
execute a:mode.'map '.a:lhs.' '.a:rhs
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
call s:Add_Mapping('n', '<Leader>al', '<Plug>Quick_Align_Paragraph_Left')
|
|
||||||
call s:Add_Mapping('n', '<Leader>ar', '<Plug>Quick_Align_Paragraph_Right')
|
|
||||||
call s:Add_Mapping('n', '<Leader>aj', '<Plug>Quick_Align_Paragraph_Justify')
|
|
||||||
call s:Add_Mapping('n', '<Leader>ac', '<Plug>Quick_Align_Paragraph_Center')
|
|
||||||
|
|
||||||
call s:Add_Mapping('v', '<Leader>al', '<Plug>Align_Range_Left')
|
|
||||||
call s:Add_Mapping('v', '<Leader>ar', '<Plug>Align_Range_Right')
|
|
||||||
call s:Add_Mapping('v', '<Leader>aj', '<Plug>Align_Range_Justify')
|
|
||||||
call s:Add_Mapping('v', '<Leader>ac', '<Plug>Align_Range_Center')
|
|
||||||
|
|
||||||
delfunction s:Add_Mapping
|
|
||||||
let g:loaded_textformat = 1
|
|
||||||
let &cpo = s:save_cpo
|
|
||||||
" vim600: fdm=marker
|
|
|
@ -1,264 +0,0 @@
|
||||||
" vim600: set foldmethod=marker:
|
|
||||||
"
|
|
||||||
" BZR extension for VCSCommand.
|
|
||||||
"
|
|
||||||
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
|
|
||||||
" License:
|
|
||||||
" Copyright (c) Bob Hiestand
|
|
||||||
"
|
|
||||||
" Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
" of this software and associated documentation files (the "Software"), to
|
|
||||||
" deal in the Software without restriction, including without limitation the
|
|
||||||
" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
||||||
" sell copies of the Software, and to permit persons to whom the Software is
|
|
||||||
" furnished to do so, subject to the following conditions:
|
|
||||||
"
|
|
||||||
" The above copyright notice and this permission notice shall be included in
|
|
||||||
" all copies or substantial portions of the Software.
|
|
||||||
"
|
|
||||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
||||||
" IN THE SOFTWARE.
|
|
||||||
"
|
|
||||||
" Section: Documentation {{{1
|
|
||||||
"
|
|
||||||
" Options documentation: {{{2
|
|
||||||
"
|
|
||||||
" VCSCommandBZRExec
|
|
||||||
" This variable specifies the BZR executable. If not set, it defaults to
|
|
||||||
" 'bzr' executed from the user's executable path.
|
|
||||||
|
|
||||||
" Section: Plugin header {{{1
|
|
||||||
|
|
||||||
if exists('VCSCommandDisableAll')
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
if v:version < 700
|
|
||||||
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists('g:loaded_VCSCommand')
|
|
||||||
runtime plugin/vcscommand.vim
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !executable(VCSCommandGetOption('VCSCommandBZRExec', 'bzr'))
|
|
||||||
" BZR is not installed
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
let s:save_cpo=&cpo
|
|
||||||
set cpo&vim
|
|
||||||
|
|
||||||
" Section: Variable initialization {{{1
|
|
||||||
|
|
||||||
let s:bzrFunctions = {}
|
|
||||||
|
|
||||||
" Section: Utility functions {{{1
|
|
||||||
|
|
||||||
" Function: s:Executable() {{{2
|
|
||||||
" Returns the executable used to invoke bzr suitable for use in a shell
|
|
||||||
" command.
|
|
||||||
function! s:Executable()
|
|
||||||
return shellescape(VCSCommandGetOption('VCSCommandBZRExec', 'bzr'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:DoCommand(cmd, cmdName, statusText) {{{2
|
|
||||||
" Wrapper to VCSCommandDoCommand to add the name of the BZR executable to the
|
|
||||||
" command argument.
|
|
||||||
function! s:DoCommand(cmd, cmdName, statusText, options)
|
|
||||||
if VCSCommandGetVCSType(expand('%')) == 'BZR'
|
|
||||||
let fullCmd = s:Executable() . ' ' . a:cmd
|
|
||||||
return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
|
|
||||||
else
|
|
||||||
throw 'BZR VCSCommand plugin called on non-BZR item.'
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Section: VCS function implementations {{{1
|
|
||||||
|
|
||||||
" Function: s:bzrFunctions.Identify(buffer) {{{2
|
|
||||||
function! s:bzrFunctions.Identify(buffer)
|
|
||||||
let fileName = resolve(bufname(a:buffer))
|
|
||||||
let l:save_bzr_log=$BZR_LOG
|
|
||||||
try
|
|
||||||
let $BZR_LOG=has("win32") || has("win95") || has("win64") || has("win16") ? "nul" : "/dev/null"
|
|
||||||
let statusText = s:VCSCommandUtility.system(s:Executable() . ' info -- "' . fileName . '"')
|
|
||||||
finally
|
|
||||||
let $BZR_LOG=l:save_bzr_log
|
|
||||||
endtry
|
|
||||||
if(v:shell_error)
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
return 1
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:bzrFunctions.Add() {{{2
|
|
||||||
function! s:bzrFunctions.Add(argList)
|
|
||||||
return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' '), {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:bzrFunctions.Annotate(argList) {{{2
|
|
||||||
function! s:bzrFunctions.Annotate(argList)
|
|
||||||
if len(a:argList) == 0
|
|
||||||
if &filetype ==? 'bzrannotate'
|
|
||||||
" Perform annotation of the version indicated by the current line.
|
|
||||||
let caption = matchstr(getline('.'),'\v^\s+\zs\d+')
|
|
||||||
let options = ' -r' . caption
|
|
||||||
else
|
|
||||||
let caption = ''
|
|
||||||
let options = ''
|
|
||||||
endif
|
|
||||||
elseif len(a:argList) == 1 && a:argList[0] !~ '^-'
|
|
||||||
let caption = a:argList[0]
|
|
||||||
let options = ' -r' . caption
|
|
||||||
else
|
|
||||||
let caption = join(a:argList, ' ')
|
|
||||||
let options = ' ' . caption
|
|
||||||
endif
|
|
||||||
|
|
||||||
let resultBuffer = s:DoCommand('blame' . options, 'annotate', caption, {})
|
|
||||||
if resultBuffer > 0
|
|
||||||
normal! 1G2dd
|
|
||||||
endif
|
|
||||||
return resultBuffer
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:bzrFunctions.Commit(argList) {{{2
|
|
||||||
function! s:bzrFunctions.Commit(argList)
|
|
||||||
let resultBuffer = s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '', {})
|
|
||||||
if resultBuffer == 0
|
|
||||||
echomsg 'No commit needed.'
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:bzrFunctions.Delete() {{{2
|
|
||||||
function! s:bzrFunctions.Delete(argList)
|
|
||||||
return s:DoCommand(join(['rm'] + a:argList, ' '), 'rm', join(a:argList, ' '), {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:bzrFunctions.Diff(argList) {{{2
|
|
||||||
function! s:bzrFunctions.Diff(argList)
|
|
||||||
if len(a:argList) == 0
|
|
||||||
let revOptions = []
|
|
||||||
let caption = ''
|
|
||||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
|
||||||
let revOptions = ['-r' . join(a:argList, '..')]
|
|
||||||
let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')'
|
|
||||||
else
|
|
||||||
" Pass-through
|
|
||||||
let caption = join(a:argList, ' ')
|
|
||||||
let revOptions = a:argList
|
|
||||||
endif
|
|
||||||
|
|
||||||
return s:DoCommand(join(['diff'] + revOptions), 'diff', caption, {'allowNonZeroExit': 1})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:bzrFunctions.GetBufferInfo() {{{2
|
|
||||||
" Provides version control details for the current file. Current version
|
|
||||||
" number and current repository version number are required to be returned by
|
|
||||||
" the vcscommand plugin.
|
|
||||||
" Returns: List of results: [revision, repository]
|
|
||||||
|
|
||||||
function! s:bzrFunctions.GetBufferInfo()
|
|
||||||
let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
|
|
||||||
let fileName = resolve(bufname(originalBuffer))
|
|
||||||
let statusText = s:VCSCommandUtility.system(s:Executable() . ' status -S -- "' . fileName . '"')
|
|
||||||
let revision = s:VCSCommandUtility.system(s:Executable() . ' revno -- "' . fileName . '"')
|
|
||||||
if(v:shell_error)
|
|
||||||
return []
|
|
||||||
endif
|
|
||||||
|
|
||||||
" File not under BZR control.
|
|
||||||
if statusText =~ '^?'
|
|
||||||
return ['Unknown']
|
|
||||||
endif
|
|
||||||
|
|
||||||
let [flags, repository] = matchlist(statusText, '^\(.\{3}\)\s\+\(\S\+\)')[1:2]
|
|
||||||
if revision == ''
|
|
||||||
" Error
|
|
||||||
return ['Unknown']
|
|
||||||
elseif flags =~ '^A'
|
|
||||||
return ['New', 'New']
|
|
||||||
else
|
|
||||||
return [revision, repository]
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:bzrFunctions.Info(argList) {{{2
|
|
||||||
function! s:bzrFunctions.Info(argList)
|
|
||||||
return s:DoCommand(join(['version-info'] + a:argList, ' '), 'version-info', join(a:argList, ' '), {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:bzrFunctions.Lock(argList) {{{2
|
|
||||||
function! s:bzrFunctions.Lock(argList)
|
|
||||||
echomsg 'bzr lock is not necessary'
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:bzrFunctions.Log() {{{2
|
|
||||||
function! s:bzrFunctions.Log(argList)
|
|
||||||
if len(a:argList) == 0
|
|
||||||
let options = []
|
|
||||||
let caption = ''
|
|
||||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
|
||||||
let options = ['-r' . join(a:argList, ':')]
|
|
||||||
let caption = options[0]
|
|
||||||
else
|
|
||||||
" Pass-through
|
|
||||||
let options = a:argList
|
|
||||||
let caption = join(a:argList, ' ')
|
|
||||||
endif
|
|
||||||
|
|
||||||
let resultBuffer = s:DoCommand(join(['log', '-v'] + options), 'log', caption, {})
|
|
||||||
return resultBuffer
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:bzrFunctions.Revert(argList) {{{2
|
|
||||||
function! s:bzrFunctions.Revert(argList)
|
|
||||||
return s:DoCommand('revert', 'revert', '', {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:bzrFunctions.Review(argList) {{{2
|
|
||||||
function! s:bzrFunctions.Review(argList)
|
|
||||||
if len(a:argList) == 0
|
|
||||||
let versiontag = '(current)'
|
|
||||||
let versionOption = ''
|
|
||||||
else
|
|
||||||
let versiontag = a:argList[0]
|
|
||||||
let versionOption = ' -r ' . versiontag . ' '
|
|
||||||
endif
|
|
||||||
|
|
||||||
return s:DoCommand('cat' . versionOption, 'review', versiontag, {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:bzrFunctions.Status(argList) {{{2
|
|
||||||
function! s:bzrFunctions.Status(argList)
|
|
||||||
let options = ['-S']
|
|
||||||
if len(a:argList) != 0
|
|
||||||
let options = a:argList
|
|
||||||
endif
|
|
||||||
return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '), {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:bzrFunctions.Unlock(argList) {{{2
|
|
||||||
function! s:bzrFunctions.Unlock(argList)
|
|
||||||
echomsg 'bzr unlock is not necessary'
|
|
||||||
endfunction
|
|
||||||
" Function: s:bzrFunctions.Update(argList) {{{2
|
|
||||||
function! s:bzrFunctions.Update(argList)
|
|
||||||
return s:DoCommand('update', 'update', '', {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Annotate setting {{{2
|
|
||||||
let s:bzrFunctions.AnnotateSplitRegex = '^[^|]\+ | '
|
|
||||||
|
|
||||||
" Section: Plugin Registration {{{1
|
|
||||||
let s:VCSCommandUtility = VCSCommandRegisterModule('BZR', expand('<sfile>'), s:bzrFunctions, [])
|
|
||||||
|
|
||||||
let &cpo = s:save_cpo
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,453 +0,0 @@
|
||||||
" vim600: set foldmethod=marker:
|
|
||||||
"
|
|
||||||
" CVS extension for VCSCommand.
|
|
||||||
"
|
|
||||||
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
|
|
||||||
" License:
|
|
||||||
" Copyright (c) Bob Hiestand
|
|
||||||
"
|
|
||||||
" Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
" of this software and associated documentation files (the "Software"), to
|
|
||||||
" deal in the Software without restriction, including without limitation the
|
|
||||||
" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
||||||
" sell copies of the Software, and to permit persons to whom the Software is
|
|
||||||
" furnished to do so, subject to the following conditions:
|
|
||||||
"
|
|
||||||
" The above copyright notice and this permission notice shall be included in
|
|
||||||
" all copies or substantial portions of the Software.
|
|
||||||
"
|
|
||||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
||||||
" IN THE SOFTWARE.
|
|
||||||
"
|
|
||||||
" Section: Documentation {{{1
|
|
||||||
"
|
|
||||||
" Command documentation {{{2
|
|
||||||
"
|
|
||||||
" The following commands only apply to files under CVS source control.
|
|
||||||
"
|
|
||||||
" CVSEdit Performs "cvs edit" on the current file.
|
|
||||||
"
|
|
||||||
" CVSEditors Performs "cvs editors" on the current file.
|
|
||||||
"
|
|
||||||
" CVSUnedit Performs "cvs unedit" on the current file.
|
|
||||||
"
|
|
||||||
" CVSWatch Takes an argument which must be one of [on|off|add|remove].
|
|
||||||
" Performs "cvs watch" with the given argument on the current
|
|
||||||
" file.
|
|
||||||
"
|
|
||||||
" CVSWatchers Performs "cvs watchers" on the current file.
|
|
||||||
"
|
|
||||||
" CVSWatchAdd Alias for "CVSWatch add"
|
|
||||||
"
|
|
||||||
" CVSWatchOn Alias for "CVSWatch on"
|
|
||||||
"
|
|
||||||
" CVSWatchOff Alias for "CVSWatch off"
|
|
||||||
"
|
|
||||||
" CVSWatchRemove Alias for "CVSWatch remove"
|
|
||||||
"
|
|
||||||
" Mapping documentation: {{{2
|
|
||||||
"
|
|
||||||
" By default, a mapping is defined for each command. User-provided mappings
|
|
||||||
" can be used instead by mapping to <Plug>CommandName, for instance:
|
|
||||||
"
|
|
||||||
" nnoremap ,ce <Plug>CVSEdit
|
|
||||||
"
|
|
||||||
" The default mappings are as follow:
|
|
||||||
"
|
|
||||||
" <Leader>ce CVSEdit
|
|
||||||
" <Leader>cE CVSEditors
|
|
||||||
" <Leader>ct CVSUnedit
|
|
||||||
" <Leader>cwv CVSWatchers
|
|
||||||
" <Leader>cwa CVSWatchAdd
|
|
||||||
" <Leader>cwn CVSWatchOn
|
|
||||||
" <Leader>cwf CVSWatchOff
|
|
||||||
" <Leader>cwr CVSWatchRemove
|
|
||||||
"
|
|
||||||
" Options documentation: {{{2
|
|
||||||
"
|
|
||||||
" VCSCommandCVSExec
|
|
||||||
" This variable specifies the CVS executable. If not set, it defaults to
|
|
||||||
" 'cvs' executed from the user's executable path.
|
|
||||||
"
|
|
||||||
" VCSCommandCVSDiffOpt
|
|
||||||
" This variable, if set, determines the options passed to the cvs diff
|
|
||||||
" command. If not set, it defaults to 'u'.
|
|
||||||
|
|
||||||
" Section: Plugin header {{{1
|
|
||||||
|
|
||||||
if exists('VCSCommandDisableAll')
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
if v:version < 700
|
|
||||||
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists('g:loaded_VCSCommand')
|
|
||||||
runtime plugin/vcscommand.vim
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !executable(VCSCommandGetOption('VCSCommandCVSExec', 'cvs'))
|
|
||||||
" CVS is not installed
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
let s:save_cpo=&cpo
|
|
||||||
set cpo&vim
|
|
||||||
|
|
||||||
" Section: Variable initialization {{{1
|
|
||||||
|
|
||||||
let s:cvsFunctions = {}
|
|
||||||
|
|
||||||
" Section: Utility functions {{{1
|
|
||||||
|
|
||||||
" Function: s:Executable() {{{2
|
|
||||||
" Returns the executable used to invoke cvs suitable for use in a shell
|
|
||||||
" command.
|
|
||||||
function! s:Executable()
|
|
||||||
return shellescape(VCSCommandGetOption('VCSCommandCVSExec', 'cvs'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
|
|
||||||
" Wrapper to VCSCommandDoCommand to add the name of the CVS executable to the
|
|
||||||
" command argument.
|
|
||||||
function! s:DoCommand(cmd, cmdName, statusText, options)
|
|
||||||
if VCSCommandGetVCSType(expand('%')) == 'CVS'
|
|
||||||
let fullCmd = s:Executable() . ' ' . a:cmd
|
|
||||||
let ret = VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
|
|
||||||
|
|
||||||
if ret > 0
|
|
||||||
if getline(line('$')) =~ '^cvs \w\+: closing down connection'
|
|
||||||
$d
|
|
||||||
1
|
|
||||||
endif
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
return ret
|
|
||||||
else
|
|
||||||
throw 'CVS VCSCommand plugin called on non-CVS item.'
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:GetRevision() {{{2
|
|
||||||
" Function for retrieving the current buffer's revision number.
|
|
||||||
" Returns: Revision number or an empty string if an error occurs.
|
|
||||||
|
|
||||||
function! s:GetRevision()
|
|
||||||
if !exists('b:VCSCommandBufferInfo')
|
|
||||||
let b:VCSCommandBufferInfo = s:cvsFunctions.GetBufferInfo()
|
|
||||||
endif
|
|
||||||
|
|
||||||
if len(b:VCSCommandBufferInfo) > 0
|
|
||||||
return b:VCSCommandBufferInfo[0]
|
|
||||||
else
|
|
||||||
return ''
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Section: VCS function implementations {{{1
|
|
||||||
|
|
||||||
" Function: s:cvsFunctions.Identify(buffer) {{{2
|
|
||||||
function! s:cvsFunctions.Identify(buffer)
|
|
||||||
let fileName = resolve(bufname(a:buffer))
|
|
||||||
if isdirectory(fileName)
|
|
||||||
let directoryName = fileName
|
|
||||||
else
|
|
||||||
let directoryName = fnamemodify(fileName, ':h')
|
|
||||||
endif
|
|
||||||
if strlen(directoryName) > 0
|
|
||||||
let CVSRoot = directoryName . '/CVS/Root'
|
|
||||||
else
|
|
||||||
let CVSRoot = 'CVS/Root'
|
|
||||||
endif
|
|
||||||
if filereadable(CVSRoot)
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
return 0
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:cvsFunctions.Add(argList) {{{2
|
|
||||||
function! s:cvsFunctions.Add(argList)
|
|
||||||
return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' '), {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:cvsFunctions.Annotate(argList) {{{2
|
|
||||||
function! s:cvsFunctions.Annotate(argList)
|
|
||||||
if len(a:argList) == 0
|
|
||||||
if &filetype ==? 'cvsannotate'
|
|
||||||
" This is a CVSAnnotate buffer. Perform annotation of the version
|
|
||||||
" indicated by the current line.
|
|
||||||
let caption = matchstr(getline('.'),'\v^[0-9.]+')
|
|
||||||
|
|
||||||
if VCSCommandGetOption('VCSCommandCVSAnnotateParent', 0) != 0
|
|
||||||
if caption != '1.1'
|
|
||||||
let revmaj = matchstr(caption,'\v[0-9.]+\ze\.[0-9]+')
|
|
||||||
let revmin = matchstr(caption,'\v[0-9.]+\.\zs[0-9]+') - 1
|
|
||||||
if revmin == 0
|
|
||||||
" Jump to ancestor branch
|
|
||||||
let caption = matchstr(revmaj,'\v[0-9.]+\ze\.[0-9]+')
|
|
||||||
else
|
|
||||||
let caption = revmaj . "." . revmin
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
let options = ['-r' . caption]
|
|
||||||
else
|
|
||||||
" CVS defaults to pulling HEAD, regardless of current branch.
|
|
||||||
" Therefore, always pass desired revision.
|
|
||||||
let caption = ''
|
|
||||||
let options = ['-r' . s:GetRevision()]
|
|
||||||
endif
|
|
||||||
elseif len(a:argList) == 1 && a:argList[0] !~ '^-'
|
|
||||||
let caption = a:argList[0]
|
|
||||||
let options = ['-r' . caption]
|
|
||||||
else
|
|
||||||
let caption = join(a:argList)
|
|
||||||
let options = a:argList
|
|
||||||
endif
|
|
||||||
|
|
||||||
let resultBuffer = s:DoCommand(join(['-q', 'annotate'] + options), 'annotate', caption, {})
|
|
||||||
if resultBuffer > 0
|
|
||||||
" Remove header lines from standard error
|
|
||||||
silent v/^\d\+\%(\.\d\+\)\+/d
|
|
||||||
endif
|
|
||||||
return resultBuffer
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:cvsFunctions.Commit(argList) {{{2
|
|
||||||
function! s:cvsFunctions.Commit(argList)
|
|
||||||
let resultBuffer = s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '', {})
|
|
||||||
if resultBuffer == 0
|
|
||||||
echomsg 'No commit needed.'
|
|
||||||
endif
|
|
||||||
return resultBuffer
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:cvsFunctions.Delete() {{{2
|
|
||||||
" By default, use the -f option to remove the file first. If options are
|
|
||||||
" passed in, use those instead.
|
|
||||||
function! s:cvsFunctions.Delete(argList)
|
|
||||||
let options = ['-f']
|
|
||||||
let caption = ''
|
|
||||||
if len(a:argList) > 0
|
|
||||||
let options = a:argList
|
|
||||||
let caption = join(a:argList, ' ')
|
|
||||||
endif
|
|
||||||
return s:DoCommand(join(['remove'] + options, ' '), 'delete', caption, {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:cvsFunctions.Diff(argList) {{{2
|
|
||||||
function! s:cvsFunctions.Diff(argList)
|
|
||||||
if len(a:argList) == 0
|
|
||||||
let revOptions = []
|
|
||||||
let caption = ''
|
|
||||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
|
||||||
let revOptions = ['-r' . join(a:argList, ' -r')]
|
|
||||||
let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')'
|
|
||||||
else
|
|
||||||
" Pass-through
|
|
||||||
let caption = join(a:argList, ' ')
|
|
||||||
let revOptions = a:argList
|
|
||||||
endif
|
|
||||||
|
|
||||||
let cvsDiffOpt = VCSCommandGetOption('VCSCommandCVSDiffOpt', 'u')
|
|
||||||
if cvsDiffOpt == ''
|
|
||||||
let diffOptions = []
|
|
||||||
else
|
|
||||||
let diffOptions = ['-' . cvsDiffOpt]
|
|
||||||
endif
|
|
||||||
|
|
||||||
return s:DoCommand(join(['diff'] + diffOptions + revOptions), 'diff', caption, {'allowNonZeroExit': 1})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:cvsFunctions.GetBufferInfo() {{{2
|
|
||||||
" Provides version control details for the current file. Current version
|
|
||||||
" number and current repository version number are required to be returned by
|
|
||||||
" the vcscommand plugin. This CVS extension adds branch name to the return
|
|
||||||
" list as well.
|
|
||||||
" Returns: List of results: [revision, repository, branch]
|
|
||||||
|
|
||||||
function! s:cvsFunctions.GetBufferInfo()
|
|
||||||
let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
|
|
||||||
let fileName = bufname(originalBuffer)
|
|
||||||
if isdirectory(fileName)
|
|
||||||
let tag = ''
|
|
||||||
if filereadable(fileName . '/CVS/Tag')
|
|
||||||
let tagFile = readfile(fileName . '/CVS/Tag')
|
|
||||||
if len(tagFile) == 1
|
|
||||||
let tag = substitute(tagFile[0], '^T', '', '')
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
return [tag]
|
|
||||||
endif
|
|
||||||
let realFileName = fnamemodify(resolve(fileName), ':t')
|
|
||||||
if !filereadable(fileName)
|
|
||||||
return ['Unknown']
|
|
||||||
endif
|
|
||||||
let oldCwd = VCSCommandChangeToCurrentFileDir(fileName)
|
|
||||||
try
|
|
||||||
let statusText=s:VCSCommandUtility.system(s:Executable() . ' status -- "' . realFileName . '"')
|
|
||||||
if(v:shell_error)
|
|
||||||
return []
|
|
||||||
endif
|
|
||||||
let revision=substitute(statusText, '^\_.*Working revision:\s*\(\d\+\%(\.\d\+\)\+\|New file!\)\_.*$', '\1', '')
|
|
||||||
|
|
||||||
" We can still be in a CVS-controlled directory without this being a CVS
|
|
||||||
" file
|
|
||||||
if match(revision, '^New file!$') >= 0
|
|
||||||
let revision='New'
|
|
||||||
elseif match(revision, '^\d\+\.\d\+\%(\.\d\+\.\d\+\)*$') <0
|
|
||||||
return ['Unknown']
|
|
||||||
endif
|
|
||||||
|
|
||||||
let branch=substitute(statusText, '^\_.*Sticky Tag:\s\+\(\d\+\%(\.\d\+\)\+\|\a[A-Za-z0-9-_]*\|(none)\).*$', '\1', '')
|
|
||||||
let repository=substitute(statusText, '^\_.*Repository revision:\s*\(\d\+\%(\.\d\+\)\+\|New file!\|No revision control file\)\_.*$', '\1', '')
|
|
||||||
let repository=substitute(repository, '^New file!\|No revision control file$', 'New', '')
|
|
||||||
return [revision, repository, branch]
|
|
||||||
finally
|
|
||||||
call VCSCommandChdir(oldCwd)
|
|
||||||
endtry
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:cvsFunctions.Log() {{{2
|
|
||||||
function! s:cvsFunctions.Log(argList)
|
|
||||||
if len(a:argList) == 0
|
|
||||||
let options = []
|
|
||||||
let caption = ''
|
|
||||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
|
||||||
let options = ['-r' . join(a:argList, ':')]
|
|
||||||
let caption = options[0]
|
|
||||||
else
|
|
||||||
" Pass-through
|
|
||||||
let options = a:argList
|
|
||||||
let caption = join(a:argList, ' ')
|
|
||||||
endif
|
|
||||||
|
|
||||||
return s:DoCommand(join(['log'] + options), 'log', caption, {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:cvsFunctions.Revert(argList) {{{2
|
|
||||||
function! s:cvsFunctions.Revert(argList)
|
|
||||||
return s:DoCommand('update -C', 'revert', '', {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:cvsFunctions.Review(argList) {{{2
|
|
||||||
function! s:cvsFunctions.Review(argList)
|
|
||||||
if len(a:argList) == 0
|
|
||||||
let versiontag = '(current)'
|
|
||||||
let versionOption = ''
|
|
||||||
else
|
|
||||||
let versiontag = a:argList[0]
|
|
||||||
let versionOption = ' -r ' . versiontag . ' '
|
|
||||||
endif
|
|
||||||
|
|
||||||
return s:DoCommand('-q update -p' . versionOption, 'review', versiontag, {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:cvsFunctions.Status(argList) {{{2
|
|
||||||
function! s:cvsFunctions.Status(argList)
|
|
||||||
return s:DoCommand(join(['status'] + a:argList, ' '), 'status', join(a:argList, ' '), {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:cvsFunctions.Update(argList) {{{2
|
|
||||||
function! s:cvsFunctions.Update(argList)
|
|
||||||
return s:DoCommand('update', 'update', '', {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Section: CVS-specific functions {{{1
|
|
||||||
|
|
||||||
" Function: s:CVSEdit() {{{2
|
|
||||||
function! s:CVSEdit()
|
|
||||||
return s:DoCommand('edit', 'cvsedit', '', {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:CVSEditors() {{{2
|
|
||||||
function! s:CVSEditors()
|
|
||||||
return s:DoCommand('editors', 'cvseditors', '', {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:CVSUnedit() {{{2
|
|
||||||
function! s:CVSUnedit()
|
|
||||||
return s:DoCommand('unedit', 'cvsunedit', '', {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:CVSWatch(onoff) {{{2
|
|
||||||
function! s:CVSWatch(onoff)
|
|
||||||
if a:onoff !~ '^\c\%(on\|off\|add\|remove\)$'
|
|
||||||
echoerr 'Argument to CVSWatch must be one of [on|off|add|remove]'
|
|
||||||
return -1
|
|
||||||
end
|
|
||||||
return s:DoCommand('watch ' . tolower(a:onoff), 'cvswatch', '', {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:CVSWatchers() {{{2
|
|
||||||
function! s:CVSWatchers()
|
|
||||||
return s:DoCommand('watchers', 'cvswatchers', '', {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Annotate setting {{{2
|
|
||||||
let s:cvsFunctions.AnnotateSplitRegex = '): '
|
|
||||||
|
|
||||||
" Section: Command definitions {{{1
|
|
||||||
" Section: Primary commands {{{2
|
|
||||||
com! CVSEdit call s:CVSEdit()
|
|
||||||
com! CVSEditors call s:CVSEditors()
|
|
||||||
com! CVSUnedit call s:CVSUnedit()
|
|
||||||
com! -nargs=1 CVSWatch call s:CVSWatch(<f-args>)
|
|
||||||
com! CVSWatchAdd call s:CVSWatch('add')
|
|
||||||
com! CVSWatchOn call s:CVSWatch('on')
|
|
||||||
com! CVSWatchOff call s:CVSWatch('off')
|
|
||||||
com! CVSWatchRemove call s:CVSWatch('remove')
|
|
||||||
com! CVSWatchers call s:CVSWatchers()
|
|
||||||
|
|
||||||
" Section: Plugin command mappings {{{1
|
|
||||||
|
|
||||||
let s:cvsExtensionMappings = {}
|
|
||||||
if !exists("no_plugin_maps")
|
|
||||||
let mappingInfo = [
|
|
||||||
\['CVSEdit', 'CVSEdit', 'e'],
|
|
||||||
\['CVSEditors', 'CVSEditors', 'E'],
|
|
||||||
\['CVSUnedit', 'CVSUnedit', 't'],
|
|
||||||
\['CVSWatchers', 'CVSWatchers', 'wv'],
|
|
||||||
\['CVSWatchAdd', 'CVSWatch add', 'wa'],
|
|
||||||
\['CVSWatchOff', 'CVSWatch off', 'wf'],
|
|
||||||
\['CVSWatchOn', 'CVSWatch on', 'wn'],
|
|
||||||
\['CVSWatchRemove', 'CVSWatch remove', 'wr']
|
|
||||||
\]
|
|
||||||
|
|
||||||
for [pluginName, commandText, shortCut] in mappingInfo
|
|
||||||
execute 'nnoremap <silent> <Plug>' . pluginName . ' :' . commandText . '<CR>'
|
|
||||||
if !hasmapto('<Plug>' . pluginName)
|
|
||||||
let s:cvsExtensionMappings[shortCut] = commandText
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Section: Plugin Registration {{{1
|
|
||||||
let s:VCSCommandUtility = VCSCommandRegisterModule('CVS', expand('<sfile>'), s:cvsFunctions, s:cvsExtensionMappings)
|
|
||||||
|
|
||||||
" Section: Menu items {{{1
|
|
||||||
for [s:shortcut, s:command] in [
|
|
||||||
\['CVS.&Edit', '<Plug>CVSEdit'],
|
|
||||||
\['CVS.Ed&itors', '<Plug>CVSEditors'],
|
|
||||||
\['CVS.Unedi&t', '<Plug>CVSUnedit'],
|
|
||||||
\['CVS.&Watchers', '<Plug>CVSWatchers'],
|
|
||||||
\['CVS.WatchAdd', '<Plug>CVSWatchAdd'],
|
|
||||||
\['CVS.WatchOn', '<Plug>CVSWatchOn'],
|
|
||||||
\['CVS.WatchOff', '<Plug>CVSWatchOff'],
|
|
||||||
\['CVS.WatchRemove', '<Plug>CVSWatchRemove']
|
|
||||||
\]
|
|
||||||
call s:VCSCommandUtility.addMenuItem(s:shortcut, s:command)
|
|
||||||
endfor
|
|
||||||
unlet s:shortcut s:command
|
|
||||||
|
|
||||||
let &cpo = s:save_cpo
|
|
|
@ -1,249 +0,0 @@
|
||||||
" vim600: set foldmethod=marker:
|
|
||||||
"
|
|
||||||
" git extension for VCSCommand.
|
|
||||||
"
|
|
||||||
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
|
|
||||||
" License:
|
|
||||||
" Copyright (c) Bob Hiestand
|
|
||||||
"
|
|
||||||
" Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
" of this software and associated documentation files (the "Software"), to
|
|
||||||
" deal in the Software without restriction, including without limitation the
|
|
||||||
" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
||||||
" sell copies of the Software, and to permit persons to whom the Software is
|
|
||||||
" furnished to do so, subject to the following conditions:
|
|
||||||
"
|
|
||||||
" The above copyright notice and this permission notice shall be included in
|
|
||||||
" all copies or substantial portions of the Software.
|
|
||||||
"
|
|
||||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
||||||
" IN THE SOFTWARE.
|
|
||||||
"
|
|
||||||
" Section: Documentation {{{1
|
|
||||||
"
|
|
||||||
" Options documentation: {{{2
|
|
||||||
"
|
|
||||||
" VCSCommandGitExec
|
|
||||||
" This variable specifies the git executable. If not set, it defaults to
|
|
||||||
" 'git' executed from the user's executable path.
|
|
||||||
"
|
|
||||||
" VCSCommandGitDiffOpt
|
|
||||||
" This variable, if set, determines the default options passed to the
|
|
||||||
" VCSDiff command. If any options (starting with '-') are passed to the
|
|
||||||
" command, this variable is not used.
|
|
||||||
|
|
||||||
" Section: Plugin header {{{1
|
|
||||||
|
|
||||||
if exists('VCSCommandDisableAll')
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
if v:version < 700
|
|
||||||
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists('g:loaded_VCSCommand')
|
|
||||||
runtime plugin/vcscommand.vim
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !executable(VCSCommandGetOption('VCSCommandGitExec', 'git'))
|
|
||||||
" git is not installed
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
let s:save_cpo=&cpo
|
|
||||||
set cpo&vim
|
|
||||||
|
|
||||||
" Section: Variable initialization {{{1
|
|
||||||
|
|
||||||
let s:gitFunctions = {}
|
|
||||||
|
|
||||||
" Section: Utility functions {{{1
|
|
||||||
|
|
||||||
" Function: s:Executable() {{{2
|
|
||||||
" Returns the executable used to invoke git suitable for use in a shell
|
|
||||||
" command.
|
|
||||||
function! s:Executable()
|
|
||||||
return shellescape(VCSCommandGetOption('VCSCommandGitExec', 'git'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
|
|
||||||
" Wrapper to VCSCommandDoCommand to add the name of the git executable to the
|
|
||||||
" command argument.
|
|
||||||
function! s:DoCommand(cmd, cmdName, statusText, options)
|
|
||||||
if VCSCommandGetVCSType(expand('%')) == 'git'
|
|
||||||
let fullCmd = s:Executable() . ' ' . a:cmd
|
|
||||||
return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
|
|
||||||
else
|
|
||||||
throw 'git VCSCommand plugin called on non-git item.'
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Section: VCS function implementations {{{1
|
|
||||||
|
|
||||||
" Function: s:gitFunctions.Identify(buffer) {{{2
|
|
||||||
" This function only returns an inexact match due to the detection method used
|
|
||||||
" by git, which simply traverses the directory structure upward.
|
|
||||||
function! s:gitFunctions.Identify(buffer)
|
|
||||||
let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname(a:buffer)))
|
|
||||||
try
|
|
||||||
call s:VCSCommandUtility.system(s:Executable() . ' rev-parse --is-inside-work-tree')
|
|
||||||
if(v:shell_error)
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
return g:VCSCOMMAND_IDENTIFY_INEXACT
|
|
||||||
endif
|
|
||||||
finally
|
|
||||||
call VCSCommandChdir(oldCwd)
|
|
||||||
endtry
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:gitFunctions.Add(argList) {{{2
|
|
||||||
function! s:gitFunctions.Add(argList)
|
|
||||||
return s:DoCommand(join(['add'] + ['-v'] + a:argList, ' '), 'add', join(a:argList, ' '), {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:gitFunctions.Annotate(argList) {{{2
|
|
||||||
function! s:gitFunctions.Annotate(argList)
|
|
||||||
if len(a:argList) == 0
|
|
||||||
if &filetype == 'gitannotate'
|
|
||||||
" Perform annotation of the version indicated by the current line.
|
|
||||||
let options = matchstr(getline('.'),'^\x\+')
|
|
||||||
else
|
|
||||||
let options = ''
|
|
||||||
endif
|
|
||||||
elseif len(a:argList) == 1 && a:argList[0] !~ '^-'
|
|
||||||
let options = a:argList[0]
|
|
||||||
else
|
|
||||||
let options = join(a:argList, ' ')
|
|
||||||
endif
|
|
||||||
|
|
||||||
return s:DoCommand('blame ' . options, 'annotate', options, {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:gitFunctions.Commit(argList) {{{2
|
|
||||||
function! s:gitFunctions.Commit(argList)
|
|
||||||
try
|
|
||||||
return s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '', {})
|
|
||||||
catch /\m^Version control command failed.*nothing\%( added\)\? to commit/
|
|
||||||
echomsg 'No commit needed.'
|
|
||||||
endtry
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:gitFunctions.Delete() {{{2
|
|
||||||
" All options are passed through.
|
|
||||||
function! s:gitFunctions.Delete(argList)
|
|
||||||
let options = a:argList
|
|
||||||
let caption = join(a:argList, ' ')
|
|
||||||
return s:DoCommand(join(['rm'] + options, ' '), 'delete', caption, {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:gitFunctions.Diff(argList) {{{2
|
|
||||||
" Pass-through call to git-diff. If no options (starting with '-') are found,
|
|
||||||
" then the options in the 'VCSCommandGitDiffOpt' variable are added.
|
|
||||||
function! s:gitFunctions.Diff(argList)
|
|
||||||
let gitDiffOpt = VCSCommandGetOption('VCSCommandGitDiffOpt', '')
|
|
||||||
if gitDiffOpt == ''
|
|
||||||
let diffOptions = []
|
|
||||||
else
|
|
||||||
let diffOptions = [gitDiffOpt]
|
|
||||||
for arg in a:argList
|
|
||||||
if arg =~ '^-'
|
|
||||||
let diffOptions = []
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
|
|
||||||
return s:DoCommand(join(['diff'] + diffOptions + a:argList), 'diff', join(a:argList), {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:gitFunctions.GetBufferInfo() {{{2
|
|
||||||
" Provides version control details for the current file. Current version
|
|
||||||
" number and current repository version number are required to be returned by
|
|
||||||
" the vcscommand plugin. This CVS extension adds branch name to the return
|
|
||||||
" list as well.
|
|
||||||
" Returns: List of results: [revision, repository, branch]
|
|
||||||
|
|
||||||
function! s:gitFunctions.GetBufferInfo()
|
|
||||||
let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname('%')))
|
|
||||||
try
|
|
||||||
let branch = substitute(s:VCSCommandUtility.system(s:Executable() . ' symbolic-ref -q HEAD'), '\n$', '', '')
|
|
||||||
if v:shell_error
|
|
||||||
let branch = 'DETACHED'
|
|
||||||
else
|
|
||||||
let branch = substitute(branch, '^refs/heads/', '', '')
|
|
||||||
endif
|
|
||||||
|
|
||||||
let info = [branch]
|
|
||||||
|
|
||||||
for method in split(VCSCommandGetOption('VCSCommandGitDescribeArgList', (',tags,all,always')), ',', 1)
|
|
||||||
if method != ''
|
|
||||||
let method = ' --' . method
|
|
||||||
endif
|
|
||||||
let tag = substitute(s:VCSCommandUtility.system(s:Executable() . ' describe' . method), '\n$', '', '')
|
|
||||||
if !v:shell_error
|
|
||||||
call add(info, tag)
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
|
|
||||||
return info
|
|
||||||
finally
|
|
||||||
call VCSCommandChdir(oldCwd)
|
|
||||||
endtry
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:gitFunctions.Log() {{{2
|
|
||||||
function! s:gitFunctions.Log(argList)
|
|
||||||
return s:DoCommand(join(['log'] + a:argList), 'log', join(a:argList, ' '), {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:gitFunctions.Revert(argList) {{{2
|
|
||||||
function! s:gitFunctions.Revert(argList)
|
|
||||||
return s:DoCommand('checkout', 'revert', '', {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:gitFunctions.Review(argList) {{{2
|
|
||||||
function! s:gitFunctions.Review(argList)
|
|
||||||
if len(a:argList) == 0
|
|
||||||
let revision = 'HEAD'
|
|
||||||
else
|
|
||||||
let revision = a:argList[0]
|
|
||||||
endif
|
|
||||||
|
|
||||||
let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname(VCSCommandGetOriginalBuffer('%'))))
|
|
||||||
try
|
|
||||||
let prefix = s:VCSCommandUtility.system(s:Executable() . ' rev-parse --show-prefix')
|
|
||||||
finally
|
|
||||||
call VCSCommandChdir(oldCwd)
|
|
||||||
endtry
|
|
||||||
|
|
||||||
let prefix = substitute(prefix, '\n$', '', '')
|
|
||||||
let blob = '"' . revision . ':' . prefix . '<VCSCOMMANDFILE>"'
|
|
||||||
return s:DoCommand('show ' . blob, 'review', revision, {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:gitFunctions.Status(argList) {{{2
|
|
||||||
function! s:gitFunctions.Status(argList)
|
|
||||||
return s:DoCommand(join(['status'] + a:argList), 'status', join(a:argList), {'allowNonZeroExit': 1})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:gitFunctions.Update(argList) {{{2
|
|
||||||
function! s:gitFunctions.Update(argList)
|
|
||||||
throw "This command is not implemented for git because file-by-file update doesn't make much sense in that context. If you have an idea for what it should do, please let me know."
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Annotate setting {{{2
|
|
||||||
let s:gitFunctions.AnnotateSplitRegex = ') '
|
|
||||||
|
|
||||||
" Section: Plugin Registration {{{1
|
|
||||||
let s:VCSCommandUtility = VCSCommandRegisterModule('git', expand('<sfile>'), s:gitFunctions, [])
|
|
||||||
|
|
||||||
let &cpo = s:save_cpo
|
|
|
@ -1,275 +0,0 @@
|
||||||
" vim600: set foldmethod=marker:
|
|
||||||
"
|
|
||||||
" Mercurial extension for VCSCommand.
|
|
||||||
"
|
|
||||||
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
|
|
||||||
" License:
|
|
||||||
" Copyright (c) Bob Hiestand
|
|
||||||
"
|
|
||||||
" Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
" of this software and associated documentation files (the "Software"), to
|
|
||||||
" deal in the Software without restriction, including without limitation the
|
|
||||||
" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
||||||
" sell copies of the Software, and to permit persons to whom the Software is
|
|
||||||
" furnished to do so, subject to the following conditions:
|
|
||||||
"
|
|
||||||
" The above copyright notice and this permission notice shall be included in
|
|
||||||
" all copies or substantial portions of the Software.
|
|
||||||
"
|
|
||||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
||||||
" IN THE SOFTWARE.
|
|
||||||
"
|
|
||||||
" Section: Documentation {{{1
|
|
||||||
"
|
|
||||||
" Options documentation: {{{2
|
|
||||||
"
|
|
||||||
" VCSCommandHGExec
|
|
||||||
" This variable specifies the mercurial executable. If not set, it defaults
|
|
||||||
" to 'hg' executed from the user's executable path.
|
|
||||||
"
|
|
||||||
" VCSCommandHGDiffExt
|
|
||||||
" This variable, if set, sets the external diff program used by Subversion.
|
|
||||||
"
|
|
||||||
" VCSCommandHGDiffOpt
|
|
||||||
" This variable, if set, determines the options passed to the hg diff
|
|
||||||
" command (such as 'u', 'w', or 'b').
|
|
||||||
|
|
||||||
" Section: Plugin header {{{1
|
|
||||||
|
|
||||||
if exists('VCSCommandDisableAll')
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
if v:version < 700
|
|
||||||
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists('g:loaded_VCSCommand')
|
|
||||||
runtime plugin/vcscommand.vim
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !executable(VCSCommandGetOption('VCSCommandHGExec', 'hg'))
|
|
||||||
" HG is not installed
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
let s:save_cpo=&cpo
|
|
||||||
set cpo&vim
|
|
||||||
|
|
||||||
" Section: Variable initialization {{{1
|
|
||||||
|
|
||||||
let s:hgFunctions = {}
|
|
||||||
|
|
||||||
" Section: Utility functions {{{1
|
|
||||||
|
|
||||||
" Function: s:Executable() {{{2
|
|
||||||
" Returns the executable used to invoke hg suitable for use in a shell
|
|
||||||
" command.
|
|
||||||
function! s:Executable()
|
|
||||||
return shellescape(VCSCommandGetOption('VCSCommandHGExec', 'hg'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
|
|
||||||
" Wrapper to VCSCommandDoCommand to add the name of the HG executable to the
|
|
||||||
" command argument.
|
|
||||||
function! s:DoCommand(cmd, cmdName, statusText, options)
|
|
||||||
if VCSCommandGetVCSType(expand('%')) == 'HG'
|
|
||||||
let fullCmd = s:Executable() . ' ' . a:cmd
|
|
||||||
return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
|
|
||||||
else
|
|
||||||
throw 'HG VCSCommand plugin called on non-HG item.'
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Section: VCS function implementations {{{1
|
|
||||||
|
|
||||||
" Function: s:hgFunctions.Identify(buffer) {{{2
|
|
||||||
function! s:hgFunctions.Identify(buffer)
|
|
||||||
let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname(a:buffer)))
|
|
||||||
try
|
|
||||||
call s:VCSCommandUtility.system(s:Executable() . ' root')
|
|
||||||
if(v:shell_error)
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
return g:VCSCOMMAND_IDENTIFY_INEXACT
|
|
||||||
endif
|
|
||||||
finally
|
|
||||||
call VCSCommandChdir(oldCwd)
|
|
||||||
endtry
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:hgFunctions.Add() {{{2
|
|
||||||
function! s:hgFunctions.Add(argList)
|
|
||||||
return s:DoCommand(join(['add -v'] + a:argList, ' '), 'add', join(a:argList, ' '), {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:hgFunctions.Annotate(argList) {{{2
|
|
||||||
function! s:hgFunctions.Annotate(argList)
|
|
||||||
if len(a:argList) == 0
|
|
||||||
if &filetype ==? 'hgannotate'
|
|
||||||
" Perform annotation of the version indicated by the current line.
|
|
||||||
let caption = matchstr(getline('.'),'\v^\s*\w+\s+\zs\d+')
|
|
||||||
let options = ' -un -r' . caption
|
|
||||||
else
|
|
||||||
let caption = ''
|
|
||||||
let options = ' -un'
|
|
||||||
endif
|
|
||||||
elseif len(a:argList) == 1 && a:argList[0] !~ '^-'
|
|
||||||
let caption = a:argList[0]
|
|
||||||
let options = ' -un -r' . caption
|
|
||||||
else
|
|
||||||
let caption = join(a:argList, ' ')
|
|
||||||
let options = ' ' . caption
|
|
||||||
endif
|
|
||||||
|
|
||||||
return s:DoCommand('blame' . options, 'annotate', caption, {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:hgFunctions.Commit(argList) {{{2
|
|
||||||
function! s:hgFunctions.Commit(argList)
|
|
||||||
try
|
|
||||||
return s:DoCommand('commit -v -l "' . a:argList[0] . '"', 'commit', '', {})
|
|
||||||
catch /Version control command failed.*nothing changed/
|
|
||||||
echomsg 'No commit needed.'
|
|
||||||
endtry
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:hgFunctions.Delete() {{{2
|
|
||||||
function! s:hgFunctions.Delete(argList)
|
|
||||||
return s:DoCommand(join(['remove'] + a:argList, ' '), 'remove', join(a:argList, ' '), {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:hgFunctions.Diff(argList) {{{2
|
|
||||||
function! s:hgFunctions.Diff(argList)
|
|
||||||
if len(a:argList) == 0
|
|
||||||
let revOptions = []
|
|
||||||
let caption = ''
|
|
||||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
|
||||||
let revOptions = ['-r' . join(a:argList, ':')]
|
|
||||||
let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')'
|
|
||||||
else
|
|
||||||
" Pass-through
|
|
||||||
let caption = join(a:argList, ' ')
|
|
||||||
let revOptions = a:argList
|
|
||||||
endif
|
|
||||||
|
|
||||||
let hgDiffExt = VCSCommandGetOption('VCSCommandHGDiffExt', '')
|
|
||||||
if hgDiffExt == ''
|
|
||||||
let diffExt = []
|
|
||||||
else
|
|
||||||
let diffExt = ['--diff-cmd ' . hgDiffExt]
|
|
||||||
endif
|
|
||||||
|
|
||||||
let hgDiffOpt = VCSCommandGetOption('VCSCommandHGDiffOpt', '')
|
|
||||||
if hgDiffOpt == ''
|
|
||||||
let diffOptions = []
|
|
||||||
else
|
|
||||||
let diffOptions = ['-x -' . hgDiffOpt]
|
|
||||||
endif
|
|
||||||
|
|
||||||
return s:DoCommand(join(['diff'] + diffExt + diffOptions + revOptions), 'diff', caption, {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:hgFunctions.Info(argList) {{{2
|
|
||||||
function! s:hgFunctions.Info(argList)
|
|
||||||
return s:DoCommand(join(['log --limit 1'] + a:argList, ' '), 'log', join(a:argList, ' '), {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:hgFunctions.GetBufferInfo() {{{2
|
|
||||||
" Provides version control details for the current file. Current version
|
|
||||||
" number and current repository version number are required to be returned by
|
|
||||||
" the vcscommand plugin.
|
|
||||||
" Returns: List of results: [revision, repository, branch]
|
|
||||||
|
|
||||||
function! s:hgFunctions.GetBufferInfo()
|
|
||||||
let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
|
|
||||||
let fileName = bufname(originalBuffer)
|
|
||||||
let statusText = s:VCSCommandUtility.system(s:Executable() . ' status -- "' . fileName . '"')
|
|
||||||
if(v:shell_error)
|
|
||||||
return []
|
|
||||||
endif
|
|
||||||
|
|
||||||
" File not under HG control.
|
|
||||||
if statusText =~ '^?'
|
|
||||||
return ['Unknown']
|
|
||||||
endif
|
|
||||||
|
|
||||||
let parentsText = s:VCSCommandUtility.system(s:Executable() . ' parents -- "' . fileName . '"')
|
|
||||||
let revision = matchlist(parentsText, '^changeset:\s\+\(\S\+\)\n')[1]
|
|
||||||
|
|
||||||
let logText = s:VCSCommandUtility.system(s:Executable() . ' log -- "' . fileName . '"')
|
|
||||||
let repository = matchlist(logText, '^changeset:\s\+\(\S\+\)\n')[1]
|
|
||||||
|
|
||||||
if revision == ''
|
|
||||||
" Error
|
|
||||||
return ['Unknown']
|
|
||||||
elseif statusText =~ '^A'
|
|
||||||
return ['New', 'New']
|
|
||||||
else
|
|
||||||
return [revision, repository]
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:hgFunctions.Log(argList) {{{2
|
|
||||||
function! s:hgFunctions.Log(argList)
|
|
||||||
if len(a:argList) == 0
|
|
||||||
let options = []
|
|
||||||
let caption = ''
|
|
||||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
|
||||||
let options = ['-r' . join(a:argList, ':')]
|
|
||||||
let caption = options[0]
|
|
||||||
else
|
|
||||||
" Pass-through
|
|
||||||
let options = a:argList
|
|
||||||
let caption = join(a:argList, ' ')
|
|
||||||
endif
|
|
||||||
|
|
||||||
let resultBuffer = s:DoCommand(join(['log', '-v'] + options), 'log', caption, {})
|
|
||||||
return resultBuffer
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:hgFunctions.Revert(argList) {{{2
|
|
||||||
function! s:hgFunctions.Revert(argList)
|
|
||||||
return s:DoCommand('revert', 'revert', '', {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:hgFunctions.Review(argList) {{{2
|
|
||||||
function! s:hgFunctions.Review(argList)
|
|
||||||
if len(a:argList) == 0
|
|
||||||
let versiontag = '(current)'
|
|
||||||
let versionOption = ''
|
|
||||||
else
|
|
||||||
let versiontag = a:argList[0]
|
|
||||||
let versionOption = ' -r ' . versiontag . ' '
|
|
||||||
endif
|
|
||||||
|
|
||||||
return s:DoCommand('cat' . versionOption, 'review', versiontag, {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:hgFunctions.Status(argList) {{{2
|
|
||||||
function! s:hgFunctions.Status(argList)
|
|
||||||
let options = ['-A', '-v']
|
|
||||||
if len(a:argList) != 0
|
|
||||||
let options = a:argList
|
|
||||||
endif
|
|
||||||
return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '), {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:hgFunctions.Update(argList) {{{2
|
|
||||||
function! s:hgFunctions.Update(argList)
|
|
||||||
return s:DoCommand('update', 'update', '', {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Annotate setting {{{2
|
|
||||||
let s:hgFunctions.AnnotateSplitRegex = '\d\+: '
|
|
||||||
|
|
||||||
" Section: Plugin Registration {{{1
|
|
||||||
let s:VCSCommandUtility = VCSCommandRegisterModule('HG', expand('<sfile>'), s:hgFunctions, [])
|
|
||||||
|
|
||||||
let &cpo = s:save_cpo
|
|
|
@ -1,259 +0,0 @@
|
||||||
" vim600: set foldmethod=marker:
|
|
||||||
"
|
|
||||||
" SVK extension for VCSCommand.
|
|
||||||
"
|
|
||||||
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
|
|
||||||
" License:
|
|
||||||
" Copyright (c) Bob Hiestand
|
|
||||||
"
|
|
||||||
" Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
" of this software and associated documentation files (the "Software"), to
|
|
||||||
" deal in the Software without restriction, including without limitation the
|
|
||||||
" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
||||||
" sell copies of the Software, and to permit persons to whom the Software is
|
|
||||||
" furnished to do so, subject to the following conditions:
|
|
||||||
"
|
|
||||||
" The above copyright notice and this permission notice shall be included in
|
|
||||||
" all copies or substantial portions of the Software.
|
|
||||||
"
|
|
||||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
||||||
" IN THE SOFTWARE.
|
|
||||||
"
|
|
||||||
" Section: Documentation {{{1
|
|
||||||
"
|
|
||||||
" Options documentation: {{{2
|
|
||||||
"
|
|
||||||
" VCSCommandSVKExec
|
|
||||||
" This variable specifies the SVK executable. If not set, it defaults to
|
|
||||||
" 'svk' executed from the user's executable path.
|
|
||||||
|
|
||||||
" Section: Plugin header {{{1
|
|
||||||
|
|
||||||
if exists('VCSCommandDisableAll')
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
if v:version < 700
|
|
||||||
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists('g:loaded_VCSCommand')
|
|
||||||
runtime plugin/vcscommand.vim
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !executable(VCSCommandGetOption('VCSCommandSVKExec', 'svk'))
|
|
||||||
" SVK is not installed
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
let s:save_cpo=&cpo
|
|
||||||
set cpo&vim
|
|
||||||
|
|
||||||
" Section: Variable initialization {{{1
|
|
||||||
|
|
||||||
let s:svkFunctions = {}
|
|
||||||
|
|
||||||
" Section: Utility functions {{{1
|
|
||||||
|
|
||||||
" Function: s:Executable() {{{2
|
|
||||||
" Returns the executable used to invoke SVK suitable for use in a shell
|
|
||||||
" command.
|
|
||||||
function! s:Executable()
|
|
||||||
return shellescape(VCSCommandGetOption('VCSCommandSVKExec', 'svk'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
|
|
||||||
" Wrapper to VCSCommandDoCommand to add the name of the SVK executable to the
|
|
||||||
" command argument.
|
|
||||||
function! s:DoCommand(cmd, cmdName, statusText, options)
|
|
||||||
if VCSCommandGetVCSType(expand('%')) == 'SVK'
|
|
||||||
let fullCmd = s:Executable() . ' ' . a:cmd
|
|
||||||
return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
|
|
||||||
else
|
|
||||||
throw 'SVK VCSCommand plugin called on non-SVK item.'
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Section: VCS function implementations {{{1
|
|
||||||
|
|
||||||
" Function: s:svkFunctions.Identify(buffer) {{{2
|
|
||||||
function! s:svkFunctions.Identify(buffer)
|
|
||||||
let fileName = resolve(bufname(a:buffer))
|
|
||||||
if isdirectory(fileName)
|
|
||||||
let directoryName = fileName
|
|
||||||
else
|
|
||||||
let directoryName = fnamemodify(fileName, ':p:h')
|
|
||||||
endif
|
|
||||||
let statusText = s:VCSCommandUtility.system(s:Executable() . ' info -- "' . directoryName . '"', "no")
|
|
||||||
if(v:shell_error)
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
return 1
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svkFunctions.Add() {{{2
|
|
||||||
function! s:svkFunctions.Add(argList)
|
|
||||||
return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' '), {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svkFunctions.Annotate(argList) {{{2
|
|
||||||
function! s:svkFunctions.Annotate(argList)
|
|
||||||
if len(a:argList) == 0
|
|
||||||
if &filetype ==? 'svkannotate'
|
|
||||||
" Perform annotation of the version indicated by the current line.
|
|
||||||
let caption = matchstr(getline('.'),'\v^\s+\zs\d+')
|
|
||||||
let options = ' -r' . caption
|
|
||||||
else
|
|
||||||
let caption = ''
|
|
||||||
let options = ''
|
|
||||||
endif
|
|
||||||
elseif len(a:argList) == 1 && a:argList[0] !~ '^-'
|
|
||||||
let caption = a:argList[0]
|
|
||||||
let options = ' -r' . caption
|
|
||||||
else
|
|
||||||
let caption = join(a:argList, ' ')
|
|
||||||
let options = ' ' . caption
|
|
||||||
endif
|
|
||||||
|
|
||||||
let resultBuffer = s:DoCommand('blame' . options, 'annotate', caption, {})
|
|
||||||
if resultBuffer > 0
|
|
||||||
normal! 1G2dd
|
|
||||||
endif
|
|
||||||
return resultBuffer
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svkFunctions.Commit(argList) {{{2
|
|
||||||
function! s:svkFunctions.Commit(argList)
|
|
||||||
let resultBuffer = s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '', {})
|
|
||||||
if resultBuffer == 0
|
|
||||||
echomsg 'No commit needed.'
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svkFunctions.Delete() {{{2
|
|
||||||
function! s:svkFunctions.Delete(argList)
|
|
||||||
return s:DoCommand(join(['delete'] + a:argList, ' '), 'delete', join(a:argList, ' '), {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svkFunctions.Diff(argList) {{{2
|
|
||||||
function! s:svkFunctions.Diff(argList)
|
|
||||||
if len(a:argList) == 0
|
|
||||||
let revOptions = []
|
|
||||||
let caption = ''
|
|
||||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
|
||||||
let revOptions = ['-r' . join(a:argList, ':')]
|
|
||||||
let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')'
|
|
||||||
else
|
|
||||||
" Pass-through
|
|
||||||
let caption = join(a:argList, ' ')
|
|
||||||
let revOptions = a:argList
|
|
||||||
endif
|
|
||||||
|
|
||||||
return s:DoCommand(join(['diff'] + revOptions), 'diff', caption, {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svkFunctions.GetBufferInfo() {{{2
|
|
||||||
" Provides version control details for the current file. Current version
|
|
||||||
" number and current repository version number are required to be returned by
|
|
||||||
" the vcscommand plugin.
|
|
||||||
" Returns: List of results: [revision, repository]
|
|
||||||
|
|
||||||
function! s:svkFunctions.GetBufferInfo()
|
|
||||||
let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
|
|
||||||
let fileName = resolve(bufname(originalBuffer))
|
|
||||||
let statusText = s:VCSCommandUtility.system(s:Executable() . ' status -v -- "' . fileName . '"')
|
|
||||||
if(v:shell_error)
|
|
||||||
return []
|
|
||||||
endif
|
|
||||||
|
|
||||||
" File not under SVK control.
|
|
||||||
if statusText =~ '^?'
|
|
||||||
return ['Unknown']
|
|
||||||
endif
|
|
||||||
|
|
||||||
let [flags, revision, repository] = matchlist(statusText, '^\(.\{3}\)\s\+\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)\s')[1:3]
|
|
||||||
if revision == ''
|
|
||||||
" Error
|
|
||||||
return ['Unknown']
|
|
||||||
elseif flags =~ '^A'
|
|
||||||
return ['New', 'New']
|
|
||||||
else
|
|
||||||
return [revision, repository]
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svkFunctions.Info(argList) {{{2
|
|
||||||
function! s:svkFunctions.Info(argList)
|
|
||||||
return s:DoCommand(join(['info'] + a:argList, ' '), 'info', join(a:argList, ' '), {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svkFunctions.Lock(argList) {{{2
|
|
||||||
function! s:svkFunctions.Lock(argList)
|
|
||||||
return s:DoCommand(join(['lock'] + a:argList, ' '), 'lock', join(a:argList, ' '), {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svkFunctions.Log() {{{2
|
|
||||||
function! s:svkFunctions.Log(argList)
|
|
||||||
if len(a:argList) == 0
|
|
||||||
let options = []
|
|
||||||
let caption = ''
|
|
||||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
|
||||||
let options = ['-r' . join(a:argList, ':')]
|
|
||||||
let caption = options[0]
|
|
||||||
else
|
|
||||||
" Pass-through
|
|
||||||
let options = a:argList
|
|
||||||
let caption = join(a:argList, ' ')
|
|
||||||
endif
|
|
||||||
|
|
||||||
let resultBuffer = s:DoCommand(join(['log', '-v'] + options), 'log', caption, {})
|
|
||||||
return resultBuffer
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svkFunctions.Revert(argList) {{{2
|
|
||||||
function! s:svkFunctions.Revert(argList)
|
|
||||||
return s:DoCommand('revert', 'revert', '', {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svkFunctions.Review(argList) {{{2
|
|
||||||
function! s:svkFunctions.Review(argList)
|
|
||||||
if len(a:argList) == 0
|
|
||||||
let versiontag = '(current)'
|
|
||||||
let versionOption = ''
|
|
||||||
else
|
|
||||||
let versiontag = a:argList[0]
|
|
||||||
let versionOption = ' -r ' . versiontag . ' '
|
|
||||||
endif
|
|
||||||
|
|
||||||
return s:DoCommand('cat' . versionOption, 'review', versiontag, {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svkFunctions.Status(argList) {{{2
|
|
||||||
function! s:svkFunctions.Status(argList)
|
|
||||||
let options = ['-v']
|
|
||||||
if len(a:argList) != 0
|
|
||||||
let options = a:argList
|
|
||||||
endif
|
|
||||||
return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '), {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svkFunctions.Unlock(argList) {{{2
|
|
||||||
function! s:svkFunctions.Unlock(argList)
|
|
||||||
return s:DoCommand(join(['unlock'] + a:argList, ' '), 'unlock', join(a:argList, ' '), {})
|
|
||||||
endfunction
|
|
||||||
" Function: s:svkFunctions.Update(argList) {{{2
|
|
||||||
function! s:svkFunctions.Update(argList)
|
|
||||||
return s:DoCommand('update', 'update', '', {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Section: Plugin Registration {{{1
|
|
||||||
let s:VCSCommandUtility = VCSCommandRegisterModule('SVK', expand('<sfile>'), s:svkFunctions, [])
|
|
||||||
|
|
||||||
let &cpo = s:save_cpo
|
|
|
@ -1,285 +0,0 @@
|
||||||
" vim600: set foldmethod=marker:
|
|
||||||
"
|
|
||||||
" SVN extension for VCSCommand.
|
|
||||||
"
|
|
||||||
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
|
|
||||||
" License:
|
|
||||||
" Copyright (c) Bob Hiestand
|
|
||||||
"
|
|
||||||
" Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
" of this software and associated documentation files (the "Software"), to
|
|
||||||
" deal in the Software without restriction, including without limitation the
|
|
||||||
" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
||||||
" sell copies of the Software, and to permit persons to whom the Software is
|
|
||||||
" furnished to do so, subject to the following conditions:
|
|
||||||
"
|
|
||||||
" The above copyright notice and this permission notice shall be included in
|
|
||||||
" all copies or substantial portions of the Software.
|
|
||||||
"
|
|
||||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
||||||
" IN THE SOFTWARE.
|
|
||||||
"
|
|
||||||
" Section: Documentation {{{1
|
|
||||||
"
|
|
||||||
" Options documentation: {{{2
|
|
||||||
"
|
|
||||||
" VCSCommandSVNExec
|
|
||||||
" This variable specifies the SVN executable. If not set, it defaults to
|
|
||||||
" 'svn' executed from the user's executable path.
|
|
||||||
"
|
|
||||||
" VCSCommandSVNDiffExt
|
|
||||||
" This variable, if set, sets the external diff program used by Subversion.
|
|
||||||
"
|
|
||||||
" VCSCommandSVNDiffOpt
|
|
||||||
" This variable, if set, determines the options passed to the svn diff
|
|
||||||
" command (such as 'u', 'w', or 'b').
|
|
||||||
|
|
||||||
" Section: Plugin header {{{1
|
|
||||||
|
|
||||||
if exists('VCSCommandDisableAll')
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
if v:version < 700
|
|
||||||
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists('g:loaded_VCSCommand')
|
|
||||||
runtime plugin/vcscommand.vim
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !executable(VCSCommandGetOption('VCSCommandSVNExec', 'svn'))
|
|
||||||
" SVN is not installed
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
let s:save_cpo=&cpo
|
|
||||||
set cpo&vim
|
|
||||||
|
|
||||||
" Section: Variable initialization {{{1
|
|
||||||
|
|
||||||
let s:svnFunctions = {}
|
|
||||||
|
|
||||||
" Section: Utility functions {{{1
|
|
||||||
|
|
||||||
" Function: s:Executable() {{{2
|
|
||||||
" Returns the executable used to invoke git suitable for use in a shell
|
|
||||||
" command.
|
|
||||||
function! s:Executable()
|
|
||||||
return shellescape(VCSCommandGetOption('VCSCommandSVNExec', 'svn'))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
|
|
||||||
" Wrapper to VCSCommandDoCommand to add the name of the SVN executable to the
|
|
||||||
" command argument.
|
|
||||||
function! s:DoCommand(cmd, cmdName, statusText, options)
|
|
||||||
if VCSCommandGetVCSType(expand('%')) == 'SVN'
|
|
||||||
let fullCmd = s:Executable() . ' ' . a:cmd
|
|
||||||
return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
|
|
||||||
else
|
|
||||||
throw 'SVN VCSCommand plugin called on non-SVN item.'
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Section: VCS function implementations {{{1
|
|
||||||
|
|
||||||
" Function: s:svnFunctions.Identify(buffer) {{{2
|
|
||||||
function! s:svnFunctions.Identify(buffer)
|
|
||||||
let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname(a:buffer)))
|
|
||||||
try
|
|
||||||
call s:VCSCommandUtility.system(s:Executable() . ' info .')
|
|
||||||
if(v:shell_error)
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
return g:VCSCOMMAND_IDENTIFY_EXACT
|
|
||||||
endif
|
|
||||||
finally
|
|
||||||
call VCSCommandChdir(oldCwd)
|
|
||||||
endtry
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svnFunctions.Add() {{{2
|
|
||||||
function! s:svnFunctions.Add(argList)
|
|
||||||
return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' '), {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svnFunctions.Annotate(argList) {{{2
|
|
||||||
function! s:svnFunctions.Annotate(argList)
|
|
||||||
if len(a:argList) == 0
|
|
||||||
if &filetype ==? 'svnannotate'
|
|
||||||
" Perform annotation of the version indicated by the current line.
|
|
||||||
let caption = matchstr(getline('.'),'\v^\s+\zs\d+')
|
|
||||||
let options = ' -r' . caption
|
|
||||||
else
|
|
||||||
let caption = ''
|
|
||||||
let options = ''
|
|
||||||
endif
|
|
||||||
elseif len(a:argList) == 1 && a:argList[0] !~ '^-'
|
|
||||||
let caption = a:argList[0]
|
|
||||||
let options = ' -r' . caption
|
|
||||||
else
|
|
||||||
let caption = join(a:argList, ' ')
|
|
||||||
let options = ' ' . caption
|
|
||||||
endif
|
|
||||||
|
|
||||||
return s:DoCommand('blame --non-interactive' . options, 'annotate', caption, {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svnFunctions.Commit(argList) {{{2
|
|
||||||
function! s:svnFunctions.Commit(argList)
|
|
||||||
let resultBuffer = s:DoCommand('commit --non-interactive -F "' . a:argList[0] . '"', 'commit', '', {})
|
|
||||||
if resultBuffer == 0
|
|
||||||
echomsg 'No commit needed.'
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svnFunctions.Delete() {{{2
|
|
||||||
function! s:svnFunctions.Delete(argList)
|
|
||||||
return s:DoCommand(join(['delete --non-interactive'] + a:argList, ' '), 'delete', join(a:argList, ' '), {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svnFunctions.Diff(argList) {{{2
|
|
||||||
function! s:svnFunctions.Diff(argList)
|
|
||||||
if len(a:argList) == 0
|
|
||||||
let revOptions = []
|
|
||||||
let caption = ''
|
|
||||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
|
||||||
let revOptions = ['-r' . join(a:argList, ':')]
|
|
||||||
let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')'
|
|
||||||
else
|
|
||||||
" Pass-through
|
|
||||||
let caption = join(a:argList, ' ')
|
|
||||||
let revOptions = a:argList
|
|
||||||
endif
|
|
||||||
|
|
||||||
let svnDiffExt = VCSCommandGetOption('VCSCommandSVNDiffExt', '')
|
|
||||||
if svnDiffExt == ''
|
|
||||||
let diffExt = []
|
|
||||||
else
|
|
||||||
let diffExt = ['--diff-cmd ' . svnDiffExt]
|
|
||||||
endif
|
|
||||||
|
|
||||||
let svnDiffOpt = VCSCommandGetOption('VCSCommandSVNDiffOpt', '')
|
|
||||||
if svnDiffOpt == ''
|
|
||||||
let diffOptions = []
|
|
||||||
else
|
|
||||||
let diffOptions = ['-x -' . svnDiffOpt]
|
|
||||||
endif
|
|
||||||
|
|
||||||
return s:DoCommand(join(['diff --non-interactive'] + diffExt + diffOptions + revOptions), 'diff', caption, {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svnFunctions.GetBufferInfo() {{{2
|
|
||||||
" Provides version control details for the current file. Current version
|
|
||||||
" number and current repository version number are required to be returned by
|
|
||||||
" the vcscommand plugin.
|
|
||||||
" Returns: List of results: [revision, repository, branch]
|
|
||||||
|
|
||||||
function! s:svnFunctions.GetBufferInfo()
|
|
||||||
let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
|
|
||||||
let fileName = bufname(originalBuffer)
|
|
||||||
let statusText = s:VCSCommandUtility.system(s:Executable() . ' status --non-interactive -v -- "' . fileName . '"')
|
|
||||||
if(v:shell_error)
|
|
||||||
return []
|
|
||||||
endif
|
|
||||||
|
|
||||||
" File not under SVN control.
|
|
||||||
if statusText =~ '^?'
|
|
||||||
return ['Unknown']
|
|
||||||
endif
|
|
||||||
" File explicitly ignored by SVN.
|
|
||||||
if statusText =~ '^I'
|
|
||||||
return ['Ignored']
|
|
||||||
endif
|
|
||||||
|
|
||||||
let [flags, revision, repository] = matchlist(statusText, '^\(.\{9}\)\s*\(\d\+\)\s\+\(\d\+\)')[1:3]
|
|
||||||
if revision == ''
|
|
||||||
" Error
|
|
||||||
return ['Unknown']
|
|
||||||
elseif flags =~ '^A'
|
|
||||||
return ['New', 'New']
|
|
||||||
elseif flags =~ '*'
|
|
||||||
return [revision, repository, '*']
|
|
||||||
else
|
|
||||||
return [revision, repository]
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svnFunctions.Info(argList) {{{2
|
|
||||||
function! s:svnFunctions.Info(argList)
|
|
||||||
return s:DoCommand(join(['info --non-interactive'] + a:argList, ' '), 'info', join(a:argList, ' '), {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svnFunctions.Lock(argList) {{{2
|
|
||||||
function! s:svnFunctions.Lock(argList)
|
|
||||||
return s:DoCommand(join(['lock --non-interactive'] + a:argList, ' '), 'lock', join(a:argList, ' '), {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svnFunctions.Log(argList) {{{2
|
|
||||||
function! s:svnFunctions.Log(argList)
|
|
||||||
if len(a:argList) == 0
|
|
||||||
let options = []
|
|
||||||
let caption = ''
|
|
||||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
|
||||||
let options = ['-r' . join(a:argList, ':')]
|
|
||||||
let caption = options[0]
|
|
||||||
else
|
|
||||||
" Pass-through
|
|
||||||
let options = a:argList
|
|
||||||
let caption = join(a:argList, ' ')
|
|
||||||
endif
|
|
||||||
|
|
||||||
let resultBuffer = s:DoCommand(join(['log --non-interactive', '-v'] + options), 'log', caption, {})
|
|
||||||
return resultBuffer
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svnFunctions.Revert(argList) {{{2
|
|
||||||
function! s:svnFunctions.Revert(argList)
|
|
||||||
return s:DoCommand('revert', 'revert', '', {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svnFunctions.Review(argList) {{{2
|
|
||||||
function! s:svnFunctions.Review(argList)
|
|
||||||
if len(a:argList) == 0
|
|
||||||
let versiontag = '(current)'
|
|
||||||
let versionOption = ''
|
|
||||||
else
|
|
||||||
let versiontag = a:argList[0]
|
|
||||||
let versionOption = ' -r ' . versiontag . ' '
|
|
||||||
endif
|
|
||||||
|
|
||||||
return s:DoCommand('cat --non-interactive' . versionOption, 'review', versiontag, {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svnFunctions.Status(argList) {{{2
|
|
||||||
function! s:svnFunctions.Status(argList)
|
|
||||||
let options = ['-u', '-v']
|
|
||||||
if len(a:argList) != 0
|
|
||||||
let options = a:argList
|
|
||||||
endif
|
|
||||||
return s:DoCommand(join(['status --non-interactive'] + options, ' '), 'status', join(options, ' '), {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svnFunctions.Unlock(argList) {{{2
|
|
||||||
function! s:svnFunctions.Unlock(argList)
|
|
||||||
return s:DoCommand(join(['unlock --non-interactive'] + a:argList, ' '), 'unlock', join(a:argList, ' '), {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:svnFunctions.Update(argList) {{{2
|
|
||||||
function! s:svnFunctions.Update(argList)
|
|
||||||
return s:DoCommand('update --non-interactive', 'update', '', {})
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Annotate setting {{{2
|
|
||||||
let s:svnFunctions.AnnotateSplitRegex = '\s\+\S\+\s\+\S\+ '
|
|
||||||
|
|
||||||
" Section: Plugin Registration {{{1
|
|
||||||
let s:VCSCommandUtility = VCSCommandRegisterModule('SVN', expand('<sfile>'), s:svnFunctions, [])
|
|
||||||
|
|
||||||
let &cpo = s:save_cpo
|
|
|
@ -1,21 +0,0 @@
|
||||||
/*
|
|
||||||
-*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
Copyright by @@LONGNAME@@ <@@EMAIL@@>
|
|
||||||
First version: @@crdate@@
|
|
||||||
|
|
||||||
Synopsis: @@DESCR@@
|
|
||||||
|
|
||||||
$Id$
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set ts=4 sw=4 tw=0 ft=c : */
|
|
|
@ -1,11 +0,0 @@
|
||||||
#!/usr/bin/env perl
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Copyright by @@LONGNAME@@ <@@EMAIL@@>
|
|
||||||
# First version: @@crdate@@
|
|
||||||
#
|
|
||||||
# Synopsis: @@DESCR@@
|
|
||||||
#
|
|
||||||
# $Id$
|
|
||||||
|
|
||||||
# vim: set ts=4 sw=4 tw=0 ft=perl :
|
|
|
@ -1,26 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
#-*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
Copyright by @@LONGNAME@@ <@@EMAIL@@>
|
|
||||||
First version: @@crdate@@
|
|
||||||
|
|
||||||
Synopsis: @@DESCR@@
|
|
||||||
|
|
||||||
$Id$
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
__version__ ='0.1'
|
|
||||||
__author__ ='@@LONGNAME@@ <@@EMAIL@@>'
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
pass
|
|
||||||
|
|
||||||
# If we have been called as 'python <script>' let's call main function
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
|
|
||||||
# vim: set ts=4 sw=4 tw=79 ft=python :
|
|
|
@ -1,13 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Copyright by @@LONGNAME@@ <@@EMAIL@@>
|
|
||||||
# First version: @@crdate@@
|
|
||||||
#
|
|
||||||
# Synopsis: @@DESCR@@
|
|
||||||
#
|
|
||||||
# $Id$
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# vim: set ts=4 sw=4 tw=79 ft=sh :
|
|
Loading…
Reference in New Issue