Permalink
Browse files

update Align.vim to v37

  • Loading branch information...
1 parent 97c34c6 commit bf2efeba30be6ad6f762d4cd69b994e532a3b9ba @lilydjwg committed Mar 25, 2013
Showing with 304 additions and 276 deletions.
  1. +1 −1 .VimballRecord
  2. +40 −30 autoload/Align.vim
  3. +47 −39 autoload/AlignMaps.vim
  4. +202 −194 doc/Align.txt
  5. +2 −0 doc/tags
  6. +3 −3 plugin/AlignPlugin.vim
  7. +9 −9 plugin/cecutil.vim
View
@@ -10,5 +10,5 @@ CountJump.vba: call delete('/home/lilydjwg/.vim/autoload/CountJump.vim')|call de
tagbar.vmb: call delete('/home/lilydjwg/.vim/autoload/tagbar.vim')|call delete('/home/lilydjwg/.vim/doc/tagbar.txt')|call delete('/home/lilydjwg/.vim/plugin/tagbar.vim')|call delete('/home/lilydjwg/.vim/syntax/tagbar.vim')
manpageview.vba: call delete('/home/lilydjwg/.vim/plugin/manpageviewPlugin.vim')|call delete('/home/lilydjwg/.vim/autoload/manpageview.vim')|call delete('/home/lilydjwg/.vim/syntax/man.vim')|call delete('/home/lilydjwg/.vim/syntax/mangl.vim')|call delete('/home/lilydjwg/.vim/syntax/mankey.vim')|call delete('/home/lilydjwg/.vim/syntax/info.vim')|call delete('/home/lilydjwg/.vim/syntax/manphp.vim')|call delete('/home/lilydjwg/.vim/doc/manpageview.txt')|call delete('/home/lilydjwg/.vim/plugin/cecutil.vim')
mark.vba: call delete('/home/lilydjwg/.vim/autoload/mark.vim')|call delete('/home/lilydjwg/.vim/plugin/mark.vim')|call delete('/home/lilydjwg/.vim/doc/mark.txt')
-Align.vba: call delete('/home/lilydjwg/.vim/plugin/AlignPlugin.vim')|call delete('/home/lilydjwg/.vim/plugin/AlignMapsPlugin.vim')|call delete('/home/lilydjwg/.vim/plugin/cecutil.vim')|call delete('/home/lilydjwg/.vim/doc/Align.txt')|call delete('/home/lilydjwg/.vim/autoload/Align.vim')|call delete('/home/lilydjwg/.vim/autoload/AlignMaps.vim')
NrrwRgn-0.29.vmb: call delete('/home/lilydjwg/.vim/plugin/NrrwRgn.vim')|call delete('/home/lilydjwg/.vim/autoload/nrrwrgn.vim')|call delete('/home/lilydjwg/.vim/doc/NarrowRegion.txt')
+Align.vba: call delete('/home/lilydjwg/.vim/plugin/AlignPlugin.vim')|call delete('/home/lilydjwg/.vim/plugin/AlignMapsPlugin.vim')|call delete('/home/lilydjwg/.vim/plugin/cecutil.vim')|call delete('/home/lilydjwg/.vim/doc/Align.txt')|call delete('/home/lilydjwg/.vim/autoload/Align.vim')|call delete('/home/lilydjwg/.vim/autoload/AlignMaps.vim')
View
@@ -1,10 +1,10 @@
" Align: tool to align multiple fields based on one or more separators
-" Author: Charles E. Campbell, Jr.
-" Date: Jun 18, 2012
-" Version: 36
+" Author: Charles E. Campbell
+" Date: Mar 12, 2013
+" Version: 37
" GetLatestVimScripts: 294 1 :AutoInstall: Align.vim
" GetLatestVimScripts: 1066 1 :AutoInstall: cecutil.vim
-" Copyright: Copyright (C) 1999-2012 Charles E. Campbell, Jr. {{{1
+" 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,
@@ -25,7 +25,7 @@
if exists("g:loaded_Align") || &cp
finish
endif
-let g:loaded_Align = "v36"
+let g:loaded_Align = "v37"
if v:version < 700
echohl WarningMsg
echo "***warning*** this version of Align needs vim 7.0"
@@ -43,7 +43,11 @@ set cpo&vim
" ---------------------------------------------------------------------
" Options: {{{1
if !exists("g:Align_xstrlen")
- if &enc == "latin1" || $LANG == "en_US.UTF-8" || !has("multi_byte")
+ if exists("g:drawit_xstrlen")
+ let g:Align_xstrlen= g:drawit_xstrlen
+ elseif exists("g:netrw_xstrlen")
+ let g:Align_xstrlen= g:netrw_xstrlen
+ elseif &enc == "latin1" || !has("multi_byte")
let g:Align_xstrlen= 0
else
let g:Align_xstrlen= 1
@@ -529,19 +533,19 @@ fun! Align#Align(hasctrl,...) range
" call Decho(" ")
" call Decho("---- Pass ".pass.": ----")
- let line= begline
- while line <= endline
+ let curline= begline
+ while curline <= endline
" Process each line
- let txt = getline(line)
+ let txt = getline(curline)
" call Decho(" ")
-" call Decho("Pass".pass.": Line ".line." <".txt.">")
+" call Decho("Pass".pass.": Line ".curline." <".txt.">")
" AlignGPat support: allows a selector pattern (akin to g/selector/cmd )
if exists("s:AlignGPat")
" call Decho("Pass".pass.": AlignGPat<".s:AlignGPat.">")
if match(txt,s:AlignGPat) == -1
" call Decho("Pass".pass.": skipping")
- let line= line + 1
+ let curline= curline + 1
continue
endif
endif
@@ -551,20 +555,20 @@ fun! Align#Align(hasctrl,...) range
" call Decho("Pass".pass.": AlignVPat<".s:AlignVPat.">")
if match(txt,s:AlignVPat) != -1
" call Decho("Pass".pass.": skipping")
- let line= line + 1
+ let curline= curline + 1
continue
endif
endif
" Always skip blank lines
if match(txt,'^\s*$') != -1
" call Decho("Pass".pass.": skipping")
- let line= line + 1
+ let curline= curline + 1
continue
endif
" Extract visual-block selected text (init bgntxt, endtxt)
- let txtlen= s:Strlen(txt)
+ let txtlen= s:Strlen(txt)
if begcol > 0
" Record text to left of selected area
let bgntxt= strpart(txt,0,begcol)
@@ -655,7 +659,7 @@ fun! Align#Align(hasctrl,...) range
if alignop == '*' && exists("g:AlignSkip") && type(g:AlignSkip) == 2
" call Decho("Pass".pass.": endfield=match(txt<".txt.">,seppat<".seppat.">,bgnfield=".bgnfield.")=".endfield." alignop=".alignop)
" a '*' acts like a '-' while the g:AlignSkip function reference is true except that alignop doesn't advance
- while g:AlignSkip(line,endfield) && endfield != -1
+ while g:AlignSkip(curline,endfield) && endfield != -1
let endfield = match(txt,seppat,skipfield)
let sepfield = matchend(txt,seppat,skipfield)
let skipfield = sepfield
@@ -688,22 +692,20 @@ fun! Align#Align(hasctrl,...) range
let field = bgntxt.field
let bgntxt= ""
endif
- let fieldlen = s:Strlen(field)
- let sFieldSize = "FieldSize_".ifield
- if !exists(sFieldSize)
+ let fieldlen= s:Strlen(field)
+ if !exists("FieldSize_{ifield}")
let FieldSize_{ifield}= fieldlen
-" call Decho("Pass".pass.": set FieldSize_{".ifield."}=".FieldSize_{ifield}." <".field.">")
+" call Decho("Pass".pass.": set FieldSize_{".ifield."}=".FieldSize_{ifield}." <".field."> (init)")
elseif fieldlen > FieldSize_{ifield}
let FieldSize_{ifield}= fieldlen
-" call Decho("Pass".pass.": oset FieldSize_{".ifield."}=".FieldSize_{ifield}." <".field.">")
+" call Decho("Pass".pass.": set FieldSize_{".ifield."}=".FieldSize_{ifield}." <".field."> (fieldlen>FieldSize_".ifield.")")
endif
- let sSepSize= "SepSize_".ifield
- if !exists(sSepSize)
+ if !exists("SepSize_{ifield}")
let SepSize_{ifield}= seplen
-" call Decho(" set SepSize_{".ifield."}=".SepSize_{ifield}." <".field.">")
+" call Decho("Pass".pass.": set SepSize_{".ifield."}=".SepSize_{ifield}." <".field."> (init)")
elseif seplen > SepSize_{ifield}
let SepSize_{ifield}= seplen
-" call Decho("Pass".pass.": oset SepSize_{".ifield."}=".SepSize_{ifield}." <".field.">")
+" call Decho("Pass".pass.": set SepSize_{".ifield."}=".SepSize_{ifield}." <".field."> (seplen>SepSize_".ifield.")")
endif
else
@@ -714,6 +716,8 @@ fun! Align#Align(hasctrl,...) range
let alignprepad = strpart(alignprepad,1).strpart(alignprepad,0,1)
let alignpostpad = strpart(alignpostpad,1).strpart(alignpostpad,0,1)
let field = substitute(strpart(txt,bgnfield,endfield-bgnfield),'^\s*\(.\{-}\)\s*$','\1','')
+" call Decho("Pass".pass.": alignprepad <".alignprepad."> prepad =".prepad)
+" call Decho("Pass".pass.": alignpostpad<".alignpostpad."> postpad=".postpad)
if s:AlignLeadKeep == 'W'
let field = bgntxt.field
let bgntxt= ""
@@ -724,21 +728,26 @@ fun! Align#Align(hasctrl,...) range
endif
let fieldlen = s:Strlen(field)
let sep = s:MakeSpace(prepad).strpart(txt,endfield,sepfield-endfield).s:MakeSpace(postpad)
+" call Decho("Pass".pass.": sep<".sep."> (after prepad, sepfield-endfield,postpad)")
if seplen < SepSize_{ifield}
if alignsepop == "<"
" left-justify separators
let sep = sep.s:MakeSpace(SepSize_{ifield}-seplen)
+" call Decho("Pass".pass.": sep<".sep."> (left-justified)")
elseif alignsepop == ">"
" right-justify separators
let sep = s:MakeSpace(SepSize_{ifield}-seplen).sep
+" call Decho("Pass".pass.": sep<".sep."> (right-justified)")
else
" center-justify separators
let sepleft = (SepSize_{ifield} - seplen)/2
let sepright = SepSize_{ifield} - seplen - sepleft
let sep = s:MakeSpace(sepleft).sep.s:MakeSpace(sepright)
+" call Decho("Pass".pass.": sep<".sep."> (center-justified)")
endif
endif
let spaces = FieldSize_{ifield} - fieldlen
+" call Decho("Pass".pass.": spaces=[FieldSize_".ifield."=".FieldSize_{ifield}."] - [fieldlen=".fieldlen."]=".spaces)
" call Decho("Pass".pass.": Field #".ifield."<".field."> spaces=".spaces." be[".bgnfield.",".endfield."] pad=".prepad.','.postpad." FS_".ifield."<".FieldSize_{ifield}."> sep<".sep."> ragged=".ragged." doend=".doend." alignop<".alignop.">")
" Perform alignment according to alignment style justification
@@ -786,18 +795,20 @@ fun! Align#Align(hasctrl,...) range
if pass == 2
" Write altered line to buffer
-" call Decho("Pass".pass.": bgntxt<".bgntxt."> line=".line)
+" call Decho("Pass".pass.": bgntxt<".bgntxt."> curline=".curline)
" call Decho("Pass".pass.": newtxt<".newtxt.">")
" call Decho("Pass".pass.": endtxt<".endtxt.">")
- keepj call setline(line,bgntxt.newtxt.endtxt)
+ keepj call setline(curline,bgntxt.newtxt.endtxt)
endif
+" call Decho("Pass".pass.": line#".curline."<".getline(".")."> (end-of-while)")
- let line = line + 1
- endwhile " line loop
+ let curline = curline + 1
+ endwhile " curline loop
let pass= pass + 1
endwhile " pass loop
" call Decho("end of two pass loop")
+" call Decho("ENDWHILE: cursor at (".line(".").",".col(".").") curline#".curline)
" restore original leading whitespace
if s:AlignLeadKeep == 'W'
@@ -1059,8 +1070,7 @@ fun! s:Strlen(x)
call setline(line("."),a:x)
let ret= virtcol("$") - 1
d
- " lilydjwg: 这样才不会让光标乱跑
- normal k
+ keepj norm! k
let &l:mod= modkeep
else
@@ -1,8 +1,8 @@
" AlignMaps.vim : support functions for AlignMaps
-" Author: Charles E. Campbell, Jr.
-" Date: Jun 18, 2012
-" Version: 42
-" Copyright: Copyright (C) 1999-2012 Charles E. Campbell, Jr. {{{1
+" 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,
@@ -16,7 +16,7 @@
if &cp || exists("g:loaded_AlignMaps")
finish
endif
-let g:loaded_AlignMaps= "v42"
+let g:loaded_AlignMaps= "v43"
let s:keepcpo = &cpo
set cpo&vim
"DechoTabOn
@@ -112,6 +112,20 @@ fun! AlignMaps#WrapperEnd() range
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.")")
@@ -169,15 +183,15 @@ 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/\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@\([.*/%|&\~^!=]\)\( \+\)=@\2\1=@ge
keepj 'a,'z-1s@[^+\-]\zs\([+\-]\)\( \+\)=@\2\1=@ge
keepj 'a,'z-1s/\( \+\);/;\1/ge
if &ft == "c" || &ft == "cpp"
@@ -323,37 +337,6 @@ fun! AlignMaps#FixMultiDec()
let curline = getline(".")
" call Decho("curline<".curline.">")
-" " Attempt to ignore function calls (ie. double x=pow(2.,3.),...
-" let leader= substitute(curline,'^\s*\([a-zA-Z_ \t][a-zA-Z0-9<>_ \t]*\)\s\+.*$','\1','')
-" let i = strlen(leader)
-" let paren = 0
-" let fmd = strpart(curline,i)
-" let ifmd = i
-" call Decho("fmd<".fmd."> ifmd=".ifmd)
-" while i < strlen(curline)
-" if strpart(curline,i,1) == '('
-" let paren= paren+1
-" elseif strpart(curline,i,1) == ')' && paren > 0
-" let paren= paren-1
-" elseif strpart(curline,i,1) == '='
-" let eq= 1
-" elseif strpart(curline,i,1) == ';'
-" let paren = 0
-" let eq = 0
-" let fmd = fmd.strpart(fmd,ifmd,i-ifmd).";\<cr>"
-" let ifmd = i + 2
-" let i = i + 1
-" let leader= substitute(curline,'^\s*\([a-zA-Z_ \t][a-zA-Z0-9<>_ \t]*\)\s\+.*$','\1','')
-" elseif strpart(curline,i,1) == ','
-" if paren == 0
-" let fmd = fmd.strpart(fmd,ifmd,i-ifmd).";\<cr>"
-" let ifmd = i + 2
-" let i = i + 1
-" endif
-" endif
-" let i= i + 1
-" endwhile
- " Get the type. I'm assuming one type per line (ie. int x; double y; on one line will not be handled properly)
let @x=substitute(curline,'^\(\s*[a-zA-Z_ \t][a-zA-Z0-9<>_ \t]*\)\s\+[(*]*\h.*$','\1','')
" call Decho("@x<".@x.">")
@@ -387,6 +370,31 @@ fun! 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
Oops, something went wrong.

0 comments on commit bf2efeb

Please sign in to comment.