Message from discussion
Bug: filetypes that rely on &sw fail after the patch which allows sw to be 0
Received: by 10.66.86.133 with SMTP id p5mr4336279paz.12.1350425126056;
Tue, 16 Oct 2012 15:05:26 -0700 (PDT)
X-BeenThere: vim_dev@googlegroups.com
Received: by 10.68.197.72 with SMTP id is8ls24149117pbc.5.gmail; Tue, 16 Oct
2012 15:05:23 -0700 (PDT)
Received: by 10.68.225.234 with SMTP id rn10mr3605257pbc.3.1350425123190;
Tue, 16 Oct 2012 15:05:23 -0700 (PDT)
Date: Tue, 16 Oct 2012 15:05:22 -0700 (PDT)
From: So8res <so8...@gmail.com>
To: vim_dev@googlegroups.com
Cc: So8res <so8...@gmail.com>, james...@jamessan.com
Message-Id: <5b685f93-61fb-486a-b06e-f37556f0d001@googlegroups.com>
In-Reply-To: <a6a13080-aa72-4429-b064-440b0c93305b@googlegroups.com>
References: <0bb1dd84-c649-4d5b-a50a-9a632de60482@googlegroups.com>
<201210160411.q9G4BoIE010040@masaka.moolenaar.net>
<a6a13080-aa72-4429-b064-440b0c93305b@googlegroups.com>
Subject: Re: Bug: filetypes that rely on &sw fail after the patch which
allows sw to be 0
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_178_17135997.1350425122033"
------=_Part_178_17135997.1350425122033
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Good idea.
> I would rather suggest not having s:Shiftwidth with has(), but have has() at the top level:
>
>
>
> if exists('*shiftwidth')
>
> let s:Shiftwidth=function('shiftwidth')
>
> else
>
> function s:Shiftwidth()
>
> return &sw
>
> endfunction
>
> endif
------=_Part_178_17135997.1350425122033
Content-Type: text/x-diff; charset=UTF-8; name=local_shiftwidth_fns.diff
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename=local_shiftwidth_fns.diff
X-Attachment-Id: 97ebe97a-f4ea-4b0a-b04c-a4cafb74f2c7
diff -r eccc57e1caa0 runtime/autoload/ada.vim
--- a/runtime/autoload/ada.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/autoload/ada.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -32,6 +32,14 @@
let s:keepcpo=3D &cpo
set cpo&vim
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
" Section: Constants {{{1
"
let g:ada#DotWordRegex=09 =3D '\a\w*\(\_s*\.\_s*\a\w*\)*'
@@ -520,9 +528,9 @@
=09 " gnat outdents a line which stards with a ( by one characters so
=09 " that parameters which follow are aligned.
=09 "
-=09 let l:Level =3D (indent (a:Line) + 1) / &shiftwidth
+=09 let l:Level =3D (indent (a:Line) + 1) / s:Shiftwidth()
else
-=09 let l:Level =3D indent (a:Line) / &shiftwidth
+=09 let l:Level =3D indent (a:Line) / s:Shiftwidth()
endif
=20
return l:Level
diff -r eccc57e1caa0 runtime/doc/indent.txt
--- a/runtime/doc/indent.txt=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/doc/indent.txt=09Tue Oct 16 15:03:58 2012 -0700
@@ -715,11 +715,11 @@
that you can change the value of 'shiftwidth' later.
=20
Indent after an open paren: >
-=09let g:pyindent_open_paren =3D '&sw * 2'
+=09let g:pyindent_open_paren =3D 'shiftwidth() * 2'
Indent after a nested paren: >
-=09let g:pyindent_nested_paren =3D '&sw'
+=09let g:pyindent_nested_paren =3D 'shiftwidth()'
Indent for a continuation line: >
-=09let g:pyindent_continue =3D '&sw * 2'
+=09let g:pyindent_continue =3D 'shiftwidth() * 2'
=20
=20
R=09=09=09=09=09=09=09=09*ft-r-indent*
@@ -808,7 +808,7 @@
indenting width (default is 'shiftwidth'): >
=20
let b:verilog_indent_width =3D 4
- let b:verilog_indent_width =3D &sw * 2
+ let b:verilog_indent_width =3D shiftwidth() * 2
=20
In addition, you can turn the verbose mode for debug issue: >
=20
@@ -931,7 +931,7 @@
For indenting Vim scripts there is one variable that specifies the amount =
of
indent for a continuation line, a line that starts with a backslash: >
=20
-=09:let g:vim_indent_cont =3D &sw * 3
+=09:let g:vim_indent_cont =3D shiftwidth() * 3
=20
Three times shiftwidth is the default value.
=20
diff -r eccc57e1caa0 runtime/ftplugin/cobol.vim
--- a/runtime/ftplugin/cobol.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/ftplugin/cobol.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -12,6 +12,14 @@
endif
let b:did_ftplugin =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
let s:cpo_save =3D &cpo
set cpo&vim
=20
@@ -113,7 +121,7 @@
=20
function! s:increase(...)
let lnum =3D '.'
- let sw =3D &shiftwidth
+ let sw =3D s:Shiftwidth()
let i =3D a:0 ? a:1 : indent(lnum)
if i >=3D 11
return sw - (i - 11) % sw
@@ -128,7 +136,7 @@
=20
function! s:decrease(...)
let lnum =3D '.'
- let sw =3D &shiftwidth
+ let sw =3D s:Shiftwidth()
let i =3D indent(a:0 ? a:1 : lnum)
if i >=3D 11 + sw
return 1 + (i + 12) % sw
@@ -147,7 +155,7 @@
let head =3D strpart(getline('.'),0,7)
let tail =3D strpart(getline('.'),7)
let indent =3D match(tail,'[^ ]')
- let sw =3D &shiftwidth
+ let sw =3D s:Shiftwidth()
let shift =3D a:shift
if shift > 0
if indent < 4
@@ -185,7 +193,7 @@
endif
endif
let interval =3D s:increase()
- let b:cobol_shiftwidth =3D &shiftwidth
+ let b:cobol_shiftwidth =3D s:Shiftwidth()
let &shiftwidth =3D 1
let lastchar =3D strpart(getline('.'),col('.')-2,1)
if lastchar =3D=3D '0' || lastchar =3D=3D '^'
@@ -205,7 +213,7 @@
endif
endif
let interval =3D s:decrease()
- let b:cobol_shiftwidth =3D &shiftwidth
+ let b:cobol_shiftwidth =3D s:Shiftwidth()
let &shiftwidth =3D 1
return s:repeat(c,interval)
endfunction
@@ -221,7 +229,7 @@
function! s:Tab()
if (strpart(getline('.'),0,col('.')-1) =3D~ '^\s*$' && &sta)
return s:IncreaseIndent()
- elseif &sts =3D=3D &sw && &sts !=3D 8 && &et
+ elseif &sts =3D=3D s:Shiftwidth() && &sts !=3D 8 && &et
return s:repeat(" ",s:increase(col('.')-1))
else
return "\<Tab>"
diff -r eccc57e1caa0 runtime/indent/ada.vim
--- a/runtime/indent/ada.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/ada.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -29,6 +29,14 @@
finish
endif
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
let b:did_indent =3D 45
=20
setlocal indentexpr=3DGetAdaIndent()
@@ -87,7 +95,7 @@
endwhile
endwhile
" Fallback - just move back one
- return a:prev_indent - &sw
+ return a:prev_indent - s:Shiftwidth()
endfunction MainBlockIndent
=20
" Section: s:EndBlockIndent {{{1
@@ -131,7 +139,7 @@
endwhile
endwhile
" Fallback - just move back one
- return a:prev_indent - &sw
+ return a:prev_indent - s:Shiftwidth()
endfunction EndBlockIndent
=20
" Section: s:StatementIndent {{{1
@@ -213,15 +221,15 @@
endif
" Move indent in
if ! false_match
-=09 let ind =3D ind + &sw
+=09 let ind =3D ind + s:Shiftwidth()
endif
elseif line =3D~ '^\s*\(case\|exception\)\>'
" Move indent in twice (next 'when' will move back)
- let ind =3D ind + 2 * &sw
+ let ind =3D ind + 2 * s:Shiftwidth()
elseif line =3D~ '^\s*end\s*record\>'
" Move indent back to tallying 'type' preceeding the 'record'.
" Allow indent to be equal to 'end record's.
- let ind =3D s:MainBlockIndent( ind+&sw, lnum, 'type\>', '' )
+ let ind =3D s:MainBlockIndent( ind+s:Shiftwidth(), lnum, 'type\>', '=
' )
elseif line =3D~ '\(^\s*new\>.*\)\@<!)\s*[;,]\s*$'
" Revert to indent of line that started this parenthesis pair
exe lnum
@@ -235,10 +243,10 @@
exe v:lnum
elseif line =3D~ '[.=3D(]\s*$'
" A statement continuation - move in one
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
elseif line =3D~ '^\s*new\>'
" Multiple line generic instantiation ('package blah is\nnew thingy'=
)
- let ind =3D s:StatementIndent( ind - &sw, lnum )
+ let ind =3D s:StatementIndent( ind - s:Shiftwidth(), lnum )
elseif line =3D~ ';\s*$'
" Statement end (but not 'end' ) - try to find current statement-sta=
rt indent
let ind =3D s:StatementIndent( ind, lnum )
@@ -256,17 +264,17 @@
elseif continuation && line =3D~ '^\s*('
" Don't do this if we've already indented due to the previous line
if ind =3D=3D initind
-=09 let ind =3D ind + &sw
+=09 let ind =3D ind + s:Shiftwidth()
endif
elseif line =3D~ '^\s*\(begin\|is\)\>'
let ind =3D s:MainBlockIndent( ind, lnum, '\(procedure\|function\|de=
clare\|package\|task\)\>', 'begin\>' )
elseif line =3D~ '^\s*record\>'
- let ind =3D s:MainBlockIndent( ind, lnum, 'type\>\|for\>.*\<use\>', =
'' ) + &sw
+ let ind =3D s:MainBlockIndent( ind, lnum, 'type\>\|for\>.*\<use\>', =
'' ) + s:Shiftwidth()
elseif line =3D~ '^\s*\(else\|elsif\)\>'
let ind =3D s:MainBlockIndent( ind, lnum, 'if\>', '' )
elseif line =3D~ '^\s*when\>'
" Align 'when' one /in/ from matching block start
- let ind =3D s:MainBlockIndent( ind, lnum, '\(case\|exception\)\>', '=
' ) + &sw
+ let ind =3D s:MainBlockIndent( ind, lnum, '\(case\|exception\)\>', '=
' ) + s:Shiftwidth()
elseif line =3D~ '^\s*end\>\s*\<if\>'
" End of if statements
let ind =3D s:EndBlockIndent( ind, lnum, 'if\>', 'end\>\s*\<if\>' )
diff -r eccc57e1caa0 runtime/indent/awk.vim
--- a/runtime/indent/awk.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/awk.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -30,6 +30,14 @@
finish
endif
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
let b:did_indent =3D 1
=20
setlocal indentexpr=3DGetAwkIndent()
@@ -60,7 +68,7 @@
" 'pattern { action }' (simple check match on /{/ increases the indent =
then)
=20
if s:Get_brace_balance( prev_data, '{', '}' ) > 0
- return ind + &sw
+ return ind + s:Shiftwidth()
endif
=20
let brace_balance =3D s:Get_brace_balance( prev_data, '(', ')' )
@@ -99,7 +107,7 @@
=09 return s:Safe_indent( ind, s:First_word_len(prev_data), getline(v:lnu=
m))
else
=09 " if/for/while without '{'
-=09 return ind + &sw
+=09 return ind + s:Shiftwidth()
endif
endif
endif
@@ -140,7 +148,7 @@
=20
" Decrease indent if this line contains a '}'.
if getline(v:lnum) =3D~ '^\s*}'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
=20
return ind
diff -r eccc57e1caa0 runtime/indent/bst.vim
--- a/runtime/indent/bst.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/bst.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -8,6 +8,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal expandtab
setlocal indentexpr=3DGetBstIndent(v:lnum)
"setlocal smartindent
@@ -69,7 +77,7 @@
endif
let fakeline =3D substitute(line,'^}','','').matchstr(cline,'^}')
let ind =3D indent(lnum)
- let ind =3D ind + &sw * s:count(line,'{')
- let ind =3D ind - &sw * s:count(fakeline,'}')
+ let ind =3D ind + s:Shiftwidth() * s:count(line,'{')
+ let ind =3D ind - s:Shiftwidth() * s:count(fakeline,'}')
return ind
endfunction
diff -r eccc57e1caa0 runtime/indent/cdl.vim
--- a/runtime/indent/cdl.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/cdl.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -7,6 +7,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentexpr=3DCdlGetIndent(v:lnum)
setlocal indentkeys&
setlocal indentkeys+=3D=3D~else,=3D~endif,=3D~then,;,),=3D
@@ -47,7 +55,7 @@
let thisline =3D getline(a:lnum)
if match(thisline, '^\s*\(\k\+\|\[[^]]*]\)\s*\(,\|;\s*$\)') >=3D 0
" it's an attributes line
- return &sw
+ return s:Shiftwidth()
elseif match(thisline, '^\c\s*\([{}]\|\/[*/]\|dimension\|schedule\|group=
\|hierarchy\|class\)') >=3D 0
" it's a header or '{' or '}' or a comment
return 0
@@ -71,13 +79,13 @@
let c =3D line[inicio-1]
" ')' and '=3D' don't change indent and are useless to set 'f'
if c =3D=3D '{'
- return &sw
+ return s:Shiftwidth()
elseif c !=3D ')' && c !=3D '=3D'
let f =3D 1 " all but 'elseif' are followed by a formula
if c =3D=3D? 'n' || c =3D=3D? 'e' " 'then', 'else'
-=09let ind =3D ind + &sw
+=09let ind =3D ind + s:Shiftwidth()
elseif strpart(line, inicio-6, 6) =3D=3D? 'elseif' " elseif, set f t=
o conditional
-=09let ind =3D ind + &sw
+=09let ind =3D ind + s:Shiftwidth()
=09let f =3D 0
end
end
@@ -98,16 +106,16 @@
let ind =3D 0
let f =3D 1
elseif c =3D=3D ')' || c=3D=3D ';' || strpart(line, inicio-5, 5) =3D=
=3D? 'endif'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
elseif c =3D=3D '(' || c =3D=3D? 'f' " '(' or 'if'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
else " c =3D=3D '=3D'
" if it is an asignment increase indent
if f =3D=3D -1 " we don't know yet, find out
=09let f =3D CdlAsignment(lnum, strpart(line, 0, inicio))
end
if f =3D=3D 1 " formula increase it
-=09let ind =3D ind + &sw
+=09let ind =3D ind + s:Shiftwidth()
end
end
endw
@@ -115,13 +123,13 @@
" CURRENT LINE, if it starts with a closing element, decrease indent
" or if it starts with '=3D' (asignment), increase indent
if match(thisline, '^\c\s*\(else\|then\|endif\|[);]\)') >=3D 0
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
elseif match(thisline, '^\s*=3D') >=3D 0
if f =3D=3D -1 " we don't know yet if is an asignment, find out
let f =3D CdlAsignment(lnum, "")
end
if f =3D=3D 1 " formula increase it
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
end
end
=20
diff -r eccc57e1caa0 runtime/indent/chaiscript.vim
--- a/runtime/indent/chaiscript.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/chaiscript.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -8,6 +8,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentexpr=3DGetChaiScriptIndent()
setlocal autoindent
=20
@@ -31,19 +39,19 @@
let flag =3D 0
let prevline =3D getline(lnum)
if prevline =3D~ '^.*{.*'
- let ind =3D ind + &shiftwidth
+ let ind =3D ind + s:Shiftwidth()
let flag =3D 1
endif
=20
" Subtract a 'shiftwidth' after lines containing a { followed by a }
" to keep it balanced
if flag =3D=3D 1 && prevline =3D~ '.*{.*}.*'
- let ind =3D ind - &shiftwidth
+ let ind =3D ind - s:Shiftwidth()
endif
=20
" Subtract a 'shiftwidth' on lines ending with }
if getline(v:lnum) =3D~ '^\s*\%(}\)'
- let ind =3D ind - &shiftwidth
+ let ind =3D ind - s:Shiftwidth()
endif
=20
return ind
diff -r eccc57e1caa0 runtime/indent/cmake.vim
--- a/runtime/indent/cmake.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/cmake.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -16,6 +16,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentexpr=3DCMakeGetIndent(v:lnum)
setlocal indentkeys+=3D=3DENDIF(,ENDFOREACH(,ENDMACRO(,ELSE(,ELSEIF(,ENDWH=
ILE(
=20
@@ -68,19 +76,19 @@
let ind =3D ind
else
if previous_line =3D~? cmake_indent_begin_regex
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
if previous_line =3D~? cmake_indent_open_regex
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
endif
=20
" Subtract
if this_line =3D~? cmake_indent_end_regex
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
if previous_line =3D~? cmake_indent_close_regex
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
=20
return ind
diff -r eccc57e1caa0 runtime/indent/cobol.vim
--- a/runtime/indent/cobol.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/cobol.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -8,6 +8,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal expandtab
setlocal indentexpr=3DGetCobolIndent(v:lnum)
setlocal indentkeys&
@@ -52,11 +60,11 @@
if getline(lastclause) =3D~? clauses && s:stripped(lastclause) !~?=
'^'.begin
let ind =3D indent(lastclause)
elseif lastclause > 0
- let ind =3D indent(lastclause) + &sw
- "let ind =3D ind + &sw
+ let ind =3D indent(lastclause) + s:Shiftwidth()
+ "let ind =3D ind + s:Shiftwidth()
endif
elseif line =3D~? clauses && cline !~? end
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
return ind
endfunction
@@ -98,8 +106,8 @@
let num =3D matchstr(line,'^\s*\zs\d\+\>')
if 0+cnum =3D=3D num
return lindent
- elseif 0+cnum > num && default < lindent + &sw
- let default =3D lindent + &sw
+ elseif 0+cnum > num && default < lindent + s:Shiftwidth()
+ let default =3D lindent + s:Shiftwidth()
endif
elseif lindent < bshft && lindent >=3D ashft
break
@@ -135,13 +143,13 @@
if line =3D~? '^PERFORM\>'
let perfline =3D substitute(line, '\c^PERFORM\s*', "", "")
if perfline =3D~? '^\%(\k\+\s\+TIMES\)\=3D\s*$'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
elseif perfline =3D~? '^\%(WITH\s\+TEST\|VARYING\|UNTIL\)\>.*[^.]$=
'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
endif
if line =3D~? '^\%(IF\|THEN\|ELSE\|READ\|EVALUATE\|SEARCH\|SELECT\)\>'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
let ind =3D s:optionalblock(a:lnum,ind,'ADD\|COMPUTE\|DIVIDE\|MULTIPLY=
\|SUBTRACT','ON\s\+SIZE\s\+ERROR')
let ind =3D s:optionalblock(a:lnum,ind,'STRING\|UNSTRING\|ACCEPT\|DISP=
LAY\|CALL','ON\s\+OVERFLOW\|ON\s\+EXCEPTION')
@@ -157,10 +165,10 @@
"&& s:stripped(lastclause) !~? '^\%(SEARCH\|EVALUATE\|READ\)\>=
'
let ind =3D indent(lastclause)
elseif lastclause > 0
- let ind =3D indent(lastclause) + &sw
+ let ind =3D indent(lastclause) + s:Shiftwidth()
endif
elseif line =3D~? '^WHEN\>'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
"I'm not sure why I had this
"if line =3D~? '^ELSE\>-\@!' && line !~? '\.$'
@@ -168,7 +176,7 @@
"endif
if cline =3D~? '^\(END\)\>-\@!'
" On lines with just END, 'guess' a simple shift left
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
elseif cline =3D~? '^\(END-IF\|THEN\|ELSE\)\>-\@!'
call cursor(a:lnum,indent(a:lnum))
let match =3D searchpair('\c-\@<!\<IF\>','\c-\@<!\%(THEN\|ELSE\)\>=
','\c-\@<!\<END-IF\>\zs','bnW',s:skip)
@@ -209,7 +217,7 @@
if match > 0
let ind =3D indent(match)
elseif cline =3D~? '^\(END-\(READ\|EVALUATE\|SEARCH\|PERFORM\)\)\>=
'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
endif
return ind < bshft ? bshft : ind
diff -r eccc57e1caa0 runtime/indent/css.vim
--- a/runtime/indent/css.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/css.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -8,6 +8,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentexpr=3DGetCSSIndent()
setlocal indentkeys=3D0{,0},!^F,o,O
setlocal nosmartindent
@@ -75,8 +83,8 @@
return 0
endif
=20
- return indent(pnum) + s:count_braces(pnum, 1) * &sw
- \ - s:count_braces(v:lnum, 0) * &sw
+ return indent(pnum) + s:count_braces(pnum, 1) * s:Shiftwidth()
+ \ - s:count_braces(v:lnum, 0) * s:Shiftwidth()
endfunction
=20
let &cpo =3D s:keepcpo
diff -r eccc57e1caa0 runtime/indent/cucumber.vim
--- a/runtime/indent/cucumber.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/cucumber.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -8,6 +8,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal autoindent
setlocal indentexpr=3DGetCucumberIndent()
setlocal indentkeys=3Do,O,*<Return>,<:>,0<Bar>,0#,=3D,!^F
@@ -29,28 +37,28 @@
if csyn =3D=3D# 'cucumberFeature' || cline =3D~# '^\s*Feature:'
return 0
elseif csyn =3D=3D# 'cucumberExamples' || cline =3D~# '^\s*\%(Examples\|=
Scenarios\):'
- return 2 * &sw
+ return 2 * s:Shiftwidth()
elseif csyn =3D~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$'=
|| cline =3D~# '^\s*\%(Background\|Scenario\|Scenario Outline\):'
- return &sw
+ return s:Shiftwidth()
elseif syn =3D=3D# 'cucumberFeature' || line =3D~# '^\s*Feature:'
- return &sw
+ return s:Shiftwidth()
elseif syn =3D=3D# 'cucumberExamples' || line =3D~# '^\s*\%(Examples\|Sc=
enarios\):'
- return 3 * &sw
+ return 3 * s:Shiftwidth()
elseif syn =3D~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$' =
|| line =3D~# '^\s*\%(Background\|Scenario\|Scenario Outline\):'
- return 2 * &sw
+ return 2 * s:Shiftwidth()
elseif cline =3D~# '^\s*@' && (s:syn(nextnonblank(v:lnum+1)) =3D=3D 'cuc=
umberFeature' || getline(nextnonblank(v:lnum+1)) =3D~# '^\s*Feature:' || in=
dent(prevnonblank(v:lnum-1)) <=3D 0)
return 0
elseif line =3D~# '^\s*@'
- return &sw
+ return s:Shiftwidth()
elseif cline =3D~# '^\s*|' && line =3D~# '^\s*|'
return indent(prevnonblank(v:lnum-1))
elseif cline =3D~# '^\s*|' && line =3D~# '^\s*[^|#]'
- return indent(prevnonblank(v:lnum-1)) + &sw
+ return indent(prevnonblank(v:lnum-1)) + s:Shiftwidth()
elseif cline =3D~# '^\s*[^|# \t]' && line =3D~# '^\s*|'
- return indent(prevnonblank(v:lnum-1)) - &sw
+ return indent(prevnonblank(v:lnum-1)) - s:Shiftwidth()
elseif cline =3D~# '^\s*$' && line =3D~# '^\s*|'
let in =3D indent(prevnonblank(v:lnum-1))
- return in =3D=3D indent(v:lnum) ? in : in - &sw
+ return in =3D=3D indent(v:lnum) ? in : in - s:Shiftwidth()
elseif cline =3D~# '^\s*#' && getline(v:lnum-1) =3D~ '^\s*$' && getline(=
v:lnum+1) =3D~# '\S'
return indent(getline(v:lnum+1))
endif
diff -r eccc57e1caa0 runtime/indent/dtd.vim
--- a/runtime/indent/dtd.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/dtd.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -14,6 +14,14 @@
finish
endif
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
" TODO: Needs to be adjusted to stop at [, <, and ].
let s:token_pattern =3D '^[^[:space:]]\+'
=20
@@ -84,7 +92,7 @@
=20
let [declaration, end] =3D s:lex1(line, col)
if declaration =3D=3D ""
- return indent + &sw
+ return indent + s:Shiftwidth()
elseif declaration =3D=3D '--'
" We?re looking at a comment. Now, simply determine if the comment is
" terminated or not. If it isn?t, let Vim take care of that using
@@ -100,7 +108,7 @@
" Check for element name. If none exists, indent one level.
let [name, end] =3D s:lex(line, end)
if name =3D=3D ""
- return indent + &sw
+ return indent + s:Shiftwidth()
endif
=20
" Check for token following element name. This can be a specification=
of
@@ -113,7 +121,7 @@
let n +=3D 1
endwhile
if token =3D=3D ""
- return indent + &sw
+ return indent + s:Shiftwidth()
endif
=20
" Next comes the content model. If the token we?ve found isn?t a
@@ -148,7 +156,7 @@
return indent
endif
" TODO: Should use s:lex here on getline(v:lnum) and check for >.
- return getline(v:lnum) =3D~ '^\s*>' || count(values(seen), 0) =3D=
=3D 0 ? indent : (indent + &sw)
+ return getline(v:lnum) =3D~ '^\s*>' || count(values(seen), 0) =3D=
=3D 0 ? indent : (indent + s:Shiftwidth())
endif
=20
" If we?ve seen an addition or exception already and this is of the =
same
@@ -167,7 +175,7 @@
" Check for element name. If none exists, indent one level.
let [name, end] =3D s:lex(line, end)
if name =3D=3D ""
- return indent + &sw
+ return indent + s:Shiftwidth()
endif
=20
" Check for any number of attributes.
@@ -180,7 +188,7 @@
let [name, end] =3D s:lex(line, end)
if name =3D=3D ""
" TODO: Should use s:lex here on getline(v:lnum) and check for >.
- return getline(v:lnum) =3D~ '^\s*>' ? indent : (indent + &sw)
+ return getline(v:lnum) =3D~ '^\s*>' ? indent : (indent + s:Shiftwi=
dth())
elseif name =3D=3D ">"
return indent
endif
@@ -194,14 +202,14 @@
" (CDATA|NMTOKEN|NMTOKENS|ID|IDREF|IDREFS|ENTITY|ENTITIES)?
let [value, end] =3D s:lex(line, end, '^\%((\|[^[:space:]]\+\)')
if value =3D=3D ""
- return indent + &sw * 2
+ return indent + s:Shiftwidth() * 2
elseif value =3D=3D 'NOTATION'
" If this is a enumerated value based on notations, read another t=
oken
" for the actual value. If it doesn?t exist, indent three levels.
" TODO: If validating according to above, value must be equal to '=
('.
let [value, end] =3D s:lex(line, end, '^\%((\|[^[:space:]]\+\)')
if value =3D=3D ""
- return indent + &sw * 3
+ return indent + s:Shiftwidth() * 3
endif
endif
=20
@@ -216,13 +224,13 @@
" two levels.
let [default, end] =3D s:lex(line, end, '^\%("\_[^"]*"\|#\(REQUIRED\=
|IMPLIED\|FIXED\)\)')
if default =3D=3D ""
- return indent + &sw * 2
+ return indent + s:Shiftwidth() * 2
elseif default =3D=3D '#FIXED'
" We need to look for the fixed value. If non exists, indent thre=
e
" levels.
let [default, end] =3D s:lex(line, end, '^"\_[^"]*"')
if default =3D=3D ""
- return indent + &sw * 3
+ return indent + s:Shiftwidth() * 3
endif
endif
endwhile
@@ -233,11 +241,11 @@
" again, if none exists, indent one level.
let [name, end] =3D s:lex(line, end)
if name =3D=3D ""
- return indent + &sw
+ return indent + s:Shiftwidth()
elseif name =3D=3D '%'
let [name, end] =3D s:lex(line, end)
if name =3D=3D ""
- return indent + &sw
+ return indent + s:Shiftwidth()
endif
endif
=20
@@ -256,27 +264,27 @@
" we?re now done with this entity.
let [value, end] =3D s:lex(line, end)
if value =3D=3D ""
- return indent + &sw
+ return indent + s:Shiftwidth()
elseif value =3D=3D 'SYSTEM' || value =3D=3D 'PUBLIC'
let [quoted_string, end] =3D s:lex(line, end, '\%("[^"]\+"\|''[^'']\=
+''\)')
if quoted_string =3D=3D ""
- return indent + &sw * 2
+ return indent + s:Shiftwidth() * 2
endif
=20
if value =3D=3D 'PUBLIC'
let [quoted_string, end] =3D s:lex(line, end, '\%("[^"]\+"\|''[^''=
]\+''\)')
if quoted_string =3D=3D ""
- return indent + &sw * 2
+ return indent + s:Shiftwidth() * 2
endif
endif
=20
let [ndata, end] =3D s:lex(line, end)
if ndata =3D=3D ""
- return indent + &sw
+ return indent + s:Shiftwidth()
endif
=20
let [name, end] =3D s:lex(line, end)
- return name =3D=3D "" ? (indent + &sw * 2) : indent
+ return name =3D=3D "" ? (indent + s:Shiftwidth() * 2) : indent
else
return indent
endif
@@ -284,24 +292,24 @@
" Check for notation name. If none exists, indent one level.
let [name, end] =3D s:lex(line, end)
if name =3D=3D ""
- return indent + &sw
+ return indent + s:Shiftwidth()
endif
=20
" Now check for the external ID. If none exists, indent one level.
let [id, end] =3D s:lex(line, end)
if id =3D=3D ""
- return indent + &sw
+ return indent + s:Shiftwidth()
elseif id =3D=3D 'SYSTEM' || id =3D=3D 'PUBLIC'
let [quoted_string, end] =3D s:lex(line, end, '\%("[^"]\+"\|''[^'']\=
+''\)')
if quoted_string =3D=3D ""
- return indent + &sw * 2
+ return indent + s:Shiftwidth() * 2
endif
=20
if id =3D=3D 'PUBLIC'
let [quoted_string, end] =3D s:lex(line, end, '\%("[^"]\+"\|''[^''=
]\+''\|>\)')
if quoted_string =3D=3D ""
" TODO: Should use s:lex here on getline(v:lnum) and check for >=
.
- return getline(v:lnum) =3D~ '^\s*>' ? indent : (indent + &sw * 2=
)
+ return getline(v:lnum) =3D~ '^\s*>' ? indent : (indent + s:Shift=
width() * 2)
elseif quoted_string =3D=3D '>'
return indent
endif
diff -r eccc57e1caa0 runtime/indent/dylan.vim
--- a/runtime/indent/dylan.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/dylan.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -10,6 +10,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentkeys+=3D=3D~begin,=3D~block,=3D~case,=3D~cleanup,=3D~define=
,=3D~end,=3D~else,=3D~elseif,=3D~exception,=3D~for,=3D~finally,=3D~if,=3D~o=
therwise,=3D~select,=3D~unless,=3D~while
=20
" Define the appropriate indent function but only once
@@ -45,13 +53,13 @@
=20
" If previous line was a 'define', indent
if prevline =3D~? '\(^\s*\(begin\|block\|case\|define\|else\|elseif\|for=
\|finally\|if\|select\|unless\|while\)\|\s*\S*\s*=3D>$\)'
- let chg =3D &sw
+ let chg =3D s:Shiftwidth()
" local methods indent the shift-width, plus 6 for the 'local'
elseif prevline =3D~? '^\s*local'
- let chg =3D &sw + 6
+ let chg =3D s:Shiftwidth() + 6
" If previous line was a let with no closing semicolon, indent
elseif prevline =3D~? '^\s*let.*[^;]\s*$'
- let chg =3D &sw
+ let chg =3D s:Shiftwidth()
" If previous line opened a parenthesis, and did not close it, indent
elseif prevline =3D~ '^.*(\s*[^)]*\((.*)\)*[^)]*$'
return =3D match( prevline, '(.*\((.*)\|[^)]\)*.*$') + 1
@@ -75,13 +83,13 @@
" line doesn't start with an indentable command:
let curr_str =3D getline(curr_line)
if curr_str =3D~? '^\s*\(begin\|block\|case\|define\|else\|elseif\|for=
\|finally\|if\|select\|unless\|while\)'
- let chg =3D &sw
+ let chg =3D s:Shiftwidth()
endif
endif
=20
" If a line starts with end, un-indent (even if we just indented!)
if cline =3D~? '^\s*\(cleanup\|end\|else\|elseif\|exception\|finally\|ot=
herwise\)'
- let chg =3D chg - &sw
+ let chg =3D chg - s:Shiftwidth()
endif
=20
return ind + chg
diff -r eccc57e1caa0 runtime/indent/eiffel.vim
--- a/runtime/indent/eiffel.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/eiffel.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -13,6 +13,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentexpr=3DGetEiffelIndent()
setlocal nolisp
setlocal nosmartindent
@@ -63,23 +71,23 @@
" Add a 'shiftwidth' after lines that start with an indent word
let ind =3D indent(lnum)
if getline(lnum) =3D~ s:relative_indent
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
=20
" Indent to single indent
if getline(v:lnum) =3D~ s:single_dent && getline(v:lnum) !~ s:relative_i=
ndent
=09 \ && getline(v:lnum) !~ '\s*\<\(and\|or\|implies\)\>'
- let ind =3D &sw
+ let ind =3D s:Shiftwidth()
endif
=20
" Indent to double indent
if getline(v:lnum) =3D~ s:inheritance_dent
- let ind =3D 2 * &sw
+ let ind =3D 2 * s:Shiftwidth()
endif
=20
" Indent line after the first line of the function definition
if getline(lnum) =3D~ s:single_dent
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
=20
" The following should always be at the start of a line, no indenting
@@ -91,17 +99,17 @@
" or first thing after the 'do'
if getline(v:lnum) =3D~ s:outdent && getline(v:lnum - 1) !~ s:single_den=
t
=09\ && getline(v:lnum - 1) !~ '^\s*do\>'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
=20
" Subtract a shiftwidth for end statements
if getline(v:lnum) =3D~ '^\s*end\>'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
=20
" set indent of zero end statements that are at an indent of 3, this sho=
uld
" only ever be the class's end.
- if getline(v:lnum) =3D~ '^\s*end\>' && ind =3D=3D &sw
+ if getline(v:lnum) =3D~ '^\s*end\>' && ind =3D=3D s:Shiftwidth()
let ind =3D 0
endif
=20
diff -r eccc57e1caa0 runtime/indent/erlang.vim
--- a/runtime/indent/erlang.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/erlang.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -14,6 +14,14 @@
let b:did_indent =3D 1
endif
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentexpr=3DErlangIndent()
setlocal indentkeys+=3D=3Dafter,=3Dend,=3Dcatch,=3D),=3D],=3D}
=20
@@ -155,7 +163,7 @@
" lnum: line number
" return: the indentation level of the line
function s:GetLineIndent(lnum)
- return (indent(a:lnum) / &sw) * &sw
+ return (indent(a:lnum) / s:Shiftwidth()) * s:Shiftwidth()
endfunction
=20
function ErlangIndent()
@@ -172,38 +180,38 @@
=20
let ind_after =3D s:ErlangIndentAfterLine(prevline)
if ind_after !=3D 0
- let ind =3D s:GetLineIndent(lnum) + ind_after * &sw
+ let ind =3D s:GetLineIndent(lnum) + ind_after * s:Shiftwidth()
else
- let ind =3D indent(lnum) + ind_after * &sw
+ let ind =3D indent(lnum) + ind_after * s:Shiftwidth()
endif
=20
" Special cases:
if prevline =3D~# '^\s*\%(after\|end\)\>'
- let ind =3D ind + 2*&sw
+ let ind =3D ind + 2*s:Shiftwidth()
endif
if currline =3D~# '^\s*end\>'
- let ind =3D ind - 2*&sw
+ let ind =3D ind - 2*s:Shiftwidth()
endif
if currline =3D~# '^\s*after\>'
let plnum =3D s:FindPrevNonBlankNonComment(v:lnum-1)
if getline(plnum) =3D~# '^[^%]*\<receive\>\s*\%(%.*\)\=3D$'
" If the 'receive' is not in the same line as the 'after'
- let ind =3D ind - 1*&sw
+ let ind =3D ind - 1*s:Shiftwidth()
else
- let ind =3D ind - 2*&sw
+ let ind =3D ind - 2*s:Shiftwidth()
endif
endif
if prevline =3D~# '^\s*[)}\]]'
- let ind =3D ind + 1*&sw
+ let ind =3D ind + 1*s:Shiftwidth()
endif
if currline =3D~# '^\s*[)}\]]'
- let ind =3D ind - 1*&sw
+ let ind =3D ind - 1*s:Shiftwidth()
endif
if prevline =3D~# '^\s*\%(catch\)\s*\%(%\|$\)'
- let ind =3D ind + 1*&sw
+ let ind =3D ind + 1*s:Shiftwidth()
endif
if currline =3D~# '^\s*\%(catch\)\s*\%(%\|$\)'
- let ind =3D ind - 1*&sw
+ let ind =3D ind - 1*s:Shiftwidth()
endif
=20
if ind<0
diff -r eccc57e1caa0 runtime/indent/eruby.vim
--- a/runtime/indent/eruby.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/eruby.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -10,6 +10,14 @@
finish
endif
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
runtime! indent/ruby.vim
unlet! b:did_indent
setlocal indentexpr=3D
@@ -59,21 +67,21 @@
let line =3D getline(lnum)
let cline =3D getline(v:lnum)
if cline =3D~# '^\s*<%-\=3D\s*\%(}\|end\|else\|\%(ensure\|rescue\|elsif\=
|when\).\{-\}\)\s*\%(-\=3D%>\|$\)'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
if line =3D~# '\S\s*<%-\=3D\s*\%(}\|end\).\{-\}\s*\%(-\=3D%>\|$\)'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
if line =3D~# '\%({\|\<do\)\%(\s*|[^|]*|\)\=3D\s*-\=3D%>'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
elseif line =3D~# '<%-\=3D\s*\%(module\|class\|def\|if\|for\|while\|unti=
l\|else\|elsif\|case\|when\|unless\|begin\|ensure\|rescue\)\>.*%>'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
if line =3D~# '^\s*<%[=3D#-]\=3D\s*$' && cline !~# '^\s*end\>'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
if cline =3D~# '^\s*-\=3D%>\s*$'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
return ind
endfunction
diff -r eccc57e1caa0 runtime/indent/eterm.vim
--- a/runtime/indent/eterm.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/eterm.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -8,6 +8,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentexpr=3DGetEtermIndent()
setlocal indentkeys=3D!^F,o,O,=3Dend
setlocal nosmartindent
@@ -25,11 +33,11 @@
let ind =3D indent(lnum)
=20
if getline(lnum) =3D~ '^\s*begin\>'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
=20
if getline(v:lnum) =3D~ '^\s*end\>'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
=20
return ind
diff -r eccc57e1caa0 runtime/indent/falcon.vim
--- a/runtime/indent/falcon.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/falcon.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -17,6 +17,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal nosmartindent
=20
" Setup indent function and when to use it
@@ -92,23 +100,23 @@
" If the start of the line equals a double quote, then indent to the
" previous lines first double quote
if cline =3D~? '^\s*"'
- let chg =3D chg + &sw
+ let chg =3D chg + s:Shiftwidth()
endif
=20
" If previous line started with a double quote and this one
" doesn't, unindent
if prevline =3D~? '^\s*"' && cline =3D~? '^\s*'
- let chg =3D chg - &sw
+ let chg =3D chg - s:Shiftwidth()
endif
=20
" Indent if proper keyword
if prevline =3D~? s:falcon_indent_keywords
- let chg =3D &sw
+ let chg =3D s:Shiftwidth()
" If previous line opened a parenthesis, and did not close it, indent
elseif prevline =3D~ '^.*(\s*[^)]*\((.*)\)*[^)]*$'
" Make sure this isn't just a function split between two lines
if prevline =3D~ ',\s*$'
- return indent(prevnonblank(v:lnum - 1)) + &sw
+ return indent(prevnonblank(v:lnum - 1)) + s:Shiftwidth()
else
return match(prevline, '(.*\((.*)\|[^)]\)*.*$') + 1
endif
@@ -132,22 +140,22 @@
" If previous line ends in a semi-colon reset indent to previous
" lines setting
if prevline =3D~? ';\s*$' && prevnonblank(prevline) =3D~? ',\s*$'
- return chg =3D chg - (2 * &sw)
+ return chg =3D chg - (2 * s:Shiftwidth())
endif
=20
" If previous line ended in a comma, indent again
if prevline =3D~? ',\s*$'
- let chg =3D chg + &sw
+ let chg =3D chg + s:Shiftwidth()
endif
=20
" If previous line ended in a =3D>, indent again
if prevline =3D~? '=3D>\s*$'
- let chg =3D chg + &sw
+ let chg =3D chg + s:Shiftwidth()
endif
=20
" Deindent on proper keywords
if cline =3D~? s:falcon_deindent_keywords
- let chg =3D chg - &sw
+ let chg =3D chg - s:Shiftwidth()
endif
=20
return ind + chg
diff -r eccc57e1caa0 runtime/indent/fortran.vim
--- a/runtime/indent/fortran.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/fortran.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -11,6 +11,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
let s:cposet=3D&cpoptions
set cpoptions&vim
=20
@@ -81,10 +89,10 @@
"Indent do loops only if they are all guaranteed to be of do/end do type
if exists("b:fortran_do_enddo") || exists("g:fortran_do_enddo")
if prevstat =3D~? '^\s*\(\d\+\s\)\=3D\s*\(\a\w*\s*:\)\=3D\s*do\>'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
if getline(v:lnum) =3D~? '^\s*\(\d\+\s\)\=3D\s*end\s*do\>'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
endif
=20
@@ -94,14 +102,14 @@
=09\ ||prevstat=3D~? '^\s*\(type\|interface\|associate\|enum\)\>'
=09\ ||prevstat=3D~?'^\s*\(\d\+\s\)\=3D\s*\(\a\w*\s*:\)\=3D\s*\(forall\|wh=
ere\|block\)\>'
=09\ ||prevstat=3D~? '^\s*\(\d\+\s\)\=3D\s*\(\a\w*\s*:\)\=3D\s*if\>'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
" Remove unwanted indent after logical and arithmetic ifs
if prevstat =3D~? '\<if\>' && prevstat !~? '\<then\>'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
" Remove unwanted indent after type( statements
if prevstat =3D~? '^\s*type\s*('
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
endif
=20
@@ -114,12 +122,12 @@
\ ||prevstat =3D~? '^\s*'.prefix.'subroutine\>'
\ ||prevstat =3D~? '^\s*'.prefix.type.'function\>'
\ ||prevstat =3D~? '^\s*'.type.prefix.'function\>'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
if getline(v:lnum) =3D~? '^\s*contains\>'
\ ||getline(v:lnum)=3D~? '^\s*end\s*'
\ .'\(function\|subroutine\|module\|program\)\>'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
endif
=20
@@ -130,20 +138,20 @@
\. '\(else\|else\s*if\|else\s*where\|case\|'
\. 'end\s*\(if\|where\|select\|interface\|'
\. 'type\|forall\|associate\|enum\)\)\>'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
" Fix indent for case statement immediately after select
if prevstat =3D~? '\<select\s\+\(case\|type\)\>'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
endif
=20
"First continuation line
if prevstat =3D~ '&\s*$' && prev2stat !~ '&\s*$'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
"Line after last continuation line
if prevstat !~ '&\s*$' && prev2stat =3D~ '&\s*$'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
=20
return ind
diff -r eccc57e1caa0 runtime/indent/framescript.vim
--- a/runtime/indent/framescript.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/framescript.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -8,6 +8,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentexpr=3DGetFrameScriptIndent()
setlocal indentkeys=3D!^F,o,O,0=3D~Else,0=3D~EndIf,0=3D~EndLoop,0=3D~EndSu=
b
setlocal nosmartindent
@@ -30,11 +38,11 @@
let ind =3D indent(lnum)
=20
if getline(lnum) =3D~? '^\s*\%(If\|Loop\|Sub\)'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
=20
if getline(v:lnum) =3D~? '^\s*\%(Else\|End\%(If\|Loop\|Sub\)\)'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
=20
return ind
diff -r eccc57e1caa0 runtime/indent/gitconfig.vim
--- a/runtime/indent/gitconfig.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/gitconfig.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -8,6 +8,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal autoindent
setlocal indentexpr=3DGetGitconfigIndent()
setlocal indentkeys=3Do,O,*<Return>,0[,],0;,0#,=3D,!^F
@@ -24,13 +32,13 @@
let cline =3D getline(v:lnum)
if line =3D~ '\\\@<!\%(\\\\\)*\\$'
" odd number of slashes, in a line continuation
- return 2 * &sw
+ return 2 * s:Shiftwidth()
elseif cline =3D~ '^\s*\['
return 0
elseif cline =3D~ '^\s*\a'
- return &sw
+ return s:Shiftwidth()
elseif cline =3D=3D '' && line =3D~ '^\['
- return &sw
+ return s:Shiftwidth()
else
return -1
endif
diff -r eccc57e1caa0 runtime/indent/gitolite.vim
--- a/runtime/indent/gitolite.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/gitolite.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -9,6 +9,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal autoindent
setlocal indentexpr=3DGetGitoliteIndent()
setlocal indentkeys=3Do,O,*<Return>,!^F,=3Drepo,\",=3D
@@ -27,11 +35,11 @@
let cline =3D getline(v:lnum)
=20
if cline =3D~ '^\s*\(C\|R\|RW\|RW+\|RWC\|RW+C\|RWD\|RW+D\|RWCD\|RW+CD\|-=
\)[ \t=3D]'
- return &sw
+ return s:Shiftwidth()
elseif cline =3D~ '^\s*config\s'
- return &sw
+ return s:Shiftwidth()
elseif pline =3D~ '^\s*repo\s' && cline =3D~ '^\s*\(#.*\)\?$'
- return &sw
+ return s:Shiftwidth()
elseif cline =3D~ '^\s*#'
return indent(prevln)
elseif cline =3D~ '^\s*$'
diff -r eccc57e1caa0 runtime/indent/haml.vim
--- a/runtime/indent/haml.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/haml.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -10,6 +10,14 @@
unlet! b:did_indent
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal autoindent sw=3D2 et
setlocal indentexpr=3DGetHamlIndent()
setlocal indentkeys=3Do,O,*<Return>,},],0),!^F,=3Dend,=3Delse,=3Delsif,=3D=
rescue,=3Densure,=3Dwhen
@@ -38,9 +46,9 @@
let indent =3D indent(lnum)
let cindent =3D indent(v:lnum)
if cline =3D~# '\v^-\s*%(elsif|else|when)>'
- let indent =3D cindent < indent ? cindent : indent - &sw
+ let indent =3D cindent < indent ? cindent : indent - s:Shiftwidth()
endif
- let increase =3D indent + &sw
+ let increase =3D indent + s:Shiftwidth()
if indent =3D=3D indent(lnum)
let indent =3D cindent <=3D indent ? -1 : increase
endif
diff -r eccc57e1caa0 runtime/indent/hamster.vim
--- a/runtime/indent/hamster.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/hamster.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -10,6 +10,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentkeys+=3D=3D~if,=3D~else,=3D~endif,=3D~endfor,=3D~endwhile
setlocal indentkeys+=3D=3D~do,=3D~until,=3D~while,=3D~repeat,=3D~for,=3D~l=
oop
setlocal indentkeys+=3D=3D~sub,=3D~endsub
@@ -27,13 +35,13 @@
" Add a shiftwidth to statements following if, else, elseif,
" case, select, default, do, until, while, for, start
if prevline =3D~? '^\s*\<\(if\|else\%(if\)\?\|for\|repeat\|do\|while\|su=
b\)\>'=20
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
=20
" Subtract a shiftwidth from else, elseif, end(if|while|for), until
let line =3D getline(v:lnum)
if line =3D~? '^\s*\(else\|elseif\|loop\|until\|end\%(if\|while\|for\|su=
b\)\)\>'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
=20
return ind
diff -r eccc57e1caa0 runtime/indent/html.vim
--- a/runtime/indent/html.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/html.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -12,6 +12,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
=20
" [-- local settings (must come before aborting the script) --]
setlocal indentexpr=3DHtmlIndentGet(v:lnum)
@@ -233,7 +241,7 @@
=09setlocal noic
endif
=20
- return indent(lnum) + (&sw * ind)
+ return indent(lnum) + (s:Shiftwidth() * ind)
endfun
=20
let &cpo =3D s:cpo_save
diff -r eccc57e1caa0 runtime/indent/idlang.vim
--- a/runtime/indent/idlang.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/idlang.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -9,6 +9,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentkeys=3Do,O,0=3Dendif,0=3DENDIF,0=3Dendelse,0=3DENDELSE,0=3D=
endwhile,0=3DENDWHILE,0=3Dendfor,0=3DENDFOR,0=3Dendrep,0=3DENDREP
=20
setlocal indentexpr=3DGetIdlangIndent(v:lnum)
@@ -34,25 +42,25 @@
" Indenting of continued lines.
if getline(pnum) =3D~ '\$\s*\(;.*\)\=3D$'
if getline(pnum2) !~ '\$\s*\(;.*\)\=3D$'
-=09 let curind =3D curind+&sw
+=09 let curind =3D curind+s:Shiftwidth()
endif
else
if getline(pnum2) =3D~ '\$\s*\(;.*\)\=3D$'
-=09 let curind =3D curind-&sw
+=09 let curind =3D curind-s:Shiftwidth()
endif
endif
=20
" Indenting blocks of statements.
if getline(v:lnum) =3D~? '^\s*\(endif\|endelse\|endwhile\|endfor\|endre=
p\)\>'
if getline(pnum) =3D~? 'begin\>'
- elseif indent(v:lnum) > curind-&sw
-=09 let curind =3D curind-&sw
+ elseif indent(v:lnum) > curind-s:Shiftwidth()
+=09 let curind =3D curind-s:Shiftwidth()
else
=09 return -1
endif
elseif getline(pnum) =3D~? 'begin\>'
- if indent(v:lnum) < curind+&sw
-=09 let curind =3D curind+&sw
+ if indent(v:lnum) < curind+s:Shiftwidth()
+=09 let curind =3D curind+s:Shiftwidth()
else
=09 return -1
endif
diff -r eccc57e1caa0 runtime/indent/ishd.vim
--- a/runtime/indent/ishd.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/ishd.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -8,6 +8,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal autoindent
setlocal indentexpr=3DGetIshdIndent(v:lnum)
setlocal indentkeys&
@@ -50,17 +58,17 @@
=20
" Add
if previous_line =3D~ '^\s*\<\(function\|begin\|switch\|case\|default\=
|if.\{-}then\|else\|elseif\|while\|repeat\)\>'
-=09let ind =3D ind + &sw
+=09let ind =3D ind + s:Shiftwidth()
endif
=20
" Subtract
if this_line =3D~ '^\s*\<endswitch\>'
-=09let ind =3D ind - 2 * &sw
+=09let ind =3D ind - 2 * s:Shiftwidth()
elseif this_line =3D~ '^\s*\<\(begin\|end\|endif\|endwhile\|else\|else=
if\|until\)\>'
-=09let ind =3D ind - &sw
+=09let ind =3D ind - s:Shiftwidth()
elseif this_line =3D~ '^\s*\<\(case\|default\)\>'
=09if previous_line !~ '^\s*\<switch\>'
-=09 let ind =3D ind - &sw
+=09 let ind =3D ind - s:Shiftwidth()
=09endif
endif
=20
diff -r eccc57e1caa0 runtime/indent/java.vim
--- a/runtime/indent/java.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/java.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -14,6 +14,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
" Indent Java anonymous classes correctly.
setlocal cindent cinoptions& cinoptions+=3Dj1
=20
@@ -87,7 +95,7 @@
" classes.
if getline(v:lnum) =3D~ '^\s*\(extends\|implements\)\>'
\ && getline(lnum) !~ '^\s*\(extends\|implements\)\>'
- let theIndent =3D theIndent + &sw
+ let theIndent =3D theIndent + s:Shiftwidth()
endif
=20
" correct for continuation lines of "throws", "implements" and "extends"
@@ -96,20 +104,20 @@
if strlen(cont_kw) > 0
let amount =3D strlen(cont_kw) + 1
if getline(lnum) !~ ',\s*$'
- let theIndent =3D theIndent - (amount + &sw)
+ let theIndent =3D theIndent - (amount + s:Shiftwidth())
if theIndent < 0
let theIndent =3D 0
endif
elseif prev =3D=3D lnum
let theIndent =3D theIndent + amount
if cont_kw =3D=3D# 'throws'
- let theIndent =3D theIndent + &sw
+ let theIndent =3D theIndent + s:Shiftwidth()
endif
endif
elseif getline(prev) =3D~ '^\s*\(throws\|implements\|extends\)\>'
\ && (getline(prev) =3D~ '{\s*$'
\ || getline(v:lnum) =3D~ '^\s*{\s*$')
- let theIndent =3D theIndent - &sw
+ let theIndent =3D theIndent - s:Shiftwidth()
endif
=20
" When the line starts with a }, try aligning it with the matching {,
diff -r eccc57e1caa0 runtime/indent/ld.vim
--- a/runtime/indent/ld.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/ld.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -8,6 +8,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentexpr=3DGetLDIndent()
setlocal indentkeys=3D0{,0},!^F,o,O
setlocal nosmartindent
@@ -65,7 +73,7 @@
if line =3D~ '^\s*\*'
return cindent(v:lnum)
elseif line =3D~ '^\s*}'
- return indent(v:lnum) - &sw
+ return indent(v:lnum) - s:Shiftwidth()
endif
=20
let pnum =3D s:prevnonblanknoncomment(v:lnum - 1)
@@ -73,11 +81,11 @@
return 0
endif
=20
- let ind =3D indent(pnum) + s:count_braces(pnum, 1) * &sw
+ let ind =3D indent(pnum) + s:count_braces(pnum, 1) * s:Shiftwidth()
=20
let pline =3D getline(pnum)
if pline =3D~ '}\s*$'
- let ind -=3D (s:count_braces(pnum, 0) - (pline =3D~ '^\s*}' ? 1 : 0)) =
* &sw
+ let ind -=3D (s:count_braces(pnum, 0) - (pline =3D~ '^\s*}' ? 1 : 0)) =
* s:Shiftwidth()
endif
=20
return ind
diff -r eccc57e1caa0 runtime/indent/liquid.vim
--- a/runtime/indent/liquid.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/liquid.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -7,6 +7,14 @@
finish
endif
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
set indentexpr=3D
if exists('b:liquid_subtype')
exe 'runtime! indent/'.b:liquid_subtype.'.vim'
@@ -54,9 +62,9 @@
let line =3D substitute(line,'\C^\%(\s*{%\s*end\w*\s*%}\)\+','','')
let line .=3D matchstr(cline,'\C^\%(\s*{%\s*end\w*\s*%}\)\+')
let cline =3D substitute(cline,'\C^\%(\s*{%\s*end\w*\s*%}\)\+','','')
- let ind +=3D &sw * s:count(line,'{%\s*\%(if\|elsif\|else\|unless\|ifchan=
ged\|case\|when\|for\|empty\|tablerow\|capture\)\>')
- let ind -=3D &sw * s:count(line,'{%\s*end\%(if\|unless\|ifchanged\|case\=
|for\|tablerow\|capture\)\>')
- let ind -=3D &sw * s:count(cline,'{%\s*\%(elsif\|else\|when\|empty\)\>')
- let ind -=3D &sw * s:count(cline,'{%\s*end\w*$')
+ let ind +=3D s:Shiftwidth() * s:count(line,'{%\s*\%(if\|elsif\|else\|unl=
ess\|ifchanged\|case\|when\|for\|empty\|tablerow\|capture\)\>')
+ let ind -=3D s:Shiftwidth() * s:count(line,'{%\s*end\%(if\|unless\|ifcha=
nged\|case\|for\|tablerow\|capture\)\>')
+ let ind -=3D s:Shiftwidth() * s:count(cline,'{%\s*\%(elsif\|else\|when\|=
empty\)\>')
+ let ind -=3D s:Shiftwidth() * s:count(cline,'{%\s*end\w*$')
return ind
endfunction
diff -r eccc57e1caa0 runtime/indent/logtalk.vim
--- a/runtime/indent/logtalk.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/logtalk.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -10,6 +10,14 @@
=09finish
endif
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
let b:did_indent =3D 1
=20
setlocal indentexpr=3DGetLogtalkIndent()
@@ -38,24 +46,24 @@
=09endif
=09" Check for entity opening directive on previous line
=09if pline =3D~ '^\s*:-\s\(object\|protocol\|category\)\ze(.*,$'
-=09=09let ind =3D ind + &sw
+=09=09let ind =3D ind + s:Shiftwidth()
=09" Check for clause head on previous line
=09elseif pline =3D~ ':-\s*\(%.*\)\?$'
-=09=09let ind =3D ind + &sw
+=09=09let ind =3D ind + s:Shiftwidth()
=09" Check for entity closing directive on previous line
=09elseif pline =3D~ '^\s*:-\send_\(object\|protocol\|category\)\.\(%.*\)\=
?$'
-=09=09let ind =3D ind - &sw
+=09=09let ind =3D ind - s:Shiftwidth()
=09" Check for end of clause on previous line
=09elseif pline =3D~ '\.\s*\(%.*\)\?$'
-=09=09let ind =3D ind - &sw
+=09=09let ind =3D ind - s:Shiftwidth()
=09endif
=09" Check for opening conditional on previous line
=09if pline =3D~ '^\s*\([(;]\|->\)' && pline !~ '\.\s*\(%.*\)\?$' && pline=
!~ '^.*\([)][,]\s*\(%.*\)\?$\)'
-=09=09let ind =3D ind + &sw
+=09=09let ind =3D ind + s:Shiftwidth()
=09endif
=09" Check for closing an unclosed paren, or middle ; or ->
=09if line =3D~ '^\s*\([);]\|->\)'
-=09=09let ind =3D ind - &sw
+=09=09let ind =3D ind - s:Shiftwidth()
=09endif
=09return ind
endfunction
diff -r eccc57e1caa0 runtime/indent/lua.vim
--- a/runtime/indent/lua.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/lua.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -10,6 +10,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentexpr=3DGetLuaIndent()
=20
" To make Vim call GetLuaIndent() when it finds '\s*end' or '\s*until'
@@ -48,7 +56,7 @@
" Add 'shiftwidth' if what we found previously is not in a comment and
" an "end" or "until" is not present on the same line.
if synIDattr(synID(prevlnum, midx + 1, 1), "name") !=3D "luaComment" &=
& prevline !~ '\<end\>\|\<until\>'
- let ind =3D ind + &shiftwidth
+ let ind =3D ind + s:Shiftwidth()
endif
endif
=20
@@ -56,7 +64,7 @@
" This is the part that requires 'indentkeys'.
let midx =3D match(getline(v:lnum), '^\s*\%(end\|else\|until\|}\)')
if midx !=3D -1 && synIDattr(synID(v:lnum, midx + 1, 1), "name") !=3D "l=
uaComment"
- let ind =3D ind - &shiftwidth
+ let ind =3D ind - s:Shiftwidth()
endif
=20
return ind
diff -r eccc57e1caa0 runtime/indent/make.vim
--- a/runtime/indent/make.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/make.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -8,6 +8,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentexpr=3DGetMakeIndent()
setlocal indentkeys=3D!^F,o,O,<:>,=3Delse,=3Dendif
setlocal nosmartindent
@@ -48,14 +56,14 @@
if prev_prev_line =3D~ s:continuation_rx
return indent(prev_lnum)
elseif prev_line =3D~ s:rule_rx
- return &sw
+ return s:Shiftwidth()
elseif prev_line =3D~ s:assignment_rx
call cursor(prev_lnum, 1)
if search(s:assignment_rx, 'W') !=3D 0
return virtcol('.') - 1
else
" TODO: ?
- return &sw
+ return s:Shiftwidth()
endif
else
" TODO: OK, this might be a continued shell command, so perhaps inde=
nt
@@ -66,7 +74,7 @@
" return indent(prev_lnum) + 2
" endif
"endif
- return indent(prev_lnum) + &sw
+ return indent(prev_lnum) + s:Shiftwidth()
endif
elseif prev_prev_line =3D~ s:continuation_rx
let folded_line =3D s:remove_continuation(prev_prev_line) . ' ' . s:re=
move_continuation(prev_line)
@@ -102,13 +110,13 @@
return &ts
endif
elseif prev_line =3D~ s:conditional_directive_rx
- return &sw
+ return s:Shiftwidth()
else
let line =3D getline(v:lnum)
if line =3D~ s:just_inserted_rule_rx
return 0
elseif line =3D~ s:end_conditional_directive_rx
- return v:lnum - 1 =3D=3D 0 ? 0 : indent(v:lnum - 1) - &sw
+ return v:lnum - 1 =3D=3D 0 ? 0 : indent(v:lnum - 1) - s:Shiftwidth()
else
return v:lnum - 1 =3D=3D 0 ? 0 : indent(v:lnum - 1)
endif
diff -r eccc57e1caa0 runtime/indent/matlab.vim
--- a/runtime/indent/matlab.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/matlab.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -9,6 +9,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
" Some preliminary setting
setlocal indentkeys=3D!=06,o,O=3Dend,=3Dcase,=3Delse,=3Delseif,=3Dotherwis=
e,=3Dcatch
=20
@@ -44,9 +52,9 @@
" See if this line does not follow the line right after an openblock
if getline(plnum) =3D~ '^\s*\(for\|if\|else\|elseif\|case\|while\|swit=
ch\|try\|otherwise\|catch\)\>'
" See if the user has already dedented
- elseif indent(v:lnum) > curind - &sw
+ elseif indent(v:lnum) > curind - s:Shiftwidth()
" If not, recommend one dedent
-=09let curind =3D curind - &sw
+=09let curind =3D curind - s:Shiftwidth()
else
" Otherwise, trust the user
return -1
@@ -56,9 +64,9 @@
" If the previous line opened a block
elseif getline(plnum) =3D~ '^\s*\(for\|if\|else\|elseif\|case\|while\|sw=
itch\|try\|otherwise\|catch\)\>'
" See if the user has already indented
- if indent(v:lnum) < curind + &sw
+ if indent(v:lnum) < curind + s:Shiftwidth()
"If not, recommend indent
- let curind =3D curind + &sw
+ let curind =3D curind + s:Shiftwidth()
else
" Otherwise, trust the user
return -1
diff -r eccc57e1caa0 runtime/indent/mma.vim
--- a/runtime/indent/mma.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/mma.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -21,6 +21,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentexpr=3DGetMmaIndent()
setlocal indentkeys+=3D0[,0],0(,0)
setlocal nosi "turn off smart indent so we don't over analyze } blocks
@@ -49,7 +57,7 @@
" also, indent only if this line if this line isn't starting a new
" block... TODO - fix this with indentkeys?
if getline(v:lnum-1) =3D~ '\\\@<!\%(\[[^\]]*\|([^)]*\|{[^}]*\)$' && ge=
tline(v:lnum) !~ '\s\+[\[({]'
- let ind =3D ind+&sw
+ let ind =3D ind+s:Shiftwidth()
endif
=20
" if this line had unmatched closing block,
diff -r eccc57e1caa0 runtime/indent/mp.vim
--- a/runtime/indent/mp.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/mp.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -49,6 +49,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentexpr=3DGetMetaPostIndent()
setlocal indentkeys+=3D;,<:>,=3Dif,=3Dfor,=3Ddef,=3Dend,=3Delse,=3Dfi
=20
@@ -162,18 +170,18 @@
" if it is an internal/external :for or :if statements {{{2
let pnn_s =3D getline(MetaPrevNonblankNoncomment(cl-1))
if pnn_s =3D~ '\<\(for\|if\)\>.\+:\s*\($\|%\)'
- let ind =3D match(pnn_s, '\<\(for\|if\)\>.\+:\s*\($\|%\)') + &sw
+ let ind =3D match(pnn_s, '\<\(for\|if\)\>.\+:\s*\($\|%\)') + s:Shiftwi=
dth()
" }}}
" if it is a :def, :vardef, :beginfig, :begingroup, :else, :elseif {{{2
elseif pnn_s =3D~ '^\s*\(' .
\ '\(var\)\=3Ddef\|' .
\ 'begin\(group\|fig\s*(\s*\d\+\s*)\)\|' .
\ 'else\(if\)\=3D' . '\)\>'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
" }}}
" if it is a broken line {{{2
elseif pnn_s !~ end_of_item.'\s*\($\|%\)'
- let ind =3D ind + (2 * &sw)
+ let ind =3D ind + (2 * s:Shiftwidth())
endif
" }}}
" }}}
@@ -196,7 +204,7 @@
" }}}
" if this is :endgroup statement {{{2
elseif cs =3D~ '^\s*endgroup\>'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
" }}}
" }}}
diff -r eccc57e1caa0 runtime/indent/ocaml.vim
--- a/runtime/indent/ocaml.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/ocaml.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -14,6 +14,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal expandtab
setlocal indentexpr=3DGetOCamlIndent()
setlocal indentkeys+=3D0=3Dand,0=3Dclass,0=3Dconstraint,0=3Ddone,0=3Delse,=
0=3Dend,0=3Dexception,0=3Dexternal,0=3Dif,0=3Din,0=3Dinclude,0=3Dinherit,0=
=3Dinitializer,0=3Dlet,0=3Dmethod,0=3Dopen,0=3Dthen,0=3Dtype,0=3Dval,0=3Dwi=
th,0;;,0>\],0\|\],0>},0\|,0},0\],0)
@@ -95,7 +103,7 @@
=20
" Return double 'shiftwidth' after lines matching:
if lline =3D~ '^\s*|.*->\s*$'
- return ind + &sw + &sw
+ return ind + s:Shiftwidth() + s:Shiftwidth()
endif
=20
let line =3D getline(v:lnum)
@@ -166,7 +174,7 @@
" Indent if current line begins with 'and':
elseif line =3D~ '^\s*and\>'
if lline !~ '^\s*\(and\|let\|type\)\>\|\<end\s*$'
- return ind - &sw
+ return ind - s:Shiftwidth()
endif
=20
" Indent if current line begins with 'with':
@@ -193,14 +201,14 @@
" or 'method':
elseif line =3D~ '^\s*\(constraint\|inherit\|initializer\|method\)\>'
if lline !~ s:obj
- return indent(search('\<\(object\|object\s*(.*)\)\s*$', 'bW')) + &sw
+ return indent(search('\<\(object\|object\s*(.*)\)\s*$', 'bW')) + s:Sh=
iftwidth()
endif
=20
endif
=20
" Add a 'shiftwidth' after lines ending with:
if lline =3D~ '\(:\|=3D\|->\|<-\|(\|\[\|{\|{<\|\[|\|\[<\|\<\(begin\|do\|e=
lse\|fun\|function\|functor\|if\|initializer\|object\|parser\|private\|sig\=
|struct\|then\|try\)\|\<object\s*(.*)\)\s*$'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
=20
" Back to normal indent after lines ending with ';;':
elseif lline =3D~ ';;\s*$' && lline !~ '^\s*;;'
@@ -257,7 +265,7 @@
=20
" Subtract a 'shiftwidth' after lines matching 'match ... with parser':
if lline =3D~ '\<match\>.*\<with\>\s*\<parser\s*$'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
=20
return ind
diff -r eccc57e1caa0 runtime/indent/occam.vim
--- a/runtime/indent/occam.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/occam.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -9,6 +9,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
"{{{ Settings
" Set the occam indent function
setlocal indentexpr=3DGetOccamIndent()
@@ -131,7 +139,7 @@
if line =3D~ s:FirstLevelIndent || (line =3D~ s:FirstLevelNonColonEndInd=
ent && line !~ s:ColonEnd)
=09\ || (line !~ s:ColonStart && (prevline =3D~ s:SecondLevelIndent
=09\ || (prevline =3D~ s:SecondLevelNonColonEndIndent && prevline !~ s:Col=
onEnd)))
- let curindent =3D curindent + &shiftwidth
+ let curindent =3D curindent + s:Shiftwidth()
=20
" Restore magic
if !save_magic|setlocal nomagic|endif
@@ -153,7 +161,7 @@
=20
while !found
=20
- if indent(prevlinenum) =3D=3D curindent - &shiftwidth
+ if indent(prevlinenum) =3D=3D curindent - s:Shiftwidth()
let found =3D 1
endif
=20
@@ -171,7 +179,7 @@
=20
if prevlinenum > 0
if getline(prevlinenum) =3D~ s:SecondLevelIndent
- let curindent =3D curindent + &shiftwidth
+ let curindent =3D curindent + s:Shiftwidth()
endif
endif
=20
diff -r eccc57e1caa0 runtime/indent/pascal.vim
--- a/runtime/indent/pascal.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/pascal.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -14,6 +14,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentexpr=3DGetPascalIndent(v:lnum)
setlocal indentkeys&
setlocal indentkeys+=3D=3Dend;,=3D=3Dconst,=3D=3Dtype,=3D=3Dvar,=3D=3Dbegi=
n,=3D=3Drepeat,=3D=3Duntil,=3D=3Dfor
@@ -102,12 +110,12 @@
=20
=09" If the PREVIOUS LINE ended in these items, always indent
=09if prev_codeline =3D~ '\<\(type\|const\|var\)$'
-=09=09return indnt + &shiftwidth
+=09=09return indnt + s:Shiftwidth()
=09endif
=20
=09if prev_codeline =3D~ '\<repeat$'
=09=09if this_codeline !~ '^\s*until\>'
-=09=09=09return indnt + &shiftwidth
+=09=09=09return indnt + s:Shiftwidth()
=09=09else
=09=09=09return indnt
=09=09endif
@@ -115,7 +123,7 @@
=20
=09if prev_codeline =3D~ '\<\(begin\|record\)$'
=09=09if this_codeline !~ '^\s*end\>'
-=09=09=09return indnt + &shiftwidth
+=09=09=09return indnt + s:Shiftwidth()
=09=09else
=09=09=09return indnt
=09=09endif
@@ -125,10 +133,10 @@
=09" followed by "begin"
=09if prev_codeline =3D~ '\<\(\|else\|then\|do\)$' || prev_codeline =3D~ '=
:$'
=09=09if this_codeline !~ '^\s*begin\>'
-=09=09=09return indnt + &shiftwidth
+=09=09=09return indnt + s:Shiftwidth()
=09=09else
=09=09=09" If it does start with "begin" then keep the same indent
-=09=09=09"return indnt + &shiftwidth
+=09=09=09"return indnt + s:Shiftwidth()
=09=09=09return indnt
=09=09endif
=09endif
@@ -137,7 +145,7 @@
=09" only the line before the current one. TODO: Get it working for
=09" parameter lists longer than two lines.
=09if prev_codeline =3D~ '([^)]\+$'
-=09=09return indnt + &shiftwidth
+=09=09return indnt + s:Shiftwidth()
=09endif
=20
=20
@@ -146,7 +154,7 @@
=09" Lines starting with "else", but not following line ending with
=09" "end".
=09if this_codeline =3D~ '^\s*else\>' && prev_codeline !~ '\<end$'
-=09=09return indnt - &shiftwidth
+=09=09return indnt - s:Shiftwidth()
=09endif
=20
=09" Lines after a single-statement branch/loop.
@@ -160,16 +168,16 @@
=09=09" additional unindentation.
=09=09if this_codeline =3D~ '^\s*\(end;\|except\|finally\|\)$'
=09=09=09" Note that we don't return from here.
-=09=09=09return indnt - &shiftwidth - &shiftwidth
+=09=09=09return indnt - s:Shiftwidth() - s:Shiftwidth()
=09=09endif
-=09=09return indnt - &shiftwidth
+=09=09return indnt - s:Shiftwidth()
=09endif
=20
=09" Lines starting with "until" or "end". This rule must be overridden
=09" by the one for "end" after a single-statement branch/loop. In
=09" other words that rule should come before this one.
=09if this_codeline =3D~ '^\s*\(end\|until\)\>'
-=09=09return indnt - &shiftwidth
+=09=09return indnt - s:Shiftwidth()
=09endif
=20
=20
@@ -201,7 +209,7 @@
=20
=09" If the PREVIOUS LINE ended in these items, always indent.
=09if prev_codeline =3D~ '^\s*\(unit\|uses\|try\|except\|finally\|private\=
|protected\|public\|published\)$'
-=09=09return indnt + &shiftwidth
+=09=09return indnt + s:Shiftwidth()
=09endif
=20
=09" ???? Indent "procedure" and "functions" if they appear within an
@@ -212,11 +220,11 @@
=09" UNINDENT ONCE
=20
=09if this_codeline =3D~ '^\s*\(except\|finally\)$'
-=09=09return indnt - &shiftwidth
+=09=09return indnt - s:Shiftwidth()
=09endif
=20
=09if this_codeline =3D~ '^\s*\(private\|protected\|public\|published\)$'
-=09=09return indnt - &shiftwidth
+=09=09return indnt - s:Shiftwidth()
=09endif
=20
=20
diff -r eccc57e1caa0 runtime/indent/perl.vim
--- a/runtime/indent/perl.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/perl.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -25,6 +25,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
" Is syntax highlighting active ?
let b:indent_use_syntax =3D has("syntax")
=20
@@ -136,9 +144,9 @@
\ || synid =3D~ '^perl\(Sub\|Block\)Fold'
let brace =3D strpart(line, bracepos, 1)
if brace =3D=3D '(' || brace =3D=3D '{' || brace =3D=3D '[=
'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
else
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
endif
let bracepos =3D match(line, '[(){}\[\]]', bracepos + 1)
@@ -149,25 +157,25 @@
if synid =3D=3D ""
\ || synid =3D=3D "perlMatchStartEnd"
\ || synid =3D~ '^perl\(Sub\|Block\)Fold'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
endif
else
if line =3D~ '[{\[(]\s*\(#[^)}\]]*\)\=3D$'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
if cline =3D~ '^\s*[)}\]]'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
endif
=20
" Indent lines that begin with 'or' or 'and'
if cline =3D~ '^\s*\(or\|and\)\>'
if line !~ '^\s*\(or\|and\)\>'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
elseif line =3D~ '^\s*\(or\|and\)\>'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
=20
return ind
diff -r eccc57e1caa0 runtime/indent/perl6.vim
--- a/runtime/indent/perl6.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/perl6.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -32,6 +32,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
" Is syntax highlighting active ?
let b:indent_use_syntax =3D has("syntax")
=20
@@ -111,19 +119,19 @@
endif
=20
if line =3D~ '[<?\[{(]\s*\(#[^)}\]?>]*\)\=3D$'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
if cline =3D~ '^\s*[)}\]?>]'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
=20
" Indent lines that begin with 'or' or 'and'
if cline =3D~ '^\s*\(or\|and\)\>'
if line !~ '^\s*\(or\|and\)\>'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
elseif line =3D~ '^\s*\(or\|and\)\>'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
=20
return ind
diff -r eccc57e1caa0 runtime/indent/php.vim
--- a/runtime/indent/php.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/php.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -46,12 +46,20 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
=20
let php_sync_method =3D 0
=20
=20
if exists("PHP_default_indenting")
- let b:PHP_default_indenting =3D PHP_default_indenting * &sw
+ let b:PHP_default_indenting =3D PHP_default_indenting * s:Shiftwidth()
else
let b:PHP_default_indenting =3D 0
endif
@@ -270,7 +278,7 @@
let test =3D GetLastRealCodeLNum(a:lnum - 1)
=20
if test <=3D 1
-=09return indent(1) - &sw * b:PHP_vintage_case_default_indent
+=09return indent(1) - s:Shiftwidth() * b:PHP_vintage_case_default_indent
end
=20
if getline(test) =3D~ '^\s*}'
@@ -284,7 +292,7 @@
if getline(test) =3D~# '^\s*switch\>'
=09return indent(test)
elseif getline(test) =3D~# s:defaultORcase
-=09return indent(test) - &sw * b:PHP_vintage_case_default_indent
+=09return indent(test) - s:Shiftwidth() * b:PHP_vintage_case_default_inden=
t
else
=09return FindTheSwitchIndent(test)
endif
@@ -353,7 +361,7 @@
endif
=20
if b:PHP_default_indenting
-=09let b:PHP_default_indenting =3D g:PHP_default_indenting * &sw
+=09let b:PHP_default_indenting =3D g:PHP_default_indenting * s:Shiftwidth(=
)
endif
=20
let cline =3D getline(v:lnum)
@@ -595,7 +603,7 @@
=09let b:PHP_CurrentIndentLevel =3D b:PHP_default_indenting
=09return indent(FindTheIfOfAnElse(v:lnum, 1))
elseif cline =3D~# s:defaultORcase
-=09return FindTheSwitchIndent(v:lnum) + &sw * b:PHP_vintage_case_default_i=
ndent
+=09return FindTheSwitchIndent(v:lnum) + s:Shiftwidth() * b:PHP_vintage_cas=
e_default_indent
elseif cline =3D~ '^\s*)\=3D\s*{'
=09let previous_line =3D last_line
=09let last_line_num =3D lnum
@@ -607,7 +615,7 @@
=09=09let ind =3D indent(last_line_num)
=20
=09=09if b:PHP_BracesAtCodeLevel
-=09=09 let ind =3D ind + &sw
+=09=09 let ind =3D ind + s:Shiftwidth()
=09=09endif
=20
=09=09return ind
@@ -618,7 +626,7 @@
=09endwhile
=20
elseif last_line =3D~# unstated && cline !~ '^\s*);\=3D'.endline
-=09let ind =3D ind + &sw
+=09let ind =3D ind + s:Shiftwidth()
=09return ind
=20
elseif (ind !=3D b:PHP_default_indenting || last_line =3D~ '^)' ) && l=
ast_line =3D~ terminated
@@ -696,7 +704,7 @@
=09if last_line =3D~# '[{(]'.endline || last_line =3D~? '\h\w*\s*(.*,$' &&=
AntepenultimateLine !~ '[,(]'.endline
=20
=09 if !b:PHP_BracesAtCodeLevel || last_line !~# '^\s*{'
-=09=09let ind =3D ind + &sw
+=09=09let ind =3D ind + s:Shiftwidth()
=09 endif
=20
=09 if b:PHP_BracesAtCodeLevel || b:PHP_vintage_case_default_indent =3D=
=3D 1
@@ -714,18 +722,18 @@
=09 endif
=09
=09elseif last_line =3D~ '^\s*'.s:blockstart
-=09 let ind =3D ind + &sw
+=09 let ind =3D ind + s:Shiftwidth()
=20
=20
=20
=09elseif AntepenultimateLine =3D~ '\%(;\%(\s*?>\)\=3D\|<<<''\=3D\a\w*''\=
=3D$\|^\s*}\|{\)'.endline . '\|' . s:defaultORcase
-=09 let ind =3D ind + &sw
+=09 let ind =3D ind + s:Shiftwidth()
=09endif
=20
endif
=20
if cline =3D~ '^\s*);\=3D'
-=09let ind =3D ind - &sw
+=09let ind =3D ind - s:Shiftwidth()
endif
=20
let b:PHP_CurrentIndentLevel =3D ind
diff -r eccc57e1caa0 runtime/indent/postscr.vim
--- a/runtime/indent/postscr.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/postscr.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -10,6 +10,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentexpr=3DPostscrIndentGet(v:lnum)
setlocal indentkeys+=3D0],0=3D>>,0=3D%%,0=3Dend,0=3Drestore,0=3Dgrestore i=
ndentkeys-=3D:,0#,e
=20
@@ -41,16 +49,16 @@
=20
" Indent for dicts, arrays, and saves with possible trailing comment
if pline =3D~ '\(begin\|<<\|g\=3Dsave\|{\|[\)\s*\(%.*\)\=3D$'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
=20
" Remove indent for popped dicts, and restores.
if pline =3D~ '\(end\|g\=3Drestore\)\s*$'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
=20
" Else handle immediate dedents of dicts, restores, and arrays.
elseif getline(a:lnum) =3D~ '\(end\|>>\|g\=3Drestore\|}\|]\)'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
=20
" Else handle DSC comments - always start of line.
elseif getline(a:lnum) =3D~ '^\s*%%'
diff -r eccc57e1caa0 runtime/indent/pov.vim
--- a/runtime/indent/pov.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/pov.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -10,6 +10,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
" Some preliminary settings.
setlocal nolisp " Make sure lisp indenting doesn't supersede us.
=20
@@ -75,9 +83,9 @@
" opening line.
let cur =3D s:MatchCount(v:lnum, '^\s*\%(#\s*\%(end\|else\)\>\|[]})]\)')
if cur > 0
- let final =3D plind + (chg - cur) * &sw
+ let final =3D plind + (chg - cur) * s:Shiftwidth()
else
- let final =3D plind + chg * &sw
+ let final =3D plind + chg * s:Shiftwidth()
endif
=20
return final < 0 ? 0 : final
diff -r eccc57e1caa0 runtime/indent/prolog.vim
--- a/runtime/indent/prolog.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/prolog.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -13,6 +13,14 @@
finish
endif
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
let b:did_indent =3D 1
=20
setlocal indentexpr=3DGetPrologIndent()
@@ -41,18 +49,18 @@
endif
" Check for clause head on previous line
if pline =3D~ ':-\s*\(%.*\)\?$'
-=09let ind =3D ind + &sw
+=09let ind =3D ind + s:Shiftwidth()
" Check for end of clause on previous line
elseif pline =3D~ '\.\s*\(%.*\)\?$'
-=09let ind =3D ind - &sw
+=09let ind =3D ind - s:Shiftwidth()
endif
" Check for opening conditional on previous line
if pline =3D~ '^\s*\([(;]\|->\)'
-=09let ind =3D ind + &sw
+=09let ind =3D ind + s:Shiftwidth()
endif
" Check for closing an unclosed paren, or middle ; or ->
if line =3D~ '^\s*\([);]\|->\)'
-=09let ind =3D ind - &sw
+=09let ind =3D ind - s:Shiftwidth()
endif
return ind
endfunction
diff -r eccc57e1caa0 runtime/indent/python.vim
--- a/runtime/indent/python.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/python.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -10,6 +10,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
" Some preliminary settings
setlocal nolisp=09=09" Make sure lisp indenting doesn't supersede us
setlocal autoindent=09" indentexpr isn't much help otherwise
@@ -36,7 +44,7 @@
if a:lnum > 1 && getline(a:lnum - 2) =3D~ '\\$'
return indent(a:lnum - 1)
endif
- return indent(a:lnum - 1) + (exists("g:pyindent_continue") ? eval(g:py=
indent_continue) : (&sw * 2))
+ return indent(a:lnum - 1) + (exists("g:pyindent_continue") ? eval(g:py=
indent_continue) : (s:Shiftwidth() * 2))
endif
=20
" If the start of the line is in a string don't change the indent.
@@ -89,9 +97,9 @@
=09 \ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
=09 \ . " =3D~ '\\(Comment\\|String\\)$'")
if pp > 0
-=09return indent(plnum) + (exists("g:pyindent_nested_paren") ? eval(g:pyin=
dent_nested_paren) : &sw)
+=09return indent(plnum) + (exists("g:pyindent_nested_paren") ? eval(g:pyin=
dent_nested_paren) : s:Shiftwidth())
endif
- return indent(plnum) + (exists("g:pyindent_open_paren") ? eval(g:pyi=
ndent_open_paren) : (&sw * 2))
+ return indent(plnum) + (exists("g:pyindent_open_paren") ? eval(g:pyi=
ndent_open_paren) : (s:Shiftwidth() * 2))
endif
if plnumstart =3D=3D p
return indent(plnum)
@@ -134,15 +142,15 @@
=20
" If the previous line ended with a colon, indent this line
if pline =3D~ ':\s*$'
- return plindent + &sw
+ return plindent + s:Shiftwidth()
endif
=20
" If the previous line was a stop-execution statement...
if getline(plnum) =3D~ '^\s*\(break\|continue\|raise\|return\|pass\)\>'
" See if the user has already dedented
- if indent(a:lnum) > indent(plnum) - &sw
+ if indent(a:lnum) > indent(plnum) - s:Shiftwidth()
" If not, recommend one dedent
- return indent(plnum) - &sw
+ return indent(plnum) - s:Shiftwidth()
endif
" Otherwise, trust the user
return -1
@@ -173,11 +181,11 @@
endif
=20
" Or the user has already dedented
- if indent(a:lnum) <=3D plindent - &sw
+ if indent(a:lnum) <=3D plindent - s:Shiftwidth()
return -1
endif
=20
- return plindent - &sw
+ return plindent - s:Shiftwidth()
endif
=20
" When after a () construct we probably want to go back to the start lin=
e.
diff -r eccc57e1caa0 runtime/indent/r.vim
--- a/runtime/indent/r.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/r.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -10,6 +10,14 @@
endif
let b:did_r_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentkeys=3D0{,0},:,!^F,o,O,e
setlocal indentexpr=3DGetRIndent()
=20
@@ -268,7 +276,7 @@
let nlnum =3D s:Get_prev_line(nlnum)
let nline =3D SanitizeRLine(getline(nlnum)) . nline
endwhile
- if nline =3D~ '^\s*function\s*(' && indent(nlnum) =3D=3D &sw
+ if nline =3D~ '^\s*function\s*(' && indent(nlnum) =3D=3D s:Shi=
ftwidth()
return 0
endif
endif
@@ -279,7 +287,7 @@
=20
" line is an incomplete command:
if line =3D~ '\<\(if\|while\|for\|function\)\s*()$' || line =3D~ '\<el=
se$' || line =3D~ '<-$'
- return indent(lnum) + &sw
+ return indent(lnum) + s:Shiftwidth()
endif
=20
" Deal with () and []
@@ -287,7 +295,7 @@
let pb =3D s:Get_paren_balance(line, '(', ')')
=20
if line =3D~ '^\s*{$' || line =3D~ '(\s*{' || (pb =3D=3D 0 && (line =
=3D~ '{$' || line =3D~ '(\s*{$'))
- return indent(lnum) + &sw
+ return indent(lnum) + s:Shiftwidth()
endif
=20
let bb =3D s:Get_paren_balance(line, '[', ']')
@@ -360,7 +368,7 @@
let line =3D linepiece . line
endwhile
if line =3D~ '{$' && post_block =3D=3D 0
- return indent(lnum) + &sw
+ return indent(lnum) + s:Shiftwidth()
endif
=20
" Now we can do some tests again
@@ -370,19 +378,19 @@
if post_block =3D=3D 0
let newl =3D SanitizeRLine(line)
if newl =3D~ '\<\(if\|while\|for\|function\)\s*()$' || newl =
=3D~ '\<else$' || newl =3D~ '<-$'
- return indent(lnum) + &sw
+ return indent(lnum) + s:Shiftwidth()
endif
endif
endif
=20
if cline =3D~ '^\s*else'
if line =3D~ '<-\s*if\s*()'
- return indent(lnum) + &sw
+ return indent(lnum) + s:Shiftwidth()
else
if line =3D~ '\<if\s*()'
return indent(lnum)
else
- return indent(lnum) - &sw
+ return indent(lnum) - s:Shiftwidth()
endif
endif
endif
@@ -451,16 +459,16 @@
let pind =3D indent(plnum)
=20
if g:r_indent_align_args =3D=3D 0 && pb !=3D 0
- let ind +=3D pb * &sw
+ let ind +=3D pb * s:Shiftwidth()
return ind
endif
=20
if g:r_indent_align_args =3D=3D 0 && bb !=3D 0
- let ind +=3D bb * &sw
+ let ind +=3D bb * s:Shiftwidth()
return ind
endif
=20
- if ind =3D=3D pind || (ind =3D=3D (pind + &sw) && pline =3D~ '{$' && =
ppost_else =3D=3D 0)
+ if ind =3D=3D pind || (ind =3D=3D (pind + s:Shiftwidth()) && pline =
=3D~ '{$' && ppost_else =3D=3D 0)
return ind
endif
=20
@@ -480,7 +488,7 @@
let pbb =3D s:Get_paren_balance(pline, '[', ']')
endwhile
let pind =3D indent(plnum)
- if ind =3D=3D (pind + &sw) && pline =3D~ '{$'
+ if ind =3D=3D (pind + s:Shiftwidth()) && pline =3D~ '{$'
return ind
endif
endwhile
diff -r eccc57e1caa0 runtime/indent/readline.vim
--- a/runtime/indent/readline.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/readline.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -8,6 +8,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentexpr=3DGetReadlineIndent()
setlocal indentkeys=3D!^F,o,O,=3D$else,=3D$endif
setlocal nosmartindent
@@ -25,11 +33,11 @@
let ind =3D indent(lnum)
=20
if getline(lnum) =3D~ '^\s*$\(if\|else\)\>'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
=20
if getline(v:lnum) =3D~ '^\s*$\(else\|endif\)\>'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
=20
return ind
diff -r eccc57e1caa0 runtime/indent/rpl.vim
--- a/runtime/indent/rpl.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/rpl.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -10,6 +10,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal autoindent
setlocal indentkeys+=3D=3D~end,=3D~case,=3D~if,=3D~then,=3D~else,=3D~do,=
=3D~until,=3D~while,=3D~repeat,=3D~select,=3D~default,=3D~for,=3D~start,=3D=
~next,=3D~step,<<>,<>>
=20
@@ -32,16 +40,16 @@
if prevstat =3D~? '\<\(if\|iferr\|do\|while\)\>' && prevstat =3D~? '\<en=
d\>'
elseif prevstat =3D~? '\(^\|\s\+\)<<\($\|\s\+\)' && prevstat =3D~? '\s\+=
>>\($\|\s\+\)'
elseif prevstat =3D~? '\<\(if\|iferr\|then\|else\|elseif\|select\|case\|=
do\|until\|while\|repeat\|for\|start\|default\)\>' || prevstat =3D~? '\(^\|=
\s\+\)<<\($\|\s\+\)'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
=20
" Subtract a shiftwidth from then, else, elseif, end, until, repeat, nex=
t,
" step
let line =3D getline(v:lnum)
if line =3D~? '^\s*\(then\|else\|elseif\|until\|repeat\|next\|step\|defa=
ult\|end\)\>'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
elseif line =3D~? '^\s*>>\($\|\s\+\)'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
=20
return ind
diff -r eccc57e1caa0 runtime/indent/ruby.vim
--- a/runtime/indent/ruby.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/ruby.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -15,6 +15,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal nosmartindent
=20
" Now, set up our indentation expression and keys that trigger it.
@@ -275,7 +283,7 @@
=20
" If the previous line ended with a block opening, add a level of indent=
.
if s:Match(lnum, s:block_regex)
- return indent(s:GetMSL(lnum)) + &sw
+ return indent(s:GetMSL(lnum)) + s:Shiftwidth()
endif
=20
" If the previous line contained an opening bracket, and we are still in=
it,
@@ -284,12 +292,12 @@
let counts =3D s:LineHasOpeningBrackets(lnum)
if counts[0] =3D=3D '1' && searchpair('(', '', ')', 'bW', s:skip_expr)=
> 0
if col('.') + 1 =3D=3D col('$')
-=09return ind + &sw
+=09return ind + s:Shiftwidth()
else
=09return virtcol('.')
endif
elseif counts[1] =3D=3D '1' || counts[2] =3D=3D '1'
- return ind + &sw
+ return ind + s:Shiftwidth()
else
call cursor(v:lnum, vcol)
end
@@ -315,8 +323,8 @@
let col =3D s:Match(lnum, s:ruby_indent_keywords)
if col > 0
call cursor(lnum, col)
- let ind =3D virtcol('.') - 1 + &sw
-" let ind =3D indent(lnum) + &sw
+ let ind =3D virtcol('.') - 1 + s:Shiftwidth()
+" let ind =3D indent(lnum) + s:Shiftwidth()
" TODO: make this better (we need to count them) (or, if a searchpair
" fails, we know that something is lacking an end and thus we indent a
" level
@@ -349,9 +357,9 @@
" TODO: this does not take into account contrived things such as
" module Foo; class Bar; end
if s:Match(lnum, s:ruby_indent_keywords)
- let ind =3D msl_ind + &sw
+ let ind =3D msl_ind + s:Shiftwidth()
if s:Match(lnum, s:end_end_regex)
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
return ind
endif
@@ -359,7 +367,7 @@
" If the previous line ended with [*+/.-=3D], indent one extra level.
if s:Match(lnum, s:continuation_regex)
if lnum =3D=3D p_lnum
- let ind =3D msl_ind + &sw
+ let ind =3D msl_ind + s:Shiftwidth()
else
let ind =3D msl_ind
endif
diff -r eccc57e1caa0 runtime/indent/sass.vim
--- a/runtime/indent/sass.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/sass.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -8,6 +8,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal autoindent sw=3D2 et
setlocal indentexpr=3DGetSassIndent()
setlocal indentkeys=3Do,O,*<Return>,<:>,!^F
@@ -28,9 +36,9 @@
let indent =3D indent(lnum)
let cindent =3D indent(v:lnum)
if line !~ s:property && cline =3D~ s:property
- return indent + &sw
+ return indent + s:Shiftwidth()
"elseif line =3D~ s:property && cline !~ s:property
- "return indent - &sw
+ "return indent - s:Shiftwidth()
else
return -1
endif
diff -r eccc57e1caa0 runtime/indent/sdl.vim
--- a/runtime/indent/sdl.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/sdl.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -11,6 +11,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentexpr=3DGetSDLIndent()
setlocal indentkeys+=3D=3D~end,=3D~state,*<Return>
=20
@@ -46,17 +54,17 @@
if (getline(lnum) =3D~? '^\s*\(start\|state\|system\|package\|connection=
\|channel\|alternative\|macro\|operator\|newtype\|select\|substructure\|dec=
ision\|generator\|refinement\|service\|method\|exceptionhandler\|asntype\|s=
yntype\|value\|(.*):\|\(priority\s\+\)\=3Dinput\|provided\)'
\ || getline(lnum) =3D~? virtuality . '\(process\|procedure\|block\|ob=
ject\)')
\ && getline(lnum) !~? 'end[[:alpha:]]\+;$'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
=20
" Subtract a 'shiftwidth' after states
if getline(lnum) =3D~? '^\s*\(stop\|return\>\|nextstate\)'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
=20
" Subtract a 'shiftwidth' on on end (uncompleted line)
if getline(v:lnum) =3D~? '^\s*end\>'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
=20
" Put each alternatives where the corresponding decision was
diff -r eccc57e1caa0 runtime/indent/sh.vim
--- a/runtime/indent/sh.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/sh.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -8,6 +8,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentexpr=3DGetShIndent()
setlocal indentkeys+=3D0=3Dthen,0=3Ddo,0=3Delse,0=3Delif,0=3Dfi,0=3Desac,0=
=3Ddone,),0=3D;;,0=3D;&
setlocal indentkeys+=3D0=3Dfin,0=3Dfil,0=3Dfip,0=3Dfir,0=3Dfix
@@ -22,7 +30,7 @@
set cpo&vim
=20
function s:buffer_shiftwidth()
- return &shiftwidth
+ return s:Shiftwidth()
endfunction
=20
let s:sh_indent_defaults =3D {
diff -r eccc57e1caa0 runtime/indent/sml.vim
--- a/runtime/indent/sml.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/sml.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -18,6 +18,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal expandtab
setlocal indentexpr=3DGetSMLIndent()
setlocal indentkeys+=3D0=3Dand,0=3Delse,0=3Dend,0=3Dhandle,0=3Dif,0=3Din,0=
=3Dlet,0=3Dthen,0=3Dval,0=3Dfun,0=3D\|,0=3D*),0)
@@ -115,9 +123,9 @@
=20
=09" Return double 'shiftwidth' after lines matching:
=09if lline =3D~ '^\s*|.*=3D>\s*$'
-=09=09return ind + &sw + &sw
+=09=09return ind + s:Shiftwidth() + s:Shiftwidth()
=09elseif lline =3D~ '^\s*val\>.*=3D\s*$'
-=09=09return ind + &sw
+=09=09return ind + s:Shiftwidth()
=09endif
=20
let line =3D getline(v:lnum)
@@ -157,7 +165,7 @@
=09=09if lastModule =3D=3D -1
=09=09=09return 0
=09=09else
-=09=09=09return lastModule + &sw
+=09=09=09return lastModule + s:Shiftwidth()
=09=09endif
=20
=09" Indent lines starting with '|' from matching 'case', 'handle'
@@ -172,7 +180,7 @@
=09=09if switchLine =3D~ '\<case\>'
=09=09=09return col(".") + 2
=09=09elseif switchLine =3D~ '\<handle\>'
-=09=09=09return switchLineIndent + &sw
+=09=09=09return switchLineIndent + s:Shiftwidth()
=09=09elseif switchLine =3D~ '\<datatype\>'
=09=09=09call search('=3D')
=09=09=09return col(".") - 1
@@ -184,7 +192,7 @@
" Indent if last line ends with 'sig', 'struct', 'let', 'then', 'else',
" 'in'
elseif lline =3D~ '\<\(sig\|struct\|let\|in\|then\|else\)\s*$'
-=09=09let ind =3D ind + &sw
+=09=09let ind =3D ind + s:Shiftwidth()
=20
" Indent if last line ends with 'of', align from 'case'
elseif lline =3D~ '\<\(of\)\s*$'
@@ -199,14 +207,14 @@
=20
=09" Indent if last line starts with 'fun', 'case', 'fn'
=09elseif lline =3D~ '^\s*\(fun\|fn\|case\)\>'
-=09=09let ind =3D ind + &sw
+=09=09let ind =3D ind + s:Shiftwidth()
=20
=09endif
=20
=09" Don't indent 'let' if last line started with 'fun', 'fn'
=09if line =3D~ '^\s*let\>'
=09=09if lline =3D~ '^\s*\(fun\|fn\)'
-=09=09=09let ind =3D ind - &sw
+=09=09=09let ind =3D ind - s:Shiftwidth()
=09=09endif
endif
=20
diff -r eccc57e1caa0 runtime/indent/sqlanywhere.vim
--- a/runtime/indent/sqlanywhere.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/sqlanywhere.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -26,6 +26,14 @@
let b:did_indent =3D 1
let b:current_indent =3D "sqlanywhere"
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentkeys-=3D0{
setlocal indentkeys-=3D0}
setlocal indentkeys-=3D:
@@ -136,7 +144,7 @@
endwhile
=20
" Fallback - just move back one
- " return a:prev_indent - &sw
+ " return a:prev_indent - s:Shiftwidth()
return ignore_paran
endfunction
=20
@@ -155,7 +163,7 @@
let lnum =3D a:curr_lnum
=20
" Default - reduce indent by 1
- let ind =3D indent(a:curr_lnum) - &sw
+ let ind =3D indent(a:curr_lnum) - s:Shiftwidth()
=20
if a:keyword =3D~? 'end'
exec 'normal! ^'
@@ -219,7 +227,7 @@
let ind =3D a:ind
=20
if ind > 0
- let modulo =3D ind % &shiftwidth
+ let modulo =3D ind % s:Shiftwidth()
=20
if modulo > 0
let ind =3D ind - modulo
@@ -288,7 +296,7 @@
" where END IF, END, should decrease the indent.
if prevline =3D~? s:SQLBlockStart
" Move indent in
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
" echom 'prevl - SQLBlockStart - indent ' . ind . ' line: ' . pre=
vline
elseif prevline =3D~ '[()]'
if prevline =3D~ '('
@@ -305,7 +313,7 @@
if num_unmatched_left > 0
" There is a open left paranethesis
" increase indent
- let ind =3D ind + ( &sw * num_unmatched_left )
+ let ind =3D ind + ( s:Shiftwidth() * num_unmatched_left )
elseif num_unmatched_right > 0
" if it is an unbalanced paranethesis only unindent if
" it was part of a command (ie create table(..) )
@@ -320,7 +328,7 @@
endif
=20
if (num_unmatched_right - ignore) > 0
- let ind =3D ind - ( &sw * (num_unmatched_right - ignore) )
+ let ind =3D ind - ( s:Shiftwidth() * (num_unmatched_right =
- ignore) )
endif
=20
endif
@@ -336,12 +344,12 @@
if line =3D~? '^\s*els'
" Any line when you type else will automatically back up one
" ident level (ie else, elseif, elsif)
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
" echom 'curr - else - indent ' . ind
elseif line =3D~? '^\s*end\>'
let ind =3D s:GetStmtStarterIndent('end', v:lnum)
" General case for end
- " let ind =3D ind - &sw
+ " let ind =3D ind - s:Shiftwidth()
" echom 'curr - end - indent ' . ind
elseif line =3D~? '^\s*when\>'
let ind =3D s:GetStmtStarterIndent('when', v:lnum)
@@ -349,7 +357,7 @@
" clause, do not change the indent level, since these
" statements do not have a corresponding END statement.
" if stmt_starter =3D~? 'case'
- " let ind =3D ind - &sw
+ " let ind =3D ind - s:Shiftwidth()
" endif
" elseif line =3D~ '^\s*)\s*;\?\s*$'
" elseif line =3D~ '^\s*)'
@@ -368,14 +376,14 @@
" let num_unmatched_right =3D s:CountUnbalancedParan( line, ')' )
" if num_unmatched_right > 0
" elseif strpart( line, strlen(line)-1, 1 ) =3D~ ')'
- " let ind =3D ind - &sw
+ " let ind =3D ind - s:Shiftwidth()
if line =3D~ '^\s*)'
" let ignore =3D ignore + 1
" echom 'curr - begins ) unbalanced ignore: ' . ignore
endif
=20
if (num_unmatched_right - ignore) > 0
- let ind =3D ind - ( &sw * (num_unmatched_right - ignore) )
+ let ind =3D ind - ( s:Shiftwidth() * (num_unmatched_right - ig=
nore) )
endif
" endif
endif
diff -r eccc57e1caa0 runtime/indent/tcl.vim
--- a/runtime/indent/tcl.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/tcl.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -8,6 +8,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentexpr=3DGetTclIndent()
setlocal indentkeys=3D0{,0},!^F,o,O,0]
setlocal nosmartindent
@@ -56,7 +64,7 @@
if line =3D~ '^\s*\*'
return cindent(v:lnum)
elseif line =3D~ '^\s*}'
- return indent(v:lnum) - &sw
+ return indent(v:lnum) - s:Shiftwidth()
endif
=20
let pnum =3D s:prevnonblanknoncomment(v:lnum - 1)
@@ -64,11 +72,11 @@
return 0
endif
=20
- let ind =3D indent(pnum) + s:count_braces(pnum, 1) * &sw
+ let ind =3D indent(pnum) + s:count_braces(pnum, 1) * s:Shiftwidth()
=20
let pline =3D getline(pnum)
if pline =3D~ '}\s*$'
- let ind -=3D (s:count_braces(pnum, 0) - (pline =3D~ '^\s*}' ? 1 : 0)) =
* &sw
+ let ind -=3D (s:count_braces(pnum, 0) - (pline =3D~ '^\s*}' ? 1 : 0)) =
* s:Shiftwidth()
endif
=20
return ind
diff -r eccc57e1caa0 runtime/indent/tcsh.vim
--- a/runtime/indent/tcsh.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/tcsh.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -8,6 +8,14 @@
finish
endif
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
let b:did_indent =3D 1
=20
setlocal indentexpr=3DTcshGetIndent()
@@ -32,17 +40,17 @@
let ind =3D indent(lnum)
let line =3D getline(lnum)
if line =3D~ '\v^\s*%(while|foreach)>|^\s*%(case\s.*:|default:|else)\s=
*$|%(<then|\\)$'
-=09let ind =3D ind + &sw
+=09let ind =3D ind + s:Shiftwidth()
endif
=20
if line =3D~ '\v^\s*breaksw>'
-=09let ind =3D ind - &sw
+=09let ind =3D ind - s:Shiftwidth()
endif
=20
" Subtract indent if current line has on end, endif, case commands
let line =3D getline(v:lnum)
if line =3D~ '\v^\s*%(else|end|endif)\s*$'
-=09let ind =3D ind - &sw
+=09let ind =3D ind - s:Shiftwidth()
endif
=20
return ind
diff -r eccc57e1caa0 runtime/indent/tex.vim
--- a/runtime/indent/tex.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/tex.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -110,6 +110,14 @@
finish
endif
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
if exists("b:did_indent")
finish
endif
@@ -216,12 +224,12 @@
" LH modification : \begin does not always start a line
" ZYC modification : \end after \begin won't cause wrong indent anymor=
e
if line =3D~ '\\begin{.*}' && line !~ g:tex_noindent_env
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
=20
if g:tex_indent_items
" Add another sw for item-environments
if line =3D~ g:tex_itemize_env
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
endif
endif
@@ -232,11 +240,11 @@
if g:tex_indent_items
" Remove another sw for item-environments
if cline =3D~ g:tex_itemize_env
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
endif
=20
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
=20
if g:tex_indent_brace
@@ -264,7 +272,7 @@
endif
endfor
=20
- let ind +=3D (sum1 - sum2) * &sw
+ let ind +=3D (sum1 - sum2) * s:Shiftwidth()
endif
=20
if g:tex_indent_paretheses
@@ -277,12 +285,12 @@
=20
" '\item' or '\bibitem' itself:
if cline =3D~ g:tex_items
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
=20
" lines following to '\item' are intented once again:
if line =3D~ g:tex_items
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
=20
endif
diff -r eccc57e1caa0 runtime/indent/tf.vim
--- a/runtime/indent/tf.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/tf.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -10,6 +10,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentexpr=3DGetTFIndent()
setlocal indentkeys-=3D0{,0} indentkeys-=3D0# indentkeys-=3D:
setlocal indentkeys+=3D=3D/endif,=3D/then,=3D/else,=3D/done,0;
@@ -38,14 +46,14 @@
=09endif
=20
=09if line =3D~ '\(/def.*\\\|/for.*\(%;\s*\)\@\<!\\\)$'
-=09=09let ind =3D ind + &sw
+=09=09let ind =3D ind + s:Shiftwidth()
=09elseif line =3D~ '\(/if\|/else\|/then\)'
=09=09if line !~ '/endif'
-=09=09=09let ind =3D ind + &sw
+=09=09=09let ind =3D ind + s:Shiftwidth()
=09=09endif
=09elseif line =3D~ '/while'
=09=09if line !~ '/done'
-=09=09=09let ind =3D ind + &sw
+=09=09=09let ind =3D ind + s:Shiftwidth()
=09=09endif
=09endif
=20
@@ -53,11 +61,11 @@
=20
=09if line =3D~ '\(/else\|/endif\|/then\)'
=09=09if line !~ '/if'
-=09=09=09let ind =3D ind - &sw
+=09=09=09let ind =3D ind - s:Shiftwidth()
=09=09endif
=09elseif line =3D~ '/done'
=09=09if line !~ '/while'
-=09=09=09let ind =3D ind - &sw
+=09=09=09let ind =3D ind - s:Shiftwidth()
=09=09endif
=09endif
=20
diff -r eccc57e1caa0 runtime/indent/tilde.vim
--- a/runtime/indent/tilde.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/tilde.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -7,6 +7,14 @@
=09finish
endif
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
let b:did_indent =3D 1
=20
setlocal autoindent
@@ -25,11 +33,11 @@
=09endif
=20
=09if getline(v:lnum) =3D~ '^\s*\~\(endif\|else\|elseif\|end\)\>'
-=09=09return indent(v:lnum) - &sw
+=09=09return indent(v:lnum) - s:Shiftwidth()
=09endif
=20
=09if getline(plnum) =3D~ '^\s*\~\(if\|foreach\|foreach_row\|xml_loop\|fil=
e_loop\|file_write\|file_append\|imap_loopsections\|imap_index\|imap_list\|=
ldap_search\|post_loopall\|post_loop\|file_loop\|sql_loop_num\|sql_dbmssele=
ct\|search\|sql_loop\|post\|for\|function_define\|silent\|while\|setvalbig\=
|mail_create\|systempipe\|mail_send\|dual\|elseif\|else\)\>'
-=09=09return indent(plnum) + &sw
+=09=09return indent(plnum) + s:Shiftwidth()
=09else
=09=09return -1
=09endif
diff -r eccc57e1caa0 runtime/indent/treetop.vim
--- a/runtime/indent/treetop.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/treetop.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -8,6 +8,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentexpr=3DGetTreetopIndent()
setlocal indentkeys=3D0{,0},!^F,o,O,=3Dend
setlocal nosmartindent
@@ -26,12 +34,12 @@
let line =3D getline(pnum)
=20
if line =3D~ '^\s*\%(grammar\|module\|rule\)\>'
- let ind +=3D &sw
+ let ind +=3D s:Shiftwidth()
endif
=20
let line =3D getline(v:lnum)
if line =3D~ '^\s*end\>'
- let ind -=3D &sw
+ let ind -=3D s:Shiftwidth()
end
=20
retur ind
diff -r eccc57e1caa0 runtime/indent/vb.vim
--- a/runtime/indent/vb.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/vb.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -9,6 +9,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal autoindent
setlocal indentexpr=3DVbGetIndent(v:lnum)
setlocal indentkeys&
@@ -49,26 +57,26 @@
=20
" Add
if previous_line =3D~? '^\s*\<\(begin\|\%(\%(private\|public\|friend\)=
\s\+\)\=3D\%(function\|sub\|property\)\|select\|case\|default\|if\|else\|el=
seif\|do\|for\|while\|enum\|with\)\>'
-=09let ind =3D ind + &sw
+=09let ind =3D ind + s:Shiftwidth()
endif
=20
" Subtract
if this_line =3D~? '^\s*\<end\>\s\+\<select\>'
=09if previous_line !~? '^\s*\<select\>'
-=09 let ind =3D ind - 2 * &sw
+=09 let ind =3D ind - 2 * s:Shiftwidth()
=09else
=09 " this case is for an empty 'select' -- 'end select'
=09 " (w/o any case statements) like:
=09 "
=09 " select case readwrite
=09 " end select
-=09 let ind =3D ind - &sw
+=09 let ind =3D ind - s:Shiftwidth()
=09endif
elseif this_line =3D~? '^\s*\<\(end\|else\|elseif\|until\|loop\|next\|=
wend\)\>'
-=09let ind =3D ind - &sw
+=09let ind =3D ind - s:Shiftwidth()
elseif this_line =3D~? '^\s*\<\(case\|default\)\>'
=09if previous_line !~? '^\s*\<select\>'
-=09 let ind =3D ind - &sw
+=09 let ind =3D ind - s:Shiftwidth()
=09endif
endif
=20
diff -r eccc57e1caa0 runtime/indent/verilog.vim
--- a/runtime/indent/verilog.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/verilog.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -20,6 +20,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentexpr=3DGetVerilogIndent()
setlocal indentkeys=3D!^F,o,O,0),=3Dbegin,=3Dend,=3Djoin,=3Dendcase
setlocal indentkeys+=3D=3Dendmodule,=3Dendfunction,=3Dendtask,=3Dendspecif=
y
@@ -38,7 +46,7 @@
if exists('b:verilog_indent_width')
let offset =3D b:verilog_indent_width
else
- let offset =3D &sw
+ let offset =3D s:Shiftwidth()
endif
if exists('b:verilog_indent_modules')
let indent_modules =3D offset
diff -r eccc57e1caa0 runtime/indent/vhdl.vim
--- a/runtime/indent/vhdl.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/vhdl.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -11,6 +11,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
" setup indent options for local VHDL buffer
setlocal indentexpr=3DGetVHDLindent()
setlocal indentkeys=3D!^F,o,O,0(,0)
@@ -114,9 +122,9 @@
return ind2 + m
else
if g:vhdl_indent_genportmap
- return ind2 + stridx(prevs_noi, '(') + &sw
+ return ind2 + stridx(prevs_noi, '(') + s:Shiftwidth()
else
- return ind2 + &sw
+ return ind2 + s:Shiftwidth()
endif
endif
endif
@@ -128,7 +136,7 @@
if g:vhdl_indent_rhsassign
return ind2 + matchend(prevs_noi, '<=3D\s*\ze.')
else
- return ind2 + &sw
+ return ind2 + s:Shiftwidth()
endif
endif
=20
@@ -218,12 +226,12 @@
let ps =3D getline(pn)
=20
if (ps =3D~? s:NC.'\<begin\>')
- return indent(pn) - &sw
+ return indent(pn) - s:Shiftwidth()
endif
endwhile
=20
if (pn =3D=3D 0)
- return ind - &sw
+ return ind - s:Shiftwidth()
else
return indent(pn)
endif
@@ -237,7 +245,7 @@
" keyword: "type"
let s3 =3D s:NC.s:NE.'\<type\>'
if curs !~? s3.'.*'.s:NC.'\<\%(record\|units\)\>.*'.s:ES && prevs =3D~=
? s3
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
return ind
endif
@@ -282,7 +290,7 @@
" removed: "begin", "case", "elsif", "if", "loop", "record", "units", "=
while"
" where: anywhere in previous line
if prevs =3D~? s:NC.s:NE.'\<\%(block\|process\)\>'
- return ind + &sw
+ return ind + s:Shiftwidth()
endif
=20
" indent: +sw
@@ -290,7 +298,7 @@
" removed: "component", "for", "when", "with"
" where: start of previous line
if prevs =3D~? '^\s*\%(architecture\|configuration\|entity\|package\)\>'
- return ind + &sw
+ return ind + s:Shiftwidth()
endif
=20
" indent: +sw
@@ -298,7 +306,7 @@
" removed: "generate", "is", "=3D>"
" where: end of previous line
if prevs =3D~? s:NC.'\<select'.s:ES
- return ind + &sw
+ return ind + s:Shiftwidth()
endif
=20
" indent: +sw
@@ -310,7 +318,7 @@
" where: end of previous line
" _note_: indent allowed to leave this filter
if prevs =3D~? s:NC.'\%(\<begin\>\|'.s:NE.'\<\%(loop\|record\|units\)\>\=
)' || prevs =3D~? '^\s*\%(component\|else\|for\)\>' || prevs =3D~? s:NC.'\%=
('.s:NE.'\<generate\|\<\%(is\|then\)\|=3D>\)'.s:ES
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
=20
" **********************************************************************=
******************
@@ -322,7 +330,7 @@
if prevs =3D~? s:NC.'\<is'.s:ES
return ind
elseif prevs !~? s4
- return ind - &sw
+ return ind - s:Shiftwidth()
else
return ind2
endif
@@ -336,7 +344,7 @@
if prevs =3D~? '^\s*\%(elsif\|'.s5.'\)'
return ind
else
- return ind - &sw
+ return ind - s:Shiftwidth()
endif
endif
=20
@@ -367,9 +375,9 @@
"where: start of previous non-comment line
if m =3D=3D 1
if ps =3D~? '^\s*end\s\+case\>'
- return indent(pn) - 2 * &sw
+ return indent(pn) - 2 * s:Shiftwidth()
elseif ps =3D~? '^\s*when\>'
- return indent(pn) - &sw
+ return indent(pn) - s:Shiftwidth()
elseif ps =3D~? '^\s*case\>'
return indent(pn)
endif
@@ -385,14 +393,14 @@
let pn =3D prevnonblank(pn - 1)
let ps =3D getline(pn)
endwhile
- return ind - &sw
+ return ind - s:Shiftwidth()
endif
=20
" indent: -sw
" keyword: ")"
" where: start of current line
if curs =3D~ '^\s*)'
- return ind - &sw
+ return ind - s:Shiftwidth()
endif
=20
" indent: 0
@@ -407,7 +415,7 @@
" where: start of current line
"if curs =3D~? '^\s*end\s\+\w\+\>'
if curs =3D~? '^\s*end\%(\s\|;'.s:ES.'\)'
- return ind - &sw
+ return ind - s:Shiftwidth()
endif
=20
" **********************************************************************=
******************
diff -r eccc57e1caa0 runtime/indent/vim.vim
--- a/runtime/indent/vim.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/vim.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -9,6 +9,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentexpr=3DGetVimIndent()
setlocal indentkeys+=3D=3Dend,=3Delse,=3Dcat,=3Dfina,=3DEND,0\\
=20
@@ -56,18 +64,18 @@
if exists("g:vim_indent_cont")
let ind =3D ind + g:vim_indent_cont
else
- let ind =3D ind + &sw * 3
+ let ind =3D ind + s:Shiftwidth() * 3
endif
elseif getline(lnum) =3D~ '^\s*aug\%[roup]' && getline(lnum) !~ '^\s*aug=
\%[roup]\s*!\=3D\s\+END'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
else
let line =3D getline(lnum)
let i =3D match(line, '\(^\||\)\s*\(if\|wh\%[ile]\|for\|try\|cat\%[ch]=
\|fina\%[lly]\|fu\%[nction]\|el\%[seif]\)\>')
if i >=3D 0
- let ind +=3D &sw
+ let ind +=3D s:Shiftwidth()
if strpart(line, i, 1) =3D=3D '|' && has('syntax_items')
\ && synIDattr(synID(lnum, i, 1), "name") =3D~ '\(Comment\|Str=
ing\)$'
- let ind -=3D &sw
+ let ind -=3D s:Shiftwidth()
endif
endif
endif
@@ -79,7 +87,7 @@
let i =3D match(line, '[^\\]|\s*\(ene\@!\)')
if i > 0 && line !~ '^\s*au\%[tocmd]'
if !has('syntax_items') || synIDattr(synID(lnum, i + 2, 1), "name") !~=
'\(Comment\|String\)$'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
endif
=20
@@ -87,7 +95,7 @@
" Subtract a 'shiftwidth' on a :endif, :endwhile, :catch, :finally, :end=
try,
" :endfun, :else and :augroup END.
if getline(v:lnum) =3D~ '^\s*\(ene\@!\|cat\|fina\|el\|aug\%[roup]\s*!\=
=3D\s\+END\)'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
=20
return ind
diff -r eccc57e1caa0 runtime/indent/xf86conf.vim
--- a/runtime/indent/xf86conf.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/xf86conf.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -8,6 +8,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentexpr=3DGetXF86ConfIndent()
setlocal indentkeys=3D!^F,o,O,=3DEnd
setlocal nosmartindent
@@ -26,11 +34,11 @@
let ind =3D indent(lnum)
=20
if getline(lnum) =3D~? '^\s*\(Sub\)\=3DSection\>'
- let ind =3D ind + &sw
+ let ind =3D ind + s:Shiftwidth()
endif
=20
if getline(v:lnum) =3D~? '^\s*End\(Sub\)\=3DSection\>'
- let ind =3D ind - &sw
+ let ind =3D ind - s:Shiftwidth()
endif
=20
return ind
diff -r eccc57e1caa0 runtime/indent/xinetd.vim
--- a/runtime/indent/xinetd.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/xinetd.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -8,6 +8,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal indentexpr=3DGetXinetdIndent()
setlocal indentkeys=3D0{,0},!^F,o,O
setlocal nosmartindent
@@ -47,8 +55,8 @@
return 0
endif
=20
- return indent(pnum) + s:count_braces(pnum, 1) * &sw
- \ - s:count_braces(v:lnum, 0) * &sw
+ return indent(pnum) + s:count_braces(pnum, 1) * s:Shiftwidth()
+ \ - s:count_braces(v:lnum, 0) * s:Shiftwidth()
endfunction
=20
let &cpo =3D s:keepcpo
diff -r eccc57e1caa0 runtime/indent/xml.vim
--- a/runtime/indent/xml.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/xml.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -15,6 +15,14 @@
let s:keepcpo=3D &cpo
set cpo&vim
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
" [-- local settings (must come before aborting the script) --]
setlocal indentexpr=3DXmlIndentGet(v:lnum,1)
setlocal indentkeys=3Do,O,*<Return>,<>>,<<>,/,{,}
@@ -67,7 +75,7 @@
fun! <SID>XmlIndentSum(lnum, style, add)
let line =3D getline(a:lnum)
if a:style =3D=3D match(line, '^\s*</')
-=09return (&sw *
+=09return (s:Shiftwidth() *
=09\ (<SID>XmlIndentWithPattern(line, b:xml_indent_open)
=09\ - <SID>XmlIndentWithPattern(line, b:xml_indent_close)
=09\ - <SID>XmlIndentWithPattern(line, '.\{-}/>'))) + a:add
diff -r eccc57e1caa0 runtime/indent/zimbu.vim
--- a/runtime/indent/zimbu.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/indent/zimbu.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -9,6 +9,14 @@
endif
let b:did_indent =3D 1
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
setlocal ai nolisp nocin
setlocal indentexpr=3DGetZimbuIndent(v:lnum)
setlocal indentkeys=3D0{,0},!^F,o,O,0=3DELSE,0=3DELSEIF,0=3DCASE,0=3DDEFAU=
LT,0=3DFINALLY
@@ -74,9 +82,9 @@
=09 \ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
=09 \ . " =3D~ '\\(Comment\\|String\\|Char\\)$'")
if pp > 0
-=09return indent(prevLnum) + &sw
+=09return indent(prevLnum) + s:Shiftwidth()
endif
- return indent(prevLnum) + &sw * 2
+ return indent(prevLnum) + s:Shiftwidth() * 2
endif
if plnumstart =3D=3D p
return indent(prevLnum)
@@ -102,13 +110,13 @@
endif
=20
if prevline =3D~ '^\s*\(IF\|\|ELSEIF\|ELSE\|GENERATE_IF\|\|GENERATE_ELSE=
IF\|GENERATE_ELSE\|WHILE\|REPEAT\|TRY\|CATCH\|FINALLY\|FOR\|DO\|SWITCH\|CAS=
E\|DEFAULT\|FUNC\|VIRTUAL\|ABSTRACT\|DEFINE\|REPLACE\|FINAL\|PROC\|MAIN\|NE=
W\|ENUM\|CLASS\|INTERFACE\|BITS\|MODULE\|SHARED\)\>'
- let plindent +=3D &sw
+ let plindent +=3D s:Shiftwidth()
endif
if thisline =3D~ '^\s*\(}\|ELSEIF\>\|ELSE\>\|CATCH\|FINALLY\|GENERATE_EL=
SEIF\>\|GENERATE_ELSE\>\|UNTIL\>\)'
- let plindent -=3D &sw
+ let plindent -=3D s:Shiftwidth()
endif
if thisline =3D~ '^\s*\(CASE\>\|DEFAULT\>\)' && prevline !~ '^\s*SWITCH\=
>'
- let plindent -=3D &sw
+ let plindent -=3D s:Shiftwidth()
endif
=20
" line up continued comment that started after some code
diff -r eccc57e1caa0 runtime/macros/justify.vim
--- a/runtime/macros/justify.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/macros/justify.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -136,6 +136,16 @@
endfunction
=20
=20
+" Get the corrected shiftwidth.
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+=09return &sw ? &sw : &ts
+ endfunction
+endif
+
+
" Now for the real thing
function! Justify(...) range
=20
@@ -203,7 +213,7 @@
=09 endwhile
=09 let indent_sw =3D 0
=09 if a:3 =3D~ '\(shiftwidth\|sw\)'
-=09=09let indent_sw =3D &sw
+=09=09let indent_sw =3D s:Shiftwidth()
=09 elseif a:3 =3D~ '\(tabstop\|ts\)'
=09=09let indent_sw =3D &ts
=09 endif
diff -r eccc57e1caa0 runtime/optwin.vim
--- a/runtime/optwin.vim=09Tue Oct 16 14:19:08 2012 -0700
+++ b/runtime/optwin.vim=09Tue Oct 16 15:03:58 2012 -0700
@@ -17,6 +17,14 @@
endwhile
endif
=20
+if exists('*shiftwidth')
+ s:Shiftwidth=3Dfunction('shiftwidth')
+else
+ function s:Shiftwidth()
+ return &sw ? &sw : &ts
+ endfunction
+endif
+
" Make sure the '<' flag is not included in 'cpoptions', otherwise <CR> wo=
uld
" not be recognized. See ":help 'cpoptions'".
let s:cpo_save =3D &cpo
@@ -469,7 +477,7 @@
call <SID>BinOptionG("hid", &hid)
call append("$", "switchbuf\t\"useopen\" and/or \"split\"; which window to=
use when jumping")
call append("$", "\tto a buffer")
-call <SID>OptionG("swb", &swb)
+call <SID>OptionG("swb", s:Shiftwidth()b)
call append("$", "splitbelow\ta new window is put below the current one")
call <SID>BinOptionG("sb", &sb)
if has("vertsplit")
@@ -1000,7 +1008,7 @@
call append("$", "\t(local to buffer)")
call <SID>BinOptionL("swf")
call append("$", "swapsync\t\"sync\", \"fsync\" or empty; how to flush a s=
wap file to disk")
-call <SID>OptionG("sws", &sws)
+call <SID>OptionG("sws", s:Shiftwidth()s)
call append("$", "updatecount\tnumber of characters typed to cause a swap =
file update")
call append("$", " \tset uc=3D" . &uc)
call append("$", "updatetime\ttime in msec after which the swap file will =
be updated")
------=_Part_178_17135997.1350425122033--