summaryrefslogtreecommitdiff
path: root/runtime/indent
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/indent')
-rw-r--r--runtime/indent/dtd.vim42
-rw-r--r--runtime/indent/eiffel.vim21
-rw-r--r--runtime/indent/eterm.vim4
-rw-r--r--runtime/indent/framescript.vim4
-rw-r--r--runtime/indent/java.vim29
-rw-r--r--runtime/indent/ld.vim6
-rw-r--r--runtime/indent/make.vim10
-rw-r--r--runtime/indent/readline.vim4
-rw-r--r--runtime/indent/sas.vim138
-rw-r--r--runtime/indent/scala.vim34
-rw-r--r--runtime/indent/tcl.vim6
-rw-r--r--runtime/indent/tcsh.vim6
-rw-r--r--runtime/indent/treetop.vim4
-rw-r--r--runtime/indent/xf86conf.vim4
-rw-r--r--runtime/indent/xinetd.vim4
15 files changed, 229 insertions, 87 deletions
diff --git a/runtime/indent/dtd.vim b/runtime/indent/dtd.vim
index 779cee9e6..563336236 100644
--- a/runtime/indent/dtd.vim
+++ b/runtime/indent/dtd.vim
@@ -84,7 +84,7 @@ function GetDTDIndent()
let [declaration, end] = s:lex1(line, col)
if declaration == ""
- return indent + &sw
+ return indent + shiftwidth()
elseif declaration == '--'
" 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 +100,7 @@ function GetDTDIndent()
" Check for element name. If none exists, indent one level.
let [name, end] = s:lex(line, end)
if name == ""
- return indent + &sw
+ return indent + shiftwidth()
endif
" Check for token following element name. This can be a specification of
@@ -113,7 +113,7 @@ function GetDTDIndent()
let n += 1
endwhile
if token == ""
- return indent + &sw
+ return indent + shiftwidth()
endif
" Next comes the content model. If the token we’ve found isn’t a
@@ -148,7 +148,7 @@ function GetDTDIndent()
return indent
endif
" TODO: Should use s:lex here on getline(v:lnum) and check for >.
- return getline(v:lnum) =~ '^\s*>' || count(values(seen), 0) == 0 ? indent : (indent + &sw)
+ return getline(v:lnum) =~ '^\s*>' || count(values(seen), 0) == 0 ? indent : (indent + shiftwidth())
endif
" If we’ve seen an addition or exception already and this is of the same
@@ -167,7 +167,7 @@ function GetDTDIndent()
" Check for element name. If none exists, indent one level.
let [name, end] = s:lex(line, end)
if name == ""
- return indent + &sw
+ return indent + shiftwidth()
endif
" Check for any number of attributes.
@@ -180,7 +180,7 @@ function GetDTDIndent()
let [name, end] = s:lex(line, end)
if name == ""
" TODO: Should use s:lex here on getline(v:lnum) and check for >.
- return getline(v:lnum) =~ '^\s*>' ? indent : (indent + &sw)
+ return getline(v:lnum) =~ '^\s*>' ? indent : (indent + shiftwidth())
elseif name == ">"
return indent
endif
@@ -194,14 +194,14 @@ function GetDTDIndent()
" (CDATA|NMTOKEN|NMTOKENS|ID|IDREF|IDREFS|ENTITY|ENTITIES)?
let [value, end] = s:lex(line, end, '^\%((\|[^[:space:]]\+\)')
if value == ""
- return indent + &sw * 2
+ return indent + shiftwidth() * 2
elseif value == 'NOTATION'
" If this is a enumerated value based on notations, read another token
" 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] = s:lex(line, end, '^\%((\|[^[:space:]]\+\)')
if value == ""
- return indent + &sw * 3
+ return indent + shiftwidth() * 3
endif
endif
@@ -216,13 +216,13 @@ function GetDTDIndent()
" two levels.
let [default, end] = s:lex(line, end, '^\%("\_[^"]*"\|#\(REQUIRED\|IMPLIED\|FIXED\)\)')
if default == ""
- return indent + &sw * 2
+ return indent + shiftwidth() * 2
elseif default == '#FIXED'
" We need to look for the fixed value. If non exists, indent three
" levels.
let [default, end] = s:lex(line, end, '^"\_[^"]*"')
if default == ""
- return indent + &sw * 3
+ return indent + shiftwidth() * 3
endif
endif
endwhile
@@ -233,11 +233,11 @@ function GetDTDIndent()
" again, if none exists, indent one level.
let [name, end] = s:lex(line, end)
if name == ""
- return indent + &sw
+ return indent + shiftwidth()
elseif name == '%'
let [name, end] = s:lex(line, end)
if name == ""
- return indent + &sw
+ return indent + shiftwidth()
endif
endif
@@ -256,27 +256,27 @@ function GetDTDIndent()
" we’re now done with this entity.
let [value, end] = s:lex(line, end)
if value == ""
- return indent + &sw
+ return indent + shiftwidth()
elseif value == 'SYSTEM' || value == 'PUBLIC'
let [quoted_string, end] = s:lex(line, end, '\%("[^"]\+"\|''[^'']\+''\)')
if quoted_string == ""
- return indent + &sw * 2
+ return indent + shiftwidth() * 2
endif
if value == 'PUBLIC'
let [quoted_string, end] = s:lex(line, end, '\%("[^"]\+"\|''[^'']\+''\)')
if quoted_string == ""
- return indent + &sw * 2
+ return indent + shiftwidth() * 2
endif
endif
let [ndata, end] = s:lex(line, end)
if ndata == ""
- return indent + &sw
+ return indent + shiftwidth()
endif
let [name, end] = s:lex(line, end)
- return name == "" ? (indent + &sw * 2) : indent
+ return name == "" ? (indent + shiftwidth() * 2) : indent
else
return indent
endif
@@ -284,24 +284,24 @@ function GetDTDIndent()
" Check for notation name. If none exists, indent one level.
let [name, end] = s:lex(line, end)
if name == ""
- return indent + &sw
+ return indent + shiftwidth()
endif
" Now check for the external ID. If none exists, indent one level.
let [id, end] = s:lex(line, end)
if id == ""
- return indent + &sw
+ return indent + shiftwidth()
elseif id == 'SYSTEM' || id == 'PUBLIC'
let [quoted_string, end] = s:lex(line, end, '\%("[^"]\+"\|''[^'']\+''\)')
if quoted_string == ""
- return indent + &sw * 2
+ return indent + shiftwidth() * 2
endif
if id == 'PUBLIC'
let [quoted_string, end] = s:lex(line, end, '\%("[^"]\+"\|''[^'']\+''\|>\)')
if quoted_string == ""
" TODO: Should use s:lex here on getline(v:lnum) and check for >.
- return getline(v:lnum) =~ '^\s*>' ? indent : (indent + &sw * 2)
+ return getline(v:lnum) =~ '^\s*>' ? indent : (indent + shiftwidth() * 2)
elseif quoted_string == '>'
return indent
endif
diff --git a/runtime/indent/eiffel.vim b/runtime/indent/eiffel.vim
index 87e82e833..d7667a834 100644
--- a/runtime/indent/eiffel.vim
+++ b/runtime/indent/eiffel.vim
@@ -2,9 +2,10 @@
" Language: Eiffel
" Maintainer: Jocelyn Fiat <jfiat@eiffel.com>
" Previous-Maintainer: David Clarke <gadicath@dishevelled.net>
+" Contributions from: Takuya Fujiwara
" Contributions from: Thilo Six
-" $Date: 2004/12/09 21:33:52 $
-" $Revision: 1.3 $
+" $Date: 2017/03/08 06:00:00 $
+" $Revision: 1.4 $
" URL: https://github.com/eiffelhub/vim-eiffel
" Only load this indent file when no other was loaded.
@@ -28,7 +29,7 @@ let b:undo_indent = "setl smartindent< indentkeys< indentexpr< autoindent< comme
" Define some stuff
" keywords grouped by indenting
let s:trust_user_indent = '\(+\)\(\s*\(--\).*\)\=$'
-let s:relative_indent = '^\s*\(deferred\|class\|feature\|creation\|inherit\|loop\|from\|until\|if\|else\|elseif\|ensure\|require\|check\|do\|local\|invariant\|variant\|rename\|redefine\|do\|export\)\>'
+let s:relative_indent = '^\s*\(deferred\|class\|feature\|creation\|inherit\|loop\|from\|across\|until\|if\|else\|elseif\|ensure\|require\|check\|do\|local\|invariant\|variant\|rename\|redefine\|do\|export\)\>'
let s:outdent = '^\s*\(else\|invariant\|variant\|do\|require\|until\|loop\|local\)\>'
let s:no_indent = '^\s*\(class\|feature\|creation\|inherit\)\>'
let s:single_dent = '^[^-]\+[[:alnum:]]\+ is\(\s*\(--\).*\)\=$'
@@ -63,23 +64,23 @@ function GetEiffelIndent()
" Add a 'shiftwidth' after lines that start with an indent word
let ind = indent(lnum)
if getline(lnum) =~ s:relative_indent
- let ind = ind + &sw
+ let ind = ind + shiftwidth()
endif
" Indent to single indent
if getline(v:lnum) =~ s:single_dent && getline(v:lnum) !~ s:relative_indent
\ && getline(v:lnum) !~ '\s*\<\(and\|or\|implies\)\>'
- let ind = &sw
+ let ind = shiftwidth()
endif
" Indent to double indent
if getline(v:lnum) =~ s:inheritance_dent
- let ind = 2 * &sw
+ let ind = 2 * shiftwidth()
endif
" Indent line after the first line of the function definition
if getline(lnum) =~ s:single_dent
- let ind = ind + &sw
+ let ind = ind + shiftwidth()
endif
" The following should always be at the start of a line, no indenting
@@ -91,17 +92,17 @@ function GetEiffelIndent()
" or first thing after the 'do'
if getline(v:lnum) =~ s:outdent && getline(v:lnum - 1) !~ s:single_dent
\ && getline(v:lnum - 1) !~ '^\s*do\>'
- let ind = ind - &sw
+ let ind = ind - shiftwidth()
endif
" Subtract a shiftwidth for end statements
if getline(v:lnum) =~ '^\s*end\>'
- let ind = ind - &sw
+ let ind = ind - shiftwidth()
endif
" set indent of zero end statements that are at an indent of 3, this should
" only ever be the class's end.
- if getline(v:lnum) =~ '^\s*end\>' && ind == &sw
+ if getline(v:lnum) =~ '^\s*end\>' && ind == shiftwidth()
let ind = 0
endif
diff --git a/runtime/indent/eterm.vim b/runtime/indent/eterm.vim
index e5fea1d3b..8ee342fcf 100644
--- a/runtime/indent/eterm.vim
+++ b/runtime/indent/eterm.vim
@@ -25,11 +25,11 @@ function GetEtermIndent()
let ind = indent(lnum)
if getline(lnum) =~ '^\s*begin\>'
- let ind = ind + &sw
+ let ind = ind + shiftwidth()
endif
if getline(v:lnum) =~ '^\s*end\>'
- let ind = ind - &sw
+ let ind = ind - shiftwidth()
endif
return ind
diff --git a/runtime/indent/framescript.vim b/runtime/indent/framescript.vim
index e35d00eb0..f9a274eab 100644
--- a/runtime/indent/framescript.vim
+++ b/runtime/indent/framescript.vim
@@ -30,11 +30,11 @@ function GetFrameScriptIndent()
let ind = indent(lnum)
if getline(lnum) =~? '^\s*\%(If\|Loop\|Sub\)'
- let ind = ind + &sw
+ let ind = ind + shiftwidth()
endif
if getline(v:lnum) =~? '^\s*\%(Else\|End\%(If\|Loop\|Sub\)\)'
- let ind = ind - &sw
+ let ind = ind - shiftwidth()
endif
return ind
diff --git a/runtime/indent/java.vim b/runtime/indent/java.vim
index e0aec0fae..49f8010d2 100644
--- a/runtime/indent/java.vim
+++ b/runtime/indent/java.vim
@@ -1,12 +1,14 @@
" Vim indent file
" Language: Java
" Previous Maintainer: Toby Allsopp <toby.allsopp@peace.com>
-" Current Maintainer: Hong Xu <xuhdev@gmail.com>
-" Last Change: 2012 May 18
-" Version: 1.0
+" Current Maintainer: Hong Xu <hong@topbug.net>
+" Homepage: http://www.vim.org/scripts/script.php?script_id=3899
+" https://github.com/xuhdev/indent-java.vim
+" Last Change: 2016 Mar 7
+" Version: 1.1
" License: Same as Vim.
-" Copyright (c) 2012 Hong Xu
-" Before 2012, this file is maintained by Toby Allsopp.
+" Copyright (c) 2012-2016 Hong Xu
+" Before 2012, this file was maintained by Toby Allsopp.
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
@@ -29,6 +31,7 @@ let b:undo_indent = "set cin< cino< indentkeys< indentexpr<"
if exists("*GetJavaIndent")
finish
endif
+
let s:keepcpo= &cpo
set cpo&vim
@@ -70,7 +73,7 @@ function GetJavaIndent()
" If the previous line starts with '@', we should have the same indent as
" the previous one
- if getline(lnum) =~ '^\s*@\S\+\s*$'
+ if getline(lnum) =~ '^\s*@.*$'
return indent(lnum)
endif
@@ -85,9 +88,9 @@ function GetJavaIndent()
" Try to align "throws" lines for methods and "extends" and "implements" for
" classes.
- if getline(v:lnum) =~ '^\s*\(extends\|implements\)\>'
- \ && getline(lnum) !~ '^\s*\(extends\|implements\)\>'
- let theIndent = theIndent + &sw
+ if getline(v:lnum) =~ '^\s*\(throws\|extends\|implements\)\>'
+ \ && getline(lnum) !~ '^\s*\(throws\|extends\|implements\)\>'
+ let theIndent = theIndent + shiftwidth()
endif
" correct for continuation lines of "throws", "implements" and "extends"
@@ -96,27 +99,27 @@ function GetJavaIndent()
if strlen(cont_kw) > 0
let amount = strlen(cont_kw) + 1
if getline(lnum) !~ ',\s*$'
- let theIndent = theIndent - (amount + &sw)
+ let theIndent = theIndent - (amount + shiftwidth())
if theIndent < 0
let theIndent = 0
endif
elseif prev == lnum
let theIndent = theIndent + amount
if cont_kw ==# 'throws'
- let theIndent = theIndent + &sw
+ let theIndent = theIndent + shiftwidth()
endif
endif
elseif getline(prev) =~ '^\s*\(throws\|implements\|extends\)\>'
\ && (getline(prev) =~ '{\s*$'
\ || getline(v:lnum) =~ '^\s*{\s*$')
- let theIndent = theIndent - &sw
+ let theIndent = theIndent - shiftwidth()
endif
" When the line starts with a }, try aligning it with the matching {,
" skipping over "throws", "extends" and "implements" clauses.
if getline(v:lnum) =~ '^\s*}\s*\(//.*\|/\*.*\)\=$'
call cursor(v:lnum, 1)
- silent normal %
+ silent normal! %
let lnum = line('.')
if lnum < v:lnum
while lnum > 1
diff --git a/runtime/indent/ld.vim b/runtime/indent/ld.vim
index 6544c4d51..a72a3a954 100644
--- a/runtime/indent/ld.vim
+++ b/runtime/indent/ld.vim
@@ -65,7 +65,7 @@ function GetLDIndent()
if line =~ '^\s*\*'
return cindent(v:lnum)
elseif line =~ '^\s*}'
- return indent(v:lnum) - &sw
+ return indent(v:lnum) - shiftwidth()
endif
let pnum = s:prevnonblanknoncomment(v:lnum - 1)
@@ -73,11 +73,11 @@ function GetLDIndent()
return 0
endif
- let ind = indent(pnum) + s:count_braces(pnum, 1) * &sw
+ let ind = indent(pnum) + s:count_braces(pnum, 1) * shiftwidth()
let pline = getline(pnum)
if pline =~ '}\s*$'
- let ind -= (s:count_braces(pnum, 0) - (pline =~ '^\s*}' ? 1 : 0)) * &sw
+ let ind -= (s:count_braces(pnum, 0) - (pline =~ '^\s*}' ? 1 : 0)) * shiftwidth()
endif
return ind
diff --git a/runtime/indent/make.vim b/runtime/indent/make.vim
index 2a4b4580a..66a8a4017 100644
--- a/runtime/indent/make.vim
+++ b/runtime/indent/make.vim
@@ -48,14 +48,14 @@ function GetMakeIndent()
if prev_prev_line =~ s:continuation_rx
return indent(prev_lnum)
elseif prev_line =~ s:rule_rx
- return &sw
+ return shiftwidth()
elseif prev_line =~ s:assignment_rx
call cursor(prev_lnum, 1)
if search(s:assignment_rx, 'W') != 0
return virtcol('.') - 1
else
" TODO: ?
- return &sw
+ return shiftwidth()
endif
else
" TODO: OK, this might be a continued shell command, so perhaps indent
@@ -66,7 +66,7 @@ function GetMakeIndent()
" return indent(prev_lnum) + 2
" endif
"endif
- return indent(prev_lnum) + &sw
+ return indent(prev_lnum) + shiftwidth()
endif
elseif prev_prev_line =~ s:continuation_rx
let folded_line = s:remove_continuation(prev_prev_line) . ' ' . s:remove_continuation(prev_line)
@@ -102,13 +102,13 @@ function GetMakeIndent()
return &ts
endif
elseif prev_line =~ s:conditional_directive_rx
- return &sw
+ return shiftwidth()
else
let line = getline(v:lnum)
if line =~ s:just_inserted_rule_rx
return 0
elseif line =~ s:end_conditional_directive_rx
- return v:lnum - 1 == 0 ? 0 : indent(v:lnum - 1) - &sw
+ return v:lnum - 1 == 0 ? 0 : indent(v:lnum - 1) - shiftwidth()
else
return v:lnum - 1 == 0 ? 0 : indent(v:lnum - 1)
endif
diff --git a/runtime/indent/readline.vim b/runtime/indent/readline.vim
index a58cc411b..e202ddfd8 100644
--- a/runtime/indent/readline.vim
+++ b/runtime/indent/readline.vim
@@ -25,11 +25,11 @@ function GetReadlineIndent()
let ind = indent(lnum)
if getline(lnum) =~ '^\s*$\(if\|else\)\>'
- let ind = ind + &sw
+ let ind = ind + shiftwidth()
endif
if getline(v:lnum) =~ '^\s*$\(else\|endif\)\>'
- let ind = ind - &sw
+ let ind = ind - shiftwidth()
endif
return ind
diff --git a/runtime/indent/sas.vim b/runtime/indent/sas.vim
new file mode 100644
index 000000000..d591b2796
--- /dev/null
+++ b/runtime/indent/sas.vim
@@ -0,0 +1,138 @@
+" Vim indent file
+" Language: SAS
+" Maintainer: Zhen-Huan Hu <wildkeny@gmail.com>
+" Version: 3.0.1
+" Last Change: Mar 13, 2017
+
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal indentexpr=GetSASIndent()
+setlocal indentkeys+=;,=~data,=~proc,=~macro
+
+if exists("*GetSASIndent")
+ finish
+endif
+
+let s:cpo_save = &cpo
+set cpo&vim
+
+" Regex that captures the start of a data/proc section
+let s:section_str = '\v%(^|;)\s*%(data|proc)>'
+" Regex that captures the end of a run-processing section
+let s:section_run = '\v%(^|;)\s*run\s*;'
+" Regex that captures the end of a data/proc section
+let s:section_end = '\v%(^|;)\s*%(quit|enddata)\s*;'
+
+" Regex that captures the start of a control block (anything inside a section)
+let s:block_str = '\v<%(do>%([^;]+<%(to|over)>[^;]+)=|%(define|layout|method|select)>[^;]+|begingraph)\s*;'
+" Regex that captures the end of a control block (anything inside a section)
+let s:block_end = '\v<%(end|endlayout|endgraph)\s*;'
+
+" Regex that captures the start of a macro
+let s:macro_str = '\v%(^|;)\s*\%macro>'
+" Regex that captures the end of a macro
+let s:macro_end = '\v%(^|;)\s*\%mend\s*;'
+
+" Regex that defines the end of the program
+let s:program_end = '\v%(^|;)\s*endsas\s*;'
+
+" List of procs supporting run-processing
+let s:run_processing_procs = [
+ \ 'catalog', 'chart', 'datasets', 'document', 'ds2', 'plot', 'sql',
+ \ 'gareabar', 'gbarline', 'gchart', 'gkpi', 'gmap', 'gplot', 'gradar', 'greplay', 'gslide', 'gtile',
+ \ 'anova', 'arima', 'catmod', 'factex', 'glm', 'model', 'optex', 'plan', 'reg',
+ \ 'iml',
+ \ ]
+
+" Find the line number of previous keyword defined by the regex
+function! s:PrevMatch(lnum, regex)
+ let prev_lnum = prevnonblank(a:lnum - 1)
+ while prev_lnum > 0
+ let prev_line = getline(prev_lnum)
+ if prev_line =~ a:regex
+ break
+ else
+ let prev_lnum = prevnonblank(prev_lnum - 1)
+ endif
+ endwhile
+ return prev_lnum
+endfunction
+
+" Main function
+function! GetSASIndent()
+ let prev_lnum = prevnonblank(v:lnum - 1)
+ if prev_lnum ==# 0
+ " Leave the indentation of the first line unchanged
+ return indent(1)
+ else
+ let prev_line = getline(prev_lnum)
+ " Previous non-blank line contains the start of a macro/section/block
+ " while not the end of a macro/section/block (at the same line)
+ if (prev_line =~ s:section_str && prev_line !~ s:section_run && prev_line !~ s:section_end) ||
+ \ (prev_line =~ s:block_str && prev_line !~ s:block_end) ||
+ \ (prev_line =~ s:macro_str && prev_line !~ s:macro_end)
+ let ind = indent(prev_lnum) + &sts
+ elseif prev_line =~ s:section_run && prev_line !~ s:section_end
+ let prev_section_str_lnum = s:PrevMatch(v:lnum, s:section_str)
+ let prev_section_end_lnum = max([
+ \ s:PrevMatch(v:lnum, s:section_end),
+ \ s:PrevMatch(v:lnum, s:macro_end ),
+ \ s:PrevMatch(v:lnum, s:program_end)])
+ " Check if the section supports run-processing
+ if prev_section_end_lnum < prev_section_str_lnum &&
+ \ getline(prev_section_str_lnum) =~ '\v%(^|;)\s*proc\s+%(' .
+ \ join(s:run_processing_procs, '|') . ')>'
+ let ind = indent(prev_lnum) + &sts
+ else
+ let ind = indent(prev_lnum)
+ endif
+ else
+ let ind = indent(prev_lnum)
+ endif
+ endif
+ " Re-adjustments based on the inputs of the current line
+ let curr_line = getline(v:lnum)
+ if curr_line =~ s:program_end
+ " End of the program
+ " Same indentation as the first non-blank line
+ return indent(nextnonblank(1))
+ elseif curr_line =~ s:macro_end
+ " Current line is the end of a macro
+ " Match the indentation of the start of the macro
+ return indent(s:PrevMatch(v:lnum, s:macro_str))
+ elseif curr_line =~ s:block_end && curr_line !~ s:block_str
+ " Re-adjust if current line is the end of a block
+ " while not the beginning of a block (at the same line)
+ " Returning the indent of previous block start directly
+ " would not work due to nesting
+ let ind = ind - &sts
+ elseif curr_line =~ s:section_str || curr_line =~ s:section_run || curr_line =~ s:section_end
+ " Re-adjust if current line is the start/end of a section
+ " since the end of a section could be inexplicit
+ let prev_section_str_lnum = s:PrevMatch(v:lnum, s:section_str)
+ " Check if the previous section supports run-processing
+ if getline(prev_section_str_lnum) =~ '\v%(^|;)\s*proc\s+%(' .
+ \ join(s:run_processing_procs, '|') . ')>'
+ let prev_section_end_lnum = max([
+ \ s:PrevMatch(v:lnum, s:section_end),
+ \ s:PrevMatch(v:lnum, s:macro_end ),
+ \ s:PrevMatch(v:lnum, s:program_end)])
+ else
+ let prev_section_end_lnum = max([
+ \ s:PrevMatch(v:lnum, s:section_end),
+ \ s:PrevMatch(v:lnum, s:section_run),
+ \ s:PrevMatch(v:lnum, s:macro_end ),
+ \ s:PrevMatch(v:lnum, s:program_end)])
+ endif
+ if prev_section_end_lnum < prev_section_str_lnum
+ let ind = ind - &sts
+ endif
+ endif
+ return ind
+endfunction
+
+let &cpo = s:cpo_save
+unlet s:cpo_save
diff --git a/runtime/indent/scala.vim b/runtime/indent/scala.vim
index f97c79bba..6fd8ca9d8 100644
--- a/runtime/indent/scala.vim
+++ b/runtime/indent/scala.vim
@@ -412,24 +412,24 @@ function! GetScalaIndent()
if prevline =~ '^\s*\.'
return ind
else
- return ind + &shiftwidth
+ return ind + shiftwidth()
endif
endif
" Indent html literals
if prevline !~ '/>\s*$' && prevline =~ '^\s*<[a-zA-Z][^>]*>\s*$'
call scala#ConditionalConfirm("3")
- return ind + &shiftwidth
+ return ind + shiftwidth()
endif
" assumes curly braces around try-block
if curline =~ '^\s*}\s*\<catch\>'
- return ind - &shiftwidth
+ return ind - shiftwidth()
elseif curline =~ '^\s*\<catch\>'
return ind
endif
- " Add a 'shiftwidth' after lines that start a block
+ " Add a shiftwidth()' after lines that start a block
" If 'if', 'for' or 'while' end with ), this is a one-line block
" If 'val', 'var', 'def' end with =, this is a one-line block
if (prevline =~ '^\s*\<\%(\%(}\?\s*else\s\+\)\?if\|for\|while\)\>.*[)=]\s*$' && scala#NumberOfBraceGroups(prevline) <= 1)
@@ -438,7 +438,7 @@ function! GetScalaIndent()
\ || prevline =~ '^\s*\%(}\s*\)\?\<else\>\s*$'
\ || prevline =~ '=\s*$'
call scala#ConditionalConfirm("4")
- let ind = ind + &shiftwidth
+ let ind = ind + shiftwidth()
elseif prevline =~ '^\s*\<\%(}\?\s*else\s\+\)\?if\>' && curline =~ '^\s*}\?\s*\<else\>'
return ind
endif
@@ -447,7 +447,7 @@ function! GetScalaIndent()
let bracketCount = scala#CountBrackets(prevline, '{', '}')
if bracketCount > 0 || prevline =~ '.*{\s*$'
call scala#ConditionalConfirm("5b")
- let ind = ind + &shiftwidth
+ let ind = ind + shiftwidth()
elseif bracketCount < 0
call scala#ConditionalConfirm("6b")
" if the closing brace actually completes the braces entirely, then we
@@ -475,7 +475,7 @@ function! GetScalaIndent()
let bracketCount = scala#CountBrackets(prevline, '(', ')')
if bracketCount > 0 || prevline =~ '.*(\s*$'
call scala#ConditionalConfirm("5a")
- let ind = ind + &shiftwidth
+ let ind = ind + shiftwidth()
elseif bracketCount < 0
call scala#ConditionalConfirm("6a")
" if the closing brace actually completes the braces entirely, then we
@@ -497,7 +497,7 @@ function! GetScalaIndent()
else
" This is the only part that's different from from the '{', '}' one below
" Yup... some refactoring is necessary at some point.
- let ind = ind + (bracketCount * &shiftwidth)
+ let ind = ind + (bracketCount * shiftwidth())
let lineCompletedBrackets = 1
endif
endif
@@ -506,10 +506,10 @@ function! GetScalaIndent()
if curline =~ '^\s*}\?\s*\<else\>\%(\s\+\<if\>\s*(.*)\)\?\s*{\?\s*$' &&
\ ! scala#LineIsCompleteIf(prevline) &&
\ prevline !~ '^.*}\s*$'
- let ind = ind - &shiftwidth
+ let ind = ind - shiftwidth()
endif
- " Subtract a 'shiftwidth' on '}' or html
+ " Subtract a shiftwidth()' on '}' or html
let curCurlyCount = scala#CountCurlies(curline)
if curCurlyCount < 0
call scala#ConditionalConfirm("14a")
@@ -517,7 +517,7 @@ function! GetScalaIndent()
return indent(matchline)
elseif curline =~ '^\s*</[a-zA-Z][^>]*>'
call scala#ConditionalConfirm("14c")
- return ind - &shiftwidth
+ return ind - shiftwidth()
endif
let prevParenCount = scala#CountParens(prevline)
@@ -529,7 +529,7 @@ function! GetScalaIndent()
let prevCurlyCount = scala#CountCurlies(prevline)
if prevCurlyCount == 0 && prevline =~ '^.*\%(=>\|⇒\)\s*$' && prevline !~ '^\s*this\s*:.*\%(=>\|⇒\)\s*$' && curline !~ '^\s*\<case\>'
call scala#ConditionalConfirm("16")
- let ind = ind + &shiftwidth
+ let ind = ind + shiftwidth()
endif
if ind == originalIndentValue && curline =~ '^\s*\<case\>'
@@ -555,7 +555,7 @@ function! GetScalaIndent()
if scala#LineIsAClosingXML(prevline)
if scala#LineCompletesXML(prevlnum, prevline)
call scala#ConditionalConfirm("20a")
- return ind - &shiftwidth
+ return ind - shiftwidth()
else
call scala#ConditionalConfirm("20b")
return ind
@@ -566,7 +566,7 @@ function! GetScalaIndent()
"let indentMultiplier = scala#LineCompletesDefValr(prevlnum, prevline)
"if indentMultiplier != 0
" call scala#ConditionalConfirm("19a")
- " let ind = ind - (indentMultiplier * &shiftwidth)
+ " let ind = ind - (indentMultiplier * shiftwidth())
let defValrLine = scala#Test(prevlnum, prevline, '{', '}')
if defValrLine != -1
call scala#ConditionalConfirm("21a")
@@ -575,10 +575,10 @@ function! GetScalaIndent()
call scala#ConditionalConfirm("21b")
if scala#GetLine(prevnonblank(prevlnum - 1)) =~ '^.*\<else\>\s*\%(//.*\)\?$'
call scala#ConditionalConfirm("21c")
- let ind = ind - &shiftwidth
+ let ind = ind - shiftwidth()
elseif scala#LineCompletesIfElse(prevlnum, prevline)
call scala#ConditionalConfirm("21d")
- let ind = ind - &shiftwidth
+ let ind = ind - shiftwidth()
elseif scala#CountParens(curline) < 0 && curline =~ '^\s*)' && scala#GetLine(scala#GetLineThatMatchesBracket('(', ')')) =~ '.*(\s*$'
" Handles situations that look like this:
"
@@ -592,7 +592,7 @@ function! GetScalaIndent()
" 10
" ).somethingHere()
call scala#ConditionalConfirm("21e")
- let ind = ind - &shiftwidth
+ let ind = ind - shiftwidth()
endif
endif
endif
diff --git a/runtime/indent/tcl.vim b/runtime/indent/tcl.vim
index a92f57d67..e9d61e436 100644
--- a/runtime/indent/tcl.vim
+++ b/runtime/indent/tcl.vim
@@ -56,7 +56,7 @@ function GetTclIndent()
if line =~ '^\s*\*'
return cindent(v:lnum)
elseif line =~ '^\s*}'
- return indent(v:lnum) - &sw
+ return indent(v:lnum) - shiftwidth()
endif
let pnum = s:prevnonblanknoncomment(v:lnum - 1)
@@ -64,11 +64,11 @@ function GetTclIndent()
return 0
endif
- let ind = indent(pnum) + s:count_braces(pnum, 1) * &sw
+ let ind = indent(pnum) + s:count_braces(pnum, 1) * shiftwidth()
let pline = getline(pnum)
if pline =~ '}\s*$'
- let ind -= (s:count_braces(pnum, 0) - (pline =~ '^\s*}' ? 1 : 0)) * &sw
+ let ind -= (s:count_braces(pnum, 0) - (pline =~ '^\s*}' ? 1 : 0)) * shiftwidth()
endif
return ind
diff --git a/runtime/indent/tcsh.vim b/runtime/indent/tcsh.vim
index 59a9d56f4..ed08e6c6e 100644
--- a/runtime/indent/tcsh.vim
+++ b/runtime/indent/tcsh.vim
@@ -32,17 +32,17 @@ function TcshGetIndent()
let ind = indent(lnum)
let line = getline(lnum)
if line =~ '\v^\s*%(while|foreach)>|^\s*%(case\s.*:|default:|else)\s*$|%(<then|\\)$'
- let ind = ind + &sw
+ let ind = ind + shiftwidth()
endif
if line =~ '\v^\s*breaksw>'
- let ind = ind - &sw
+ let ind = ind - shiftwidth()
endif
" Subtract indent if current line has on end, endif, case commands
let line = getline(v:lnum)
if line =~ '\v^\s*%(else|end|endif)\s*$'
- let ind = ind - &sw
+ let ind = ind - shiftwidth()
endif
return ind
diff --git a/runtime/indent/treetop.vim b/runtime/indent/treetop.vim
index 01716e719..2c6eecf5c 100644
--- a/runtime/indent/treetop.vim
+++ b/runtime/indent/treetop.vim
@@ -26,12 +26,12 @@ function GetTreetopIndent()
let line = getline(pnum)
if line =~ '^\s*\%(grammar\|module\|rule\)\>'
- let ind += &sw
+ let ind += shiftwidth()
endif
let line = getline(v:lnum)
if line =~ '^\s*end\>'
- let ind -= &sw
+ let ind -= shiftwidth()
end
retur ind
diff --git a/runtime/indent/xf86conf.vim b/runtime/indent/xf86conf.vim
index 7c3ea15d9..5a8bc0fec 100644
--- a/runtime/indent/xf86conf.vim
+++ b/runtime/indent/xf86conf.vim
@@ -26,11 +26,11 @@ function GetXF86ConfIndent()
let ind = indent(lnum)
if getline(lnum) =~? '^\s*\(Sub\)\=Section\>'
- let ind = ind + &sw
+ let ind = ind + shiftwidth()
endif
if getline(v:lnum) =~? '^\s*End\(Sub\)\=Section\>'
- let ind = ind - &sw
+ let ind = ind - shiftwidth()
endif
return ind
diff --git a/runtime/indent/xinetd.vim b/runtime/indent/xinetd.vim
index 5a32a74d1..977ee3d33 100644
--- a/runtime/indent/xinetd.vim
+++ b/runtime/indent/xinetd.vim
@@ -47,8 +47,8 @@ function GetXinetdIndent()
return 0
endif
- return indent(pnum) + s:count_braces(pnum, 1) * &sw
- \ - s:count_braces(v:lnum, 0) * &sw
+ return indent(pnum) + s:count_braces(pnum, 1) * shiftwidth()
+ \ - s:count_braces(v:lnum, 0) * shiftwidth()
endfunction
let &cpo = s:keepcpo