summaryrefslogtreecommitdiff
path: root/runtime/indent
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/indent')
-rw-r--r--runtime/indent/README.txt45
-rw-r--r--runtime/indent/aap.vim7
-rw-r--r--runtime/indent/ada.vim264
-rw-r--r--runtime/indent/ant.vim12
-rw-r--r--runtime/indent/automake.vim11
-rw-r--r--runtime/indent/awk.vim228
-rw-r--r--runtime/indent/c.vim13
-rw-r--r--runtime/indent/cdl.vim129
-rw-r--r--runtime/indent/ch.vim18
-rw-r--r--runtime/indent/config.vim85
-rw-r--r--runtime/indent/cpp.vim13
-rw-r--r--runtime/indent/cs.vim13
-rw-r--r--runtime/indent/css.vim79
-rw-r--r--runtime/indent/docbk.vim13
-rw-r--r--runtime/indent/dylan.vim90
-rw-r--r--runtime/indent/eiffel.vim106
-rw-r--r--runtime/indent/eterm.vim49
-rw-r--r--runtime/indent/fortran.vim161
-rw-r--r--runtime/indent/html.vim219
-rw-r--r--runtime/indent/idlang.vim63
-rw-r--r--runtime/indent/ishd.vim65
-rw-r--r--runtime/indent/java.vim128
-rw-r--r--runtime/indent/lua.vim49
-rw-r--r--runtime/indent/make.vim57
-rw-r--r--runtime/indent/matlab.vim74
-rw-r--r--runtime/indent/mp.vim206
-rw-r--r--runtime/indent/objc.vim79
-rw-r--r--runtime/indent/ocaml.vim311
-rw-r--r--runtime/indent/occam.vim182
-rw-r--r--runtime/indent/perl.vim180
-rw-r--r--runtime/indent/php.vim118
-rw-r--r--runtime/indent/postscr.vim68
-rw-r--r--runtime/indent/pov.vim84
-rw-r--r--runtime/indent/prolog.vim58
-rw-r--r--runtime/indent/pyrex.vim8
-rw-r--r--runtime/indent/python.vim175
-rw-r--r--runtime/indent/readline.vim48
-rw-r--r--runtime/indent/rpl.vim60
-rw-r--r--runtime/indent/rst.vim60
-rw-r--r--runtime/indent/ruby.vim67
-rw-r--r--runtime/indent/sdl.vim89
-rw-r--r--runtime/indent/sh.vim58
-rw-r--r--runtime/indent/tcl.vim123
-rw-r--r--runtime/indent/tcsh.vim51
-rw-r--r--runtime/indent/tilde.vim36
-rw-r--r--runtime/indent/vb.vim72
-rw-r--r--runtime/indent/verilog.vim219
-rw-r--r--runtime/indent/vim.vim65
-rw-r--r--runtime/indent/xf86conf.vim42
-rw-r--r--runtime/indent/xhtml.vim7
-rw-r--r--runtime/indent/xml.vim88
-rw-r--r--runtime/indent/xslt.vim13
-rw-r--r--runtime/indent/yacc.vim44
-rw-r--r--runtime/indent/zsh.vim11
54 files changed, 4613 insertions, 0 deletions
diff --git a/runtime/indent/README.txt b/runtime/indent/README.txt
new file mode 100644
index 000000000..a424b4f8c
--- /dev/null
+++ b/runtime/indent/README.txt
@@ -0,0 +1,45 @@
+This directory contains files to automatically compute the indent for a
+type of file.
+
+If you want to add your own indent file for your personal use, read the docs
+at ":help indent-expression". Looking at the existing files should give you
+inspiration.
+
+If you make a new indent file which would be useful for others, please send it
+to Bram@vim.org. Include instructions for detecting the file type for this
+language, by file name extension or by checking a few lines in the file.
+And please stick to the rules below.
+
+If you have remarks about an existing file, send them to the maintainer of
+that file. Only when you get no response send a message to Bram@vim.org.
+
+If you are the maintainer of an indent file and make improvements, e-mail the
+new version to Bram@vim.org.
+
+
+Rules for making an indent file:
+
+You should use this check for "b:did_indent":
+
+ " Only load this indent file when no other was loaded yet.
+ if exists("b:did_indent")
+ finish
+ endif
+ let b:did_indent = 1
+
+Always use ":setlocal" to set 'indentexpr'. This avoids it being carried over
+to other buffers.
+
+To trigger the indenting after typing a word like "endif", add the word to the
+'cinkeys' option with "+=".
+
+You normally set 'indentexpr' to evaluate a function and then define that
+function. That function only needs to be defined once for as long as Vim is
+running. Add a test if the function exists and use ":finish", like this:
+ if exists("*GetMyIndent")
+ finish
+ endif
+
+The user may have several options set unlike you, try to write the file such
+that it works with any option settings. Also be aware of certain features not
+being compiled in.
diff --git a/runtime/indent/aap.vim b/runtime/indent/aap.vim
new file mode 100644
index 000000000..78ac0336d
--- /dev/null
+++ b/runtime/indent/aap.vim
@@ -0,0 +1,7 @@
+" Vim indent file
+" Language: Aap recipe
+" Maintainer: Bram Moolenaar <Bram@vim.org>
+" Last Change: 2003 Sep 08
+
+" Works mostly like Python.
+runtime! indent/python.vim
diff --git a/runtime/indent/ada.vim b/runtime/indent/ada.vim
new file mode 100644
index 000000000..72e2e80e5
--- /dev/null
+++ b/runtime/indent/ada.vim
@@ -0,0 +1,264 @@
+" Vim indent file
+" Language: Ada
+" Maintainer: Neil Bird <neil@fnxweb.com>
+" Last Change: 2003 May 20
+" Version: $Id$
+" Look for the latest version at http://vim.sourceforge.net/
+"
+" ToDo:
+" Verify handling of multi-line exprs. and recovery upon the final ';'.
+" Correctly find comments given '"' and "" ==> " syntax.
+" Combine the two large block-indent functions into one?
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal indentexpr=GetAdaIndent()
+setlocal indentkeys-=0{,0}
+setlocal indentkeys+=0=~then,0=~end,0=~elsif,0=~when,0=~exception,0=~begin,0=~is,0=~record
+
+" Only define the functions once.
+if exists("*GetAdaIndent")
+ finish
+endif
+
+let s:AdaBlockStart = '^\s*\(if\>\|while\>\|else\>\|elsif\>\|loop\>\|for\>.*\<loop\>\|declare\>\|begin\>\|type\>.*\<is\s*$\|\(type\>.*\)\=\<record\>\|procedure\>\|function\>\|accept\>\|do\>\|task\>\|package\>\|then\>\|when\>\|is\>\)'
+let s:AdaComment = "\\v^(\"[^\"]*\"|'.'|[^\"']){-}\\zs\\s*--.*"
+
+
+" Try to find indent of the block we're in (and about to complete)
+" prev_indent = the previous line's indent
+" prev_lnum = previous line (to start looking on)
+" blockstart = expr. that indicates a possible start of this block
+" stop_at = if non-null, if a matching line is found, gives up!
+" No recursive previous block analysis: simply look for a valid line
+" with a lesser or equal indent than we currently (on prev_lnum) have.
+" This shouldn't work as well as it appears to with lines that are currently
+" nowhere near the correct indent (e.g., start of line)!
+" Seems to work OK as it 'starts' with the indent of the /previous/ line.
+function s:MainBlockIndent( prev_indent, prev_lnum, blockstart, stop_at )
+ let lnum = a:prev_lnum
+ let line = substitute( getline(lnum), s:AdaComment, '', '' )
+ while lnum > 1
+ if a:stop_at != '' && line =~ '^\s*' . a:stop_at && indent(lnum) < a:prev_indent
+ return -1
+ elseif line =~ '^\s*' . a:blockstart
+ let ind = indent(lnum)
+ if ind < a:prev_indent
+ return ind
+ endif
+ endif
+
+ let lnum = prevnonblank(lnum - 1)
+ " Get previous non-blank/non-comment-only line
+ while 1
+ let line = substitute( getline(lnum), s:AdaComment, '', '' )
+ if line !~ '^\s*$' && line !~ '^\s*#'
+ break
+ endif
+ let lnum = prevnonblank(lnum - 1)
+ if lnum <= 0
+ return a:prev_indent
+ endif
+ endwhile
+ endwhile
+ " Fallback - just move back one
+ return a:prev_indent - &sw
+endfunction
+
+" Try to find indent of the block we're in (and about to complete),
+" including handling of nested blocks. Works on the 'end' of a block.
+" prev_indent = the previous line's indent
+" prev_lnum = previous line (to start looking on)
+" blockstart = expr. that indicates a possible start of this block
+" blockend = expr. that indicates a possible end of this block
+function s:EndBlockIndent( prev_indent, prev_lnum, blockstart, blockend )
+ let lnum = a:prev_lnum
+ let line = getline(lnum)
+ let ends = 0
+ while lnum > 1
+ if getline(lnum) =~ '^\s*' . a:blockstart
+ let ind = indent(lnum)
+ if ends <= 0
+ if ind < a:prev_indent
+ return ind
+ endif
+ else
+ let ends = ends - 1
+ endif
+ elseif getline(lnum) =~ '^\s*' . a:blockend
+ let ends = ends + 1
+ endif
+
+ let lnum = prevnonblank(lnum - 1)
+ " Get previous non-blank/non-comment-only line
+ while 1
+ let line = getline(lnum)
+ let line = substitute( line, s:AdaComment, '', '' )
+ if line !~ '^\s*$'
+ break
+ endif
+ let lnum = prevnonblank(lnum - 1)
+ if lnum <= 0
+ return a:prev_indent
+ endif
+ endwhile
+ endwhile
+ " Fallback - just move back one
+ return a:prev_indent - &sw
+endfunction
+
+" As per MainBlockIndent, but return indent of previous statement-start
+" (after we've indented due to multi-line statements).
+" This time, we start searching on the line *before* the one given (which is
+" the end of a statement - we want the previous beginning).
+function s:StatementIndent( current_indent, prev_lnum )
+ let lnum = a:prev_lnum
+ while lnum > 0
+ let prev_lnum = lnum
+ let lnum = prevnonblank(lnum - 1)
+ " Get previous non-blank/non-comment-only line
+ while 1
+ let line = substitute( getline(lnum), s:AdaComment, '', '' )
+ if line !~ '^\s*$' && line !~ '^\s*#'
+ break
+ endif
+ let lnum = prevnonblank(lnum - 1)
+ if lnum <= 0
+ return a:current_indent
+ endif
+ endwhile
+ " Leave indent alone if our ';' line is part of a ';'-delineated
+ " aggregate (e.g., procedure args.) or first line after a block start.
+ if line =~ s:AdaBlockStart || line =~ '(\s*$'
+ return a:current_indent
+ endif
+ if line !~ '[.=(]\s*$'
+ let ind = indent(prev_lnum)
+ if ind < a:current_indent
+ return ind
+ endif
+ endif
+ endwhile
+ " Fallback - just use current one
+ return a:current_indent
+endfunction
+
+
+" Find correct indent of a new line based upon what went before
+function GetAdaIndent()
+ " Find a non-blank line above the current line.
+ let lnum = prevnonblank(v:lnum - 1)
+ let ind = indent(lnum)
+ let package_line = 0
+
+ " Get previous non-blank/non-comment-only/non-cpp line
+ while 1
+ let line = substitute( getline(lnum), s:AdaComment, '', '' )
+ if line !~ '^\s*$' && line !~ '^\s*#'
+ break
+ endif
+ let lnum = prevnonblank(lnum - 1)
+ if lnum <= 0
+ return ind
+ endif
+ endwhile
+
+ " Get default indent (from prev. line)
+ let ind = indent(lnum)
+
+ " Now check what's on the previous line
+ if line =~ s:AdaBlockStart || line =~ '(\s*$'
+ " Check for false matches to AdaBlockStart
+ let false_match = 0
+ if line =~ '^\s*\(procedure\|function\|package\)\>.*\<is\s*new\>'
+ " Generic instantiation
+ let false_match = 1
+ elseif line =~ ')\s*;\s*$' || line =~ '^\([^(]*([^)]*)\)*[^(]*;\s*$'
+ " forward declaration
+ let false_match = 1
+ endif
+ " Move indent in
+ if ! false_match
+ let ind = ind + &sw
+ endif
+ elseif line =~ '^\s*\(case\|exception\)\>'
+ " Move indent in twice (next 'when' will move back)
+ let ind = ind + 2 * &sw
+ elseif line =~ '^\s*end\s*record\>'
+ " Move indent back to tallying 'type' preceeding the 'record'.
+ " Allow indent to be equal to 'end record's.
+ let ind = s:MainBlockIndent( ind+&sw, lnum, 'type\>', '' )
+ elseif line =~ '\(^\s*new\>.*\)\@<!)\s*[;,]\s*$'
+ " Revert to indent of line that started this parenthesis pair
+ exe lnum
+ exe 'normal! $F)%'
+ if getline('.') =~ '^\s*('
+ " Dire layout - use previous indent (could check for AdaComment here)
+ let ind = indent( prevnonblank( line('.')-1 ) )
+ else
+ let ind = indent('.')
+ endif
+ exe v:lnum
+ elseif line =~ '[.=(]\s*$'
+ " A statement continuation - move in one
+ let ind = ind + &sw
+ elseif line =~ '^\s*new\>'
+ " Multiple line generic instantiation ('package blah is\nnew thingy')
+ let ind = s:StatementIndent( ind - &sw, lnum )
+ elseif line =~ ';\s*$'
+ " Statement end - try to find current statement-start indent
+ let ind = s:StatementIndent( ind, lnum )
+ endif
+
+ " Check for potential argument list on next line
+ let continuation = (line =~ '[A-Za-z0-9_]\s*$')
+
+
+ " Check current line; search for simplistic matching start-of-block
+ let line = getline(v:lnum)
+ if line =~ '^\s*#'
+ " Start of line for ada-pp
+ let ind = 0
+ elseif continuation && line =~ '^\s*('
+ let ind = ind + &sw
+ elseif line =~ '^\s*\(begin\|is\)\>'
+ let ind = s:MainBlockIndent( ind, lnum, '\(procedure\|function\|declare\|package\|task\)\>', 'begin\>' )
+ elseif line =~ '^\s*record\>'
+ let ind = s:MainBlockIndent( ind, lnum, 'type\>', '' ) + &sw
+ elseif line =~ '^\s*\(else\|elsif\)\>'
+ let ind = s:MainBlockIndent( ind, lnum, 'if\>', '' )
+ elseif line =~ '^\s*when\>'
+ " Align 'when' one /in/ from matching block start
+ let ind = s:MainBlockIndent( ind, lnum, '\(case\|exception\)\>', '' ) + &sw
+ elseif line =~ '^\s*end\>\s*\<if\>'
+ " End of if statements
+ let ind = s:EndBlockIndent( ind, lnum, 'if\>', 'end\>\s*\<if\>' )
+ elseif line =~ '^\s*end\>\s*\<loop\>'
+ " End of loops
+ let ind = s:EndBlockIndent( ind, lnum, '\(\(while\|for\)\>.*\)\?\<loop\>', 'end\>\s*\<loop\>' )
+ elseif line =~ '^\s*end\>\s*\<record\>'
+ " End of records
+ let ind = s:EndBlockIndent( ind, lnum, '\(type\>.*\)\=\<record\>', 'end\>\s*\<record\>' )
+ elseif line =~ '^\s*end\>\s*\<procedure\>'
+ " End of procedures
+ let ind = s:EndBlockIndent( ind, lnum, 'procedure\>.*\<is\>', 'end\>\s*\<procedure\>' )
+ elseif line =~ '^\s*end\>\s*\<case\>'
+ " End of case statement
+ let ind = s:EndBlockIndent( ind, lnum, 'case\>.*\<is\>', 'end\>\s*\<case\>' )
+ elseif line =~ '^\s*end\>'
+ " General case for end
+ let ind = s:MainBlockIndent( ind, lnum, '\(if\|while\|for\|loop\|accept\|begin\|record\|case\|exception\)\>', '' )
+ elseif line =~ '^\s*exception\>'
+ let ind = s:MainBlockIndent( ind, lnum, 'begin\>', '' )
+ elseif line =~ '^\s*then\>'
+ let ind = s:MainBlockIndent( ind, lnum, 'if\>', '' )
+ endif
+
+ return ind
+endfunction
+
+" vim: set sw=3 sts=3 :
diff --git a/runtime/indent/ant.vim b/runtime/indent/ant.vim
new file mode 100644
index 000000000..067f27213
--- /dev/null
+++ b/runtime/indent/ant.vim
@@ -0,0 +1,12 @@
+" Vim indent file
+" Language: ANT files
+" Maintainer: David Fishburn <fishburn@ianywhere.com>
+" Last Change: Thu May 15 2003 10:02:54 PM
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+
+" Use XML formatting rules
+runtime! indent/xml.vim
diff --git a/runtime/indent/automake.vim b/runtime/indent/automake.vim
new file mode 100644
index 000000000..60eff0750
--- /dev/null
+++ b/runtime/indent/automake.vim
@@ -0,0 +1,11 @@
+" Vim indent file
+" Language: automake
+" Maintainer: Nikolai Weibull <source@pcppopper.org>
+" URL: http://www.pcppopper.org/vim/indent/pcp/automake/
+" Latest Revision: 2004-04-25
+" arch-tag: 9a2af48c-48d4-4bae-82c3-c801bc9d1976
+
+" same as makefile indenting for now.
+source <sfile>:p:h/make.vim
+
+" vim: set sts=2 sw=2:
diff --git a/runtime/indent/awk.vim b/runtime/indent/awk.vim
new file mode 100644
index 000000000..726a5ddbe
--- /dev/null
+++ b/runtime/indent/awk.vim
@@ -0,0 +1,228 @@
+" vim: set sw=3 sts=3:
+
+" Awk indent script. It can handle multi-line statements and expressions.
+" It works up to the point where the distinction between correct/incorrect
+" and personal taste gets fuzzy. Drop me an e-mail for bug reports and
+" reasonable style suggestions.
+"
+" Bugs:
+" =====
+" - Some syntax errors may cause erratic indentation.
+" - Same for very unusual but syntacticly correct use of { }
+" - In some cases it's confused by the use of ( and { in strings constants
+" - This version likes the closing brace of a multiline pattern-action be on
+" character position 1 before the following pattern-action combination is
+" formatted
+
+" Author:
+" =======
+" Erik Janssen, ejanssen@itmatters.nl
+"
+" History:
+" ========
+" 26-04-2002 Got initial version working reasonably well
+" 29-04-2002 Fixed problems in function headers and max line width
+" Added support for two-line if's without curly braces
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+
+let b:did_indent = 1
+
+setlocal indentexpr=GetAwkIndent()
+" Mmm, copied from the tcl indent program. Is this okay?
+setlocal indentkeys-=:,0#
+
+" Only define the function once.
+if exists("*GetAwkIndent")
+ finish
+endif
+
+" This function contains a lot of exit points. It checks for simple cases
+" first to get out of the function as soon as possible, thereby reducing the
+" number of possibilities later on in the difficult parts
+
+function! GetAwkIndent()
+
+ " Find previous line and get it's indentation
+ let prev_lineno = s:Get_prev_line( v:lnum )
+ if prev_lineno == 0
+ return 0
+ endif
+ let prev_data = getline( prev_lineno )
+ let ind = indent( prev_lineno )
+
+ " Increase indent if the previous line contains an opening brace. Search
+ " for this brace the hard way to prevent errors if the previous line is a
+ " 'pattern { action }' (simple check match on /{/ increases the indent then)
+
+ if s:Get_brace_balance( prev_data, '{', '}' ) > 0
+ return ind + &sw
+ endif
+
+ let brace_balance = s:Get_brace_balance( prev_data, '(', ')' )
+
+ " If prev line has positive brace_balance and starts with a word (keyword
+ " or function name), align the current line on the first '(' of the prev
+ " line
+
+ if brace_balance > 0 && s:Starts_with_word( prev_data )
+ return s:Safe_indent( ind, s:First_word_len(prev_data), getline(v:lnum))
+ endif
+
+ " If this line starts with an open brace bail out now before the line
+ " continuation checks.
+
+ if getline( v:lnum ) =~ '^\s*{'
+ return ind
+ endif
+
+ " If prev line seems to be part of multiline statement:
+ " 1. Prev line is first line of a multiline statement
+ " -> attempt to indent on first ' ' or '(' of prev line, just like we
+ " indented the positive brace balance case above
+ " 2. Prev line is not first line of a multiline statement
+ " -> copy indent of prev line
+
+ let continue_mode = s:Seems_continuing( prev_data )
+ if continue_mode > 0
+ if s:Seems_continuing( getline(s:Get_prev_line( prev_lineno )) )
+ " Case 2
+ return ind
+ else
+ " Case 1
+ if continue_mode == 1
+ " Need continuation due to comma, backslash, etc
+ return s:Safe_indent( ind, s:First_word_len(prev_data), getline(v:lnum))
+ else
+ " if/for/while without '{'
+ return ind + &sw
+ endif
+ endif
+ endif
+
+ " If the previous line doesn't need continuation on the current line we are
+ " on the start of a new statement. We have to make sure we align with the
+ " previous statement instead of just the previous line. This is a bit
+ " complicated because the previous statement might be multi-line.
+ "
+ " The start of a multiline statement can be found by:
+ "
+ " 1 If the previous line contains closing braces and has negative brace
+ " balance, search backwards until cumulative brace balance becomes zero,
+ " take indent of that line
+ " 2 If the line before the previous needs continuation search backward
+ " until that's not the case anymore. Take indent of one line down.
+
+ " Case 1
+ if prev_data =~ ')' && brace_balance < 0
+ while brace_balance != 0
+ let prev_lineno = s:Get_prev_line( prev_lineno )
+ let prev_data = getline( prev_lineno )
+ let brace_balance=brace_balance+s:Get_brace_balance(prev_data,'(',')' )
+ endwhile
+ let ind = indent( prev_lineno )
+ else
+ " Case 2
+ if s:Seems_continuing( getline( prev_lineno - 1 ) )
+ let prev_lineno = prev_lineno - 2
+ let prev_data = getline( prev_lineno )
+ while prev_lineno > 0 && (s:Seems_continuing( prev_data ) > 0)
+ let prev_lineno = s:Get_prev_line( prev_lineno )
+ let prev_data = getline( prev_lineno )
+ endwhile
+ let ind = indent( prev_lineno + 1 )
+ endif
+ endif
+
+ " Decrease indent if this line contains a '}'.
+ if getline(v:lnum) =~ '^\s*}'
+ let ind = ind - &sw
+ endif
+
+ return ind
+endfunction
+
+" Find the open and close braces in this line and return how many more open-
+" than close braces there are. It's also used to determine cumulative balance
+" across multiple lines.
+
+function! s:Get_brace_balance( line, b_open, b_close )
+ let line2 = substitute( a:line, a:b_open, "", "g" )
+ let openb = strlen( a:line ) - strlen( line2 )
+ let line3 = substitute( line2, a:b_close, "", "g" )
+ let closeb = strlen( line2 ) - strlen( line3 )
+ return openb - closeb
+endfunction
+
+" Find out whether the line starts with a word (i.e. keyword or function
+" call). Might need enhancements here.
+
+function! s:Starts_with_word( line )
+ if a:line =~ '^\s*[a-zA-Z_0-9]\+\s*('
+ return 1
+ endif
+ return 0
+endfunction
+
+" Find the length of the first word in a line. This is used to be able to
+" align a line relative to the 'print ' or 'if (' on the previous line in case
+" such a statement spans multiple lines.
+" Precondition: only to be used on lines where 'Starts_with_word' returns 1.
+
+function! s:First_word_len( line )
+ let white_end = matchend( a:line, '^\s*' )
+ if match( a:line, '^\s*func' ) != -1
+ let word_end = matchend( a:line, '[a-z]\+\s\+[a-zA-Z_0-9]\+[ (]*' )
+ else
+ let word_end = matchend( a:line, '[a-zA-Z_0-9]\+[ (]*' )
+ endif
+ return word_end - white_end
+endfunction
+
+" Determine if 'line' completes a statement or is continued on the next line.
+" This one is far from complete and accepts illegal code. Not important for
+" indenting, however.
+
+function! s:Seems_continuing( line )
+ " Unfinished lines
+ if a:line =~ '[\\,\|\&\+\-\*\%\^]\s*$'
+ return 1
+ endif
+ " if/for/while (cond) eol
+ if a:line =~ '^\s*\(if\|while\|for\)\s*(.*)\s*$' || a:line =~ '^\s*else\s*'
+ return 2
+ endif
+ return 0
+endfunction
+
+" Get previous relevant line. Search back until a line is that is no
+" comment or blank and return the line number
+
+function! s:Get_prev_line( lineno )
+ let lnum = a:lineno - 1
+ let data = getline( lnum )
+ while lnum > 0 && (data =~ '^\s*#' || data =~ '^\s*$')
+ let lnum = lnum - 1
+ let data = getline( lnum )
+ endwhile
+ return lnum
+endfunction
+
+" This function checks whether an indented line exceeds a maximum linewidth
+" (hardcoded 80). If so and it is possible to stay within 80 positions (or
+" limit num of characters beyond linewidth) by decreasing the indent (keeping
+" it > base_indent), do so.
+
+function! s:Safe_indent( base, wordlen, this_line )
+ let line_base = matchend( a:this_line, '^\s*' )
+ let line_len = strlen( a:this_line ) - line_base
+ let indent = a:base
+ if (indent + a:wordlen + line_len) > 80
+ " Simple implementation good enough for the time being
+ let indent = indent + 3
+ endif
+ return indent + a:wordlen
+endfunction
diff --git a/runtime/indent/c.vim b/runtime/indent/c.vim
new file mode 100644
index 000000000..135251dca
--- /dev/null
+++ b/runtime/indent/c.vim
@@ -0,0 +1,13 @@
+" Vim indent file
+" Language: C
+" Maintainer: Bram Moolenaar <Bram@vim.org>
+" Last Change: 2001 Jun 12
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+" C indenting is built-in, thus this is very simple
+setlocal cindent
diff --git a/runtime/indent/cdl.vim b/runtime/indent/cdl.vim
new file mode 100644
index 000000000..db2b9052b
--- /dev/null
+++ b/runtime/indent/cdl.vim
@@ -0,0 +1,129 @@
+" Description: Comshare Dimension Definition Language (CDL)
+" Author: Raul Segura Acevedo <raulseguraaceved@netscape.net>
+" Last Change: Fri Nov 30 13:35:48 2001 CST
+
+if exists("b:did_indent")
+ "finish
+endif
+let b:did_indent = 1
+
+setlocal indentexpr=CdlGetIndent(v:lnum)
+setlocal indentkeys&
+setlocal indentkeys+==~else,=~endif,=~then,;,),=
+
+" Only define the function once.
+if exists("*CdlGetIndent")
+ "finish
+endif
+
+" find out if an "...=..." expresion its an asignment (or a conditional)
+" it scans 'line' first, and then the previos lines
+fun! CdlAsignment(lnum, line)
+ let f = -1
+ let lnum = a:lnum
+ let line = a:line
+ while lnum > 0 && f == -1
+ " line without members [a] of [b]:[c]...
+ let inicio = 0
+ while 1
+ " keywords that help to decide
+ let inicio = matchend(line, '\c\<\(expr\|\a*if\|and\|or\|not\|else\|then\|memberis\|\k\+of\)\>\|[<>;]', inicio)
+ if inicio < 0
+ break
+ endif
+ " it's formula if there's a ';', 'elsE', 'theN', 'enDif' or 'expr'
+ " conditional if there's a '<', '>', 'elseif', 'if', 'and', 'or', 'not',
+ " 'memberis', 'childrenof' and other \k\+of funcions
+ let f = line[inicio-1] =~? '[en;]' || strpart(line, inicio-4, 4) =~? 'ndif\|expr'
+ endw
+ let lnum = prevnonblank(lnum-1)
+ let line = substitute(getline(lnum), '\c\(\[[^]]*]\(\s*of\s*\|:\)*\)\+', ' ', 'g')
+ endw
+ " if we hit the start of the file then f = -1, return 1 (formula)
+ return f != 0
+endf
+
+fun! CdlGetIndent(lnum)
+ let thisline = getline(a:lnum)
+ if match(thisline, '^\s*\(\k\+\|\[[^]]*]\)\s*\(,\|;\s*$\)') >= 0
+ " it's an attributes line
+ return &sw
+ elseif match(thisline, '^\c\s*\([{}]\|\/[*/]\|dimension\|schedule\|group\|hierarchy\|class\)') >= 0
+ " it's a header or '{' or '}' or a comment
+ return 0
+ end
+
+ let lnum = prevnonblank(a:lnum-1)
+ " Hit the start of the file, use zero indent.
+ if lnum == 0
+ return 0
+ endif
+
+ " PREVIOUS LINE
+ let ind = indent(lnum)
+ let line = getline(lnum)
+ let f = -1 " wether a '=' is a conditional or a asignment, -1 means we don't know yet
+ " one 'closing' element at the beginning of the line has already reduced the
+ " indent, but 'else', 'elseif' & 'then' increment it for the next line
+ " '=' at the beginning has already de right indent (increased for asignments)
+ let inicio = matchend(line, '^\c\s*\(else\a*\|then\|endif\|/[*/]\|[);={]\)')
+ if inicio > 0
+ let c = line[inicio-1]
+ " ')' and '=' don't change indent and are useless to set 'f'
+ if c == '{'
+ return &sw
+ elseif c != ')' && c != '='
+ let f = 1 " all but 'elseif' are followed by a formula
+ if c ==? 'n' || c ==? 'e' " 'then', 'else'
+ let ind = ind + &sw
+ elseif strpart(line, inicio-6, 6) ==? 'elseif' " elseif, set f to conditional
+ let ind = ind + &sw
+ let f = 0
+ end
+ end
+ end
+
+ " remove members [a] of [b]:[c]... (inicio remainds valid)
+ let line = substitute(line, '\c\(\[[^]]*]\(\s*of\s*\|:\)*\)\+', ' ', 'g')
+ while 1
+ " search for the next interesting element
+ let inicio=matchend(line, '\c\<if\|endif\|[()=;]', inicio)
+ if inicio < 0
+ break
+ end
+
+ let c = line[inicio-1]
+ " 'expr(...)' containing the formula
+ if strpart(line, inicio-5, 5) ==? 'expr('
+ let ind = 0
+ let f = 1
+ elseif c == ')' || c== ';' || strpart(line, inicio-5, 5) ==? 'endif'
+ let ind = ind - &sw
+ elseif c == '(' || c ==? 'f' " '(' or 'if'
+ let ind = ind + &sw
+ else " c == '='
+ " if it is an asignment increase indent
+ if f == -1 " we don't know yet, find out
+ let f = CdlAsignment(lnum, strpart(line, 0, inicio))
+ end
+ if f == 1 " formula increase it
+ let ind = ind + &sw
+ end
+ end
+ endw
+
+ " CURRENT LINE, if it starts with a closing element, decrease indent
+ " or if it starts with '=' (asignment), increase indent
+ if match(thisline, '^\c\s*\(else\|then\|endif\|[);]\)') >= 0
+ let ind = ind - &sw
+ elseif match(thisline, '^\s*=') >= 0
+ if f == -1 " we don't know yet if is an asignment, find out
+ let f = CdlAsignment(lnum, "")
+ end
+ if f == 1 " formula increase it
+ let ind = ind + &sw
+ end
+ end
+
+ return ind
+endfun
diff --git a/runtime/indent/ch.vim b/runtime/indent/ch.vim
new file mode 100644
index 000000000..12d583d06
--- /dev/null
+++ b/runtime/indent/ch.vim
@@ -0,0 +1,18 @@
+" Vim indent file
+" Language: Ch
+" Maintainer: SoftIntegration, Inc. <info@softintegration.com>
+" URL: http://www.softintegration.com/download/vim/indent/ch.vim
+" Last change: 2003 Aug 05
+" Created based on cpp.vim
+"
+" Ch is a C/C++ interpreter with many high level extensions
+
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+" Ch indenting is built-in, thus this is very simple
+setlocal cindent
diff --git a/runtime/indent/config.vim b/runtime/indent/config.vim
new file mode 100644
index 000000000..5a803ed8a
--- /dev/null
+++ b/runtime/indent/config.vim
@@ -0,0 +1,85 @@
+" Vim indent file
+" Language: Autoconf configure.{ac,in} file
+" Maintainer: Nikolai Weibull <source@pcppopper.org>
+" URL: http://www.pcppopper.org/vim/indent/pcp/config/
+" Latest Revision: 2004-04-25
+" arch-tag: 7779c341-796f-408e-80e4-a55c26b519a4
+" TODO: how about nested [()]'s in one line
+" what's wrong with '\\\@!'?
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+
+source <sfile>:p:h/sh.vim " will set b:did_indent
+
+setlocal indentexpr=GetConfigIndent()
+setlocal indentkeys=!^F,o,O,=then,=do,=else,=elif,=esac,=fi,=fin,=fil,=done
+
+" Only define the function once.
+if exists("*GetConfigIndent")
+ finish
+endif
+
+" get the offset (indent) of the end of the match of 'regexp' in 'line'
+function s:GetOffsetOf(line, regexp)
+ let end = matchend(a:line, a:regexp)
+ let width = 0
+ let i = 0
+ while i < end
+ if a:line[i] != "\t"
+ let width = width + 1
+ else
+ let width = width + &ts - (width % &ts)
+ endif
+ let i = i + 1
+ endwhile
+ return width
+endfunction
+
+function GetConfigIndent()
+ " Find a non-blank line above the current line.
+ let lnum = prevnonblank(v:lnum - 1)
+
+ " Hit the start of the file, use zero indent.
+ if lnum == 0
+ return 0
+ endif
+
+ " where to put this
+ let ind = GetShIndent()
+ let line = getline(lnum)
+
+ " if previous line has unmatched, unescaped opening parentheses,
+ " indent to its position. TODO: not failsafe if multiple ('s
+ if line =~ '\\\@<!([^)]*$'
+ let ind = s:GetOffsetOf(line, '\\\@!(')
+ endif
+
+ " if previous line has unmatched opening bracket,
+ " indent to its position. TODO: same as above
+ if line =~ '\[[^]]*$'
+ let ind = s:GetOffsetOf(line, '\[')
+ endif
+
+ " if previous line had an unmatched closing parantheses,
+ " indent to the matching opening parantheses
+ if line =~ '[^(]*\\\@<!)$'
+ call search(')', 'bW')
+ let lnum = searchpair('\\\@<!(', '', ')', 'bWn')
+ let ind = indent(lnum)
+ endif
+
+ " if previous line had an unmatched closing bracket,
+ " indent to the matching opening bracket
+ if line =~ '[^[]*]$'
+ call search(']', 'bW')
+ let lnum = searchpair('\[', '', ']', 'bWn')
+ let ind = indent(lnum)
+ endif
+
+ return ind
+endfunction
+
+" vim: set sts=2 sw=2:
diff --git a/runtime/indent/cpp.vim b/runtime/indent/cpp.vim
new file mode 100644
index 000000000..9ae126ac4
--- /dev/null
+++ b/runtime/indent/cpp.vim
@@ -0,0 +1,13 @@
+" Vim indent file
+" Language: C++
+" Maintainer: Bram Moolenaar <Bram@vim.org>
+" Last Change: 2001 Jun 12
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+" C++ indenting is built-in, thus this is very simple
+setlocal cindent
diff --git a/runtime/indent/cs.vim b/runtime/indent/cs.vim
new file mode 100644
index 000000000..064ab0069
--- /dev/null
+++ b/runtime/indent/cs.vim
@@ -0,0 +1,13 @@
+" Vim indent file
+" Language: C#
+" Maintainer: Johannes Zellner <johannes@zellner.org>
+" Last Change: Fri, 15 Mar 2002 07:53:54 CET
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+" C# is like indenting C
+setlocal cindent
diff --git a/runtime/indent/css.vim b/runtime/indent/css.vim
new file mode 100644
index 000000000..610c725c6
--- /dev/null
+++ b/runtime/indent/css.vim
@@ -0,0 +1,79 @@
+" Vim indent file
+" Language: CSS
+" Maintainer: Nikolai Weibull <source@pcppopper.org>
+" URL: http://www.pcppopper.org/vim/indent/pcp/css/
+" Latest Revision: 2004-04-25
+" arch-tag: ccfd77a0-1c9a-43f7-a407-bbe704541442
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+
+let b:did_indent = 1
+
+setlocal indentexpr=GetCSSIndent()
+setlocal indentkeys-=:,0# indentkeys-=e
+
+" Only define the function once.
+if exists("*GetCSSIndent")
+ finish
+endif
+
+function! s:LookupLine(lnum)
+ " find a non-blank line above the current line
+ let lnum = prevnonblank(a:lnum - 1)
+
+ if lnum == 0
+ return 0
+ endif
+
+ let line = getline(lnum)
+
+ " if the line has an end comment sequence we need to find a line
+ " that isn't affected by the comment.
+ if line =~ '\*/'
+ while line !~ '/\*'
+ let lnum = lnum - 1
+ let line = getline(lnum)
+ endwhile
+ endif
+
+ " if the line we found only contained the comment and whitespace
+ " we need to find another line to use...
+ if line =~ '^\s*/\*'
+ return s:LookupLine(lnum)
+ else
+ return lnum
+ endif
+endfunction
+
+function GetCSSIndent()
+ let lnum = s:LookupLine(v:lnum)
+
+ if lnum == 0
+ return 0
+ endif
+
+ " remove commented stuff from line
+ let line = substitute(getline(lnum), '/\*.\*/', '', 'eg')
+
+ let ind = indent(lnum)
+
+ " check for opening brace on the previous line
+ " skip if it also contains a closing brace...
+ if line =~ '{\(.*}\)\@!'
+ let ind = ind + &sw
+ endif
+
+ let line = getline(v:lnum)
+
+ " check for closing brace first on current line
+ if line =~ '^\s*}'
+ let ind = ind - &sw
+ endif
+
+ return ind
+endfunction
+
+" vim: set sts=2 sw=2:
diff --git a/runtime/indent/docbk.vim b/runtime/indent/docbk.vim
new file mode 100644
index 000000000..6b807bbf3
--- /dev/null
+++ b/runtime/indent/docbk.vim
@@ -0,0 +1,13 @@
+" Vim indent file
+" Language: DocBook Documentation Format
+" Maintainer: Nikolai Weibull <source@pcppopper.org>
+" URL: http://www.pcppopper.org/vim/indent/pcp/docbk/
+" Latest Revision: 2004-05-22
+" arch-tag: 3d073af7-1d69-42a2-99ad-9a49a21eb28f
+
+" Same as XML indenting for now.
+runtime! indent/xml.vim
+
+setlocal indentexpr=XmlIndentGet(v:lnum,0)
+
+" vim: set sts=2 sw=2:
diff --git a/runtime/indent/dylan.vim b/runtime/indent/dylan.vim
new file mode 100644
index 000000000..0afcbeada
--- /dev/null
+++ b/runtime/indent/dylan.vim
@@ -0,0 +1,90 @@
+" Vim indent file
+" Language: Dylan
+" Version: 0.01
+" Last Change: 2003 Feb 04
+" Maintainer: Brent A. Fulgham <bfulgham@debian.org>
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal indentkeys+==~begin,=~block,=~case,=~cleanup,=~define,=~end,=~else,=~elseif,=~exception,=~for,=~finally,=~if,=~otherwise,=~select,=~unless,=~while
+
+" Define the appropriate indent function but only once
+setlocal indentexpr=DylanGetIndent()
+if exists("*DylanGetIndent")
+ finish
+endif
+
+function DylanGetIndent()
+ " Get the line to be indented
+ let cline = getline(v:lnum)
+
+ " Don't reindent comments on first column
+ if cline =~ '^/\[/\*]'
+ return 0
+ endif
+
+ "Find the previous non-blank line
+ let lnum = prevnonblank(v:lnum - 1)
+ "Use zero indent at the top of the file
+ if lnum == 0
+ return 0
+ endif
+
+ let prevline=getline(lnum)
+ let ind = indent(lnum)
+ let chg = 0
+
+ " If previous line was a comment, use its indent
+ if prevline =~ '^\s*//'
+ return ind
+ endif
+
+ " If previous line was a 'define', indent
+ if prevline =~? '\(^\s*\(begin\|block\|case\|define\|else\|elseif\|for\|finally\|if\|select\|unless\|while\)\|\s*\S*\s*=>$\)'
+ let chg = &sw
+ " local methods indent the shift-width, plus 6 for the 'local'
+ elseif prevline =~? '^\s*local'
+ let chg = &sw + 6
+ " If previous line was a let with no closing semicolon, indent
+ elseif prevline =~? '^\s*let.*[^;]\s*$'
+ let chg = &sw
+ " If previous line opened a parenthesis, and did not close it, indent
+ elseif prevline =~ '^.*(\s*[^)]*\((.*)\)*[^)]*$'
+ return = match( prevline, '(.*\((.*)\|[^)]\)*.*$') + 1
+ "elseif prevline =~ '^.*(\s*[^)]*\((.*)\)*[^)]*$'
+ elseif prevline =~ '^[^(]*)\s*$'
+ " This line closes a parenthesis. Find opening
+ let curr_line = prevnonblank(lnum - 1)
+ while curr_line >= 0
+ let str = getline(curr_line)
+ if str !~ '^.*(\s*[^)]*\((.*)\)*[^)]*$'
+ let curr_line = prevnonblank(curr_line - 1)
+ else
+ break
+ endif
+ endwhile
+ if curr_line < 0
+ return -1
+ endif
+ let ind = indent(curr_line)
+ " Although we found the closing parenthesis, make sure this
+ " line doesn't start with an indentable command:
+ let curr_str = getline(curr_line)
+ if curr_str =~? '^\s*\(begin\|block\|case\|define\|else\|elseif\|for\|finally\|if\|select\|unless\|while\)'
+ let chg = &sw
+ endif
+ endif
+
+ " If a line starts with end, un-indent (even if we just indented!)
+ if cline =~? '^\s*\(cleanup\|end\|else\|elseif\|exception\|finally\|otherwise\)'
+ let chg = chg - &sw
+ endif
+
+ return ind + chg
+endfunction
+
+" vim:sw=2 tw=130
diff --git a/runtime/indent/eiffel.vim b/runtime/indent/eiffel.vim
new file mode 100644
index 000000000..ac31d1043
--- /dev/null
+++ b/runtime/indent/eiffel.vim
@@ -0,0 +1,106 @@
+" Vim indent file
+" Language: Eiffel
+" Maintainer: David Clarke <gadicath@dishevelled.net>
+" $Date$
+" $Revision$
+" URL: http://gadicath.webhop.net/other/eiffel.vim
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal indentexpr=GetEiffelIndent()
+setlocal nolisp
+setlocal nosmartindent
+setlocal nocindent
+setlocal autoindent
+setlocal comments=:--
+setlocal indentkeys+==end,=else,=ensure,=require,=check,=loop,=until
+setlocal indentkeys+==creation,=feature,=inherit,=class,=is,=redefine,=rename,=variant
+setlocal indentkeys+==invariant,=do,=local,=export
+setlocal sw=3
+setlocal tw=78
+
+" 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: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*\(--\).*\)\=$'
+let s:inheritance_dent = '\s*\(redefine\|rename\|export\)\>'
+
+
+" Only define the function once.
+if exists("*GetEiffelIndent")
+ finish
+endif
+
+function GetEiffelIndent()
+
+ " Eiffel Class indenting
+ "
+ " Find a non-blank line above the current line.
+ let lnum = prevnonblank(v:lnum - 1)
+
+ " At the start of the file use zero indent.
+ if lnum == 0
+ return 0
+ endif
+
+ " trust the user's indenting
+ if getline(lnum) =~ s:trust_user_indent
+ return -1
+ endif
+
+ " 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
+ 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
+ endif
+
+ " Indent to double indent
+ if getline(v:lnum) =~ s:inheritance_dent
+ let ind = 2 * &sw
+ endif
+
+ " Indent line after the first line of the function definition
+ if getline(lnum) =~ s:single_dent
+ let ind = ind + &sw
+ endif
+
+ " The following should always be at the start of a line, no indenting
+ if getline(v:lnum) =~ s:no_indent
+ let ind = 0
+ endif
+
+ " Subtract a 'shiftwidth', if this isn't the first thing after the 'is'
+ " 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
+ endif
+
+ " Subtract a shiftwidth for end statements
+ if getline(v:lnum) =~ '^\s*end\>'
+ let ind = ind - &sw
+ 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 == 3
+ let ind = 0
+ endif
+
+ return ind
+endfunction
+
+" vim:sw=2
diff --git a/runtime/indent/eterm.vim b/runtime/indent/eterm.vim
new file mode 100644
index 000000000..2e7ba1858
--- /dev/null
+++ b/runtime/indent/eterm.vim
@@ -0,0 +1,49 @@
+" Vim indent file
+" Language: Eterm configuration file
+" Maintainer: Nikolai Weibull <source@pcppopper.org>
+" URL: http://www.pcppopper.org/vim/indent/pcp/eterm/
+" Latest Revision: 2004-04-25
+" arch-tag: a22a92b1-c59f-4f47-8207-b21db6549b21
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+
+let b:did_indent = 1
+
+setlocal indentexpr=GetEtermIndent()
+setlocal indentkeys=!^F,o,O,=end
+
+" Only define the function once.
+if exists("*GetEtermIndent")
+ finish
+endif
+
+function GetEtermIndent()
+ " Find a non-blank line above the current line.
+ let lnum = prevnonblank(v:lnum - 1)
+
+ " Hit the start of the file, use zero indent.
+ if lnum == 0
+ return 0
+ endif
+
+ let line = getline(lnum)
+ let ind = indent(lnum)
+
+ if line =~ '^\s*begin\>'
+ let ind = ind + &sw
+ endif
+
+ let line = getline(v:lnum)
+
+ " Check for closing brace on current line
+ if line =~ '^\s*end\>'
+ let ind = ind - &sw
+ endif
+
+ return ind
+endfunction
+
+" vim: set sts=2 sw=2:
diff --git a/runtime/indent/fortran.vim b/runtime/indent/fortran.vim
new file mode 100644
index 000000000..b14273aa3
--- /dev/null
+++ b/runtime/indent/fortran.vim
@@ -0,0 +1,161 @@
+" Vim indent file
+" Language: Fortran95 (and Fortran90, Fortran77, F and elf90)
+" Version: 0.36
+" URL: http://www.unb.ca/chem/ajit/indent/fortran.vim
+" Last Change: 2004 Apr. 05
+" Maintainer: Ajit J. Thakkar <ajit@unb.ca>; <http://www.unb.ca/chem/ajit/>
+" Usage: Do :help fortran-indent from Vim
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+let s:cposet=&cpoptions
+set cpoptions-=C
+
+setlocal indentkeys+==~end,=~case,=~if,=~else,=~do,=~where,=~elsewhere,=~select
+setlocal indentkeys+==~endif,=~enddo,=~endwhere,=~endselect
+
+" Determine whether this is a fixed or free format source file
+" if this hasn't been done yet
+if !exists("b:fortran_fixed_source")
+ if exists("fortran_free_source")
+ " User guarantees free source form
+ let b:fortran_fixed_source = 0
+ elseif exists("fortran_fixed_source")
+ " User guarantees fixed source form
+ let b:fortran_fixed_source = 1
+ else
+ " f90 and f95 allow both fixed and free source form
+ " assume fixed source form unless signs of free source form
+ " are detected in the first five columns of the first 25 lines
+ " Detection becomes more accurate and time-consuming if more lines
+ " are checked. Increase the limit below if you keep lots of comments at
+ " the very top of each file and you have a fast computer
+ let s:lmax = 25
+ if ( s:lmax > line("$") )
+ let s:lmax = line("$")
+ endif
+ let b:fortran_fixed_source = 1
+ let s:ln=1
+ while s:ln <= s:lmax
+ let s:test = strpart(getline(s:ln),0,5)
+ if s:test[0] !~ '[Cc*!#]' && s:test !~ '^ \+[!#]' && s:test =~ '[^ 0-9\t]'
+ let b:fortran_fixed_source = 0
+ break
+ endif
+ let s:ln = s:ln + 1
+ endwhile
+ endif
+endif
+
+" Define the appropriate indent function but only once
+if (b:fortran_fixed_source == 1)
+ setlocal indentexpr=FortranGetFixedIndent()
+ if exists("*FortranGetFixedIndent")
+ finish
+ endif
+else
+ setlocal indentexpr=FortranGetFreeIndent()
+ if exists("*FortranGetFreeIndent")
+ finish
+ endif
+endif
+
+function FortranGetIndent(lnum)
+ let ind = indent(a:lnum)
+ let prevline=getline(a:lnum)
+ " Strip tail comment
+ let prevstat=substitute(prevline, '!.*$', '', '')
+
+ "Indent do loops only if they are all guaranteed to be of do/end do type
+ if exists("b:fortran_do_enddo") || exists("fortran_do_enddo")
+ if prevstat =~? '^\s*\(\d\+\s\)\=\s*\(\a\w*\s*:\)\=\s*do\>'
+ let ind = ind + &sw
+ endif
+ if getline(v:lnum) =~? '^\s*\(\d\+\s\)\=\s*end\s*do\>'
+ let ind = ind - &sw
+ endif
+ endif
+
+ "Add a shiftwidth to statements following if, else, case,
+ "where and elsewhere statements
+ if prevstat =~? '^\s*\(\d\+\s\)\=\s*\(else\|case\|where\|elsewhere\)\>'
+ \ || prevstat =~? '^\s*\(\d\+\s\)\=\s*\(\a\w*\s*:\)\=\s*if\>'
+ let ind = ind + &sw
+ " Remove unwanted indent after logical and arithmetic ifs
+ if prevstat =~? '\<if\>' && prevstat !~? '\<then\>'
+ let ind = ind - &sw
+ endif
+ endif
+
+ "Subtract a shiftwidth from else, elsewhere, case, end if,
+ " end where and end select statements
+ if getline(v:lnum) =~? '^\s*\(\d\+\s\)\=\s*'
+ \. '\(else\|elsewhere\|case\|end\s*\(if\|where\|select\)\)\>'
+ let ind = ind - &sw
+ " Fix indent for case statement immediately after select
+ if prevstat =~? '\<select\>'
+ let ind = ind + &sw
+ endif
+ endif
+
+ return ind
+endfunction
+
+function FortranGetFreeIndent()
+ "Find the previous non-blank line
+ let lnum = prevnonblank(v:lnum - 1)
+
+ "Use zero indent at the top of the file
+ if lnum == 0
+ return 0
+ endif
+
+ let ind=FortranGetIndent(lnum)
+ return ind
+endfunction
+
+function FortranGetFixedIndent()
+ let currline=getline(v:lnum)
+ "Don't indent comments, continuation lines and labelled lines
+ if strpart(currline,0,6) =~ '[^ \t]'
+ let ind = indent(v:lnum)
+ return ind
+ endif
+
+ "Find the previous line which is not blank, not a comment,
+ "not a continuation line, and does not have a label
+ let lnum = v:lnum - 1
+ while lnum > 0
+ let prevline=getline(lnum)
+ if (prevline =~ "^[C*!]") || (prevline =~ "^\s*$")
+ \ || (strpart(prevline,5,1) !~ "[ 0]")
+ " Skip comments, blank lines and continuation lines
+ let lnum = lnum - 1
+ else
+ let test=strpart(prevline,0,5)
+ if test =~ "[0-9]"
+ " Skip lines with statement numbers
+ let lnum = lnum - 1
+ else
+ break
+ endif
+ endif
+ endwhile
+
+ "First line must begin at column 7
+ if lnum == 0
+ return 6
+ endif
+
+ let ind=FortranGetIndent(lnum)
+ return ind
+endfunction
+
+let &cpoptions=s:cposet
+unlet s:cposet
+
+" vim:sw=2 tw=130
diff --git a/runtime/indent/html.vim b/runtime/indent/html.vim
new file mode 100644
index 000000000..d78da193b
--- /dev/null
+++ b/runtime/indent/html.vim
@@ -0,0 +1,219 @@
+" Description: html indenter
+" Author: Johannes Zellner <johannes@zellner.org>
+" Last Change: Tue, 27 Apr 2004 10:28:39 CEST
+" Globals: g:html_indent_tags -- indenting tags
+" g:html_indent_strict -- inhibit 'O O' elements
+" g:html_indent_strict_table -- inhibit 'O -' elements
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+
+" [-- local settings (must come before aborting the script) --]
+setlocal indentexpr=HtmlIndentGet(v:lnum)
+setlocal indentkeys=o,O,*<Return>,<>>,<bs>,{,}
+
+
+if exists('g:html_indent_tags')
+ unlet g:html_indent_tags
+endif
+
+" [-- helper function to assemble tag list --]
+fun! <SID>HtmlIndentPush(tag)
+ if exists('g:html_indent_tags')
+ let g:html_indent_tags = g:html_indent_tags.'\|'.a:tag
+ else
+ let g:html_indent_tags = a:tag
+ endif
+endfun
+
+
+" [-- <ELEMENT ? - - ...> --]
+call <SID>HtmlIndentPush('a')
+call <SID>HtmlIndentPush('abbr')
+call <SID>HtmlIndentPush('acronym')
+call <SID>HtmlIndentPush('address')
+call <SID>HtmlIndentPush('b')
+call <SID>HtmlIndentPush('bdo')
+call <SID>HtmlIndentPush('big')
+call <SID>HtmlIndentPush('blockquote')
+call <SID>HtmlIndentPush('button')
+call <SID>HtmlIndentPush('caption')
+call <SID>HtmlIndentPush('center')
+call <SID>HtmlIndentPush('cite')
+call <SID>HtmlIndentPush('code')
+call <SID>HtmlIndentPush('colgroup')
+call <SID>HtmlIndentPush('del')
+call <SID>HtmlIndentPush('dfn')
+call <SID>HtmlIndentPush('dir')
+call <SID>HtmlIndentPush('div')
+call <SID>HtmlIndentPush('dl')
+call <SID>HtmlIndentPush('em')
+call <SID>HtmlIndentPush('fieldset')
+call <SID>HtmlIndentPush('font')
+call <SID>HtmlIndentPush('form')
+call <SID>HtmlIndentPush('frameset')
+call <SID>HtmlIndentPush('h1')
+call <SID>HtmlIndentPush('h2')
+call <SID>HtmlIndentPush('h3')
+call <SID>HtmlIndentPush('h4')
+call <SID>HtmlIndentPush('h5')
+call <SID>HtmlIndentPush('h6')
+call <SID>HtmlIndentPush('i')
+call <SID>HtmlIndentPush('iframe')
+call <SID>HtmlIndentPush('ins')
+call <SID>HtmlIndentPush('kbd')
+call <SID>HtmlIndentPush('label')
+call <SID>HtmlIndentPush('legend')
+call <SID>HtmlIndentPush('map')
+call <SID>HtmlIndentPush('menu')
+call <SID>HtmlIndentPush('noframes')
+call <SID>HtmlIndentPush('noscript')
+call <SID>HtmlIndentPush('object')
+call <SID>HtmlIndentPush('ol')
+call <SID>HtmlIndentPush('optgroup')
+" call <SID>HtmlIndentPush('pre')
+call <SID>HtmlIndentPush('q')
+call <SID>HtmlIndentPush('s')
+call <SID>HtmlIndentPush('samp')
+call <SID>HtmlIndentPush('script')
+call <SID>HtmlIndentPush('select')
+call <SID>HtmlIndentPush('small')
+call <SID>HtmlIndentPush('span')
+call <SID>HtmlIndentPush('strong')
+call <SID>HtmlIndentPush('style')
+call <SID>HtmlIndentPush('sub')
+call <SID>HtmlIndentPush('sup')
+call <SID>HtmlIndentPush('table')
+call <SID>HtmlIndentPush('textarea')
+call <SID>HtmlIndentPush('title')
+call <SID>HtmlIndentPush('tt')
+call <SID>HtmlIndentPush('u')
+call <SID>HtmlIndentPush('ul')
+call <SID>HtmlIndentPush('var')
+
+
+" [-- <ELEMENT ? O O ...> --]
+if !exists('g:html_indent_strict')
+ call <SID>HtmlIndentPush('body')
+ call <SID>HtmlIndentPush('head')
+ call <SID>HtmlIndentPush('html')
+ call <SID>HtmlIndentPush('tbody')
+endif
+
+
+" [-- <ELEMENT ? O - ...> --]
+if !exists('g:html_indent_strict_table')
+ call <SID>HtmlIndentPush('th')
+ call <SID>HtmlIndentPush('td')
+ call <SID>HtmlIndentPush('tr')
+ call <SID>HtmlIndentPush('tfoot')
+ call <SID>HtmlIndentPush('thead')
+endif
+
+delfun <SID>HtmlIndentPush
+
+set cpo-=C
+
+" [-- count indent-increasing tags of line a:lnum --]
+fun! <SID>HtmlIndentOpen(lnum, pattern)
+ let s = substitute('x'.getline(a:lnum),
+ \ '.\{-}\(\(<\)\('.a:pattern.'\)\>\)', "\1", 'g')
+ let s = substitute(s, "[^\1].*$", '', '')
+ return strlen(s)
+endfun
+
+" [-- count indent-decreasing tags of line a:lnum --]
+fun! <SID>HtmlIndentClose(lnum, pattern)
+ let s = substitute('x'.getline(a:lnum),
+ \ '.\{-}\(\(<\)/\('.a:pattern.'\)\>>\)', "\1", 'g')
+ let s = substitute(s, "[^\1].*$", '', '')
+ return strlen(s)
+endfun
+
+" [-- count indent-increasing '{' of (java|css) line a:lnum --]
+fun! <SID>HtmlIndentOpenAlt(lnum)
+ return strlen(substitute(getline(a:lnum), '[^{]\+', '', 'g'))
+endfun
+
+" [-- count indent-decreasing '}' of (java|css) line a:lnum --]
+fun! <SID>HtmlIndentCloseAlt(lnum)
+ return strlen(substitute(getline(a:lnum), '[^}]\+', '', 'g'))
+endfun
+
+" [-- return the sum of indents respecting the syntax of a:lnum --]
+fun! <SID>HtmlIndentSum(lnum, style)
+ if a:style == match(getline(a:lnum), '^\s*</')
+ if a:style == match(getline(a:lnum), '^\s*</\<\('.g:html_indent_tags.'\)\>')
+ let open = <SID>HtmlIndentOpen(a:lnum, g:html_indent_tags)
+ let close = <SID>HtmlIndentClose(a:lnum, g:html_indent_tags)
+ if 0 != open || 0 != close
+ return open - close
+ endif
+ endif
+ endif
+ if '' != &syntax &&
+ \ synIDattr(synID(a:lnum, 1, 1), 'name') =~ '\(css\|java\).*' &&
+ \ synIDattr(synID(a:lnum, strlen(getline(a:lnum)), 1), 'name')
+ \ =~ '\(css\|java\).*'
+ if a:style == match(getline(a:lnum), '^\s*}')
+ return <SID>HtmlIndentOpenAlt(a:lnum) - <SID>HtmlIndentCloseAlt(a:lnum)
+ endif
+ endif
+ return 0
+endfun
+
+fun! HtmlIndentGet(lnum)
+ " Find a non-empty line above the current line.
+ let lnum = prevnonblank(a:lnum - 1)
+
+ " Hit the start of the file, use zero indent.
+ if lnum == 0
+ return 0
+ endif
+
+ let restore_ic = &ic
+ setlocal ic " ignore case
+
+ " [-- special handling for <pre>: no indenting --]
+ if getline(a:lnum) =~ '\c</pre>'
+ \ || 0 < searchpair('\c<pre>', '', '\c</pre>', 'nWb')
+ \ || 0 < searchpair('\c<pre>', '', '\c</pre>', 'nW')
+ " we're in a line with </pre> or inside <pre> ... </pre>
+ return -1
+ endif
+
+ " [-- special handling for <javascript>: use cindent --]
+ let js = '<script.*type\s*=\s*.*java'
+ if 0 < searchpair(js, '', '</script>', 'nWb')
+ \ || 0 < searchpair(js, '', '</script>', 'nW')
+ " we're inside javascript
+ if getline(lnum) !~ js && getline(a:lnum) != '</script>'
+ return cindent(a:lnum)
+ endif
+ endif
+
+ if getline(lnum) =~ '\c</pre>'
+ " line before the current line a:lnum contains
+ " a closing </pre>. --> search for line before
+ " starting <pre> to restore the indent.
+ let preline = prevnonblank(search('\c<pre>', 'bW') - 1)
+ if preline > 0
+ return indent(preline)
+ endif
+ endif
+
+ let ind = <SID>HtmlIndentSum(lnum, -1)
+ let ind = ind + <SID>HtmlIndentSum(a:lnum, 0)
+
+ if restore_ic == 0
+ setlocal noic
+ endif
+
+ return indent(lnum) + (&sw * ind)
+endfun
+
+" [-- EOF <runtime>/indent/html.vim --]
diff --git a/runtime/indent/idlang.vim b/runtime/indent/idlang.vim
new file mode 100644
index 000000000..97c31ada5
--- /dev/null
+++ b/runtime/indent/idlang.vim
@@ -0,0 +1,63 @@
+" IDL (Interactive Data Language) indent file.
+" Language: IDL (ft=idlang)
+" Last change: 2002 Sep 23
+" Maintainer: Aleksandar Jelenak <ajelenak AT yahoo.com>
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal indentkeys=o,O,0=endif,0=ENDIF,0=endelse,0=ENDELSE,0=endwhile,
+ \0=ENDWHILE,0=endfor,0=ENDFOR,0=endrep,0=ENDREP
+
+setlocal indentexpr=GetIdlangIndent(v:lnum)
+
+" Only define the function once.
+if exists("*GetIdlangIndent")
+ finish
+endif
+
+function GetIdlangIndent(lnum)
+ " First non-empty line above the current line.
+ let pnum = prevnonblank(v:lnum-1)
+ " v:lnum is the first non-empty line -- zero indent.
+ if pnum == 0
+ return 0
+ endif
+ " Second non-empty line above the current line.
+ let pnum2 = prevnonblank(pnum-1)
+
+ " Current indent.
+ let curind = indent(pnum)
+
+ " Indenting of continued lines.
+ if getline(pnum) =~ '\$\s*\(;.*\)\=$'
+ if getline(pnum2) !~ '\$\s*\(;.*\)\=$'
+ let curind = curind+&sw
+ endif
+ else
+ if getline(pnum2) =~ '\$\s*\(;.*\)\=$'
+ let curind = curind-&sw
+ endif
+ endif
+
+ " Indenting blocks of statements.
+ if getline(v:lnum) =~? '^\s*\(endif\|endelse\|endwhile\|endfor\|endrep\)\>'
+ if getline(pnum) =~? 'begin\>'
+ elseif indent(v:lnum) > curind-&sw
+ let curind = curind-&sw
+ else
+ return -1
+ endif
+ elseif getline(pnum) =~? 'begin\>'
+ if indent(v:lnum) < curind+&sw
+ let curind = curind+&sw
+ else
+ return -1
+ endif
+ endif
+ return curind
+endfunction
+
diff --git a/runtime/indent/ishd.vim b/runtime/indent/ishd.vim
new file mode 100644
index 000000000..9b4d7ff0d
--- /dev/null
+++ b/runtime/indent/ishd.vim
@@ -0,0 +1,65 @@
+" Description: InstallShield indenter
+" Author: Johannes Zellner <johannes@zellner.org>
+" Last Change: Tue, 27 Apr 2004 14:54:59 CEST
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal indentexpr=GetIshdIndent(v:lnum)
+setlocal indentkeys&
+setlocal indentkeys+==else,=elseif,=endif,=end,=begin,<:>
+" setlocal indentkeys-=0#
+
+" Only define the function once.
+if exists("*GetIshdIndent")
+ finish
+endif
+
+fun! GetIshdIndent(lnum)
+ " labels and preprocessor get zero indent immediately
+ let this_line = getline(a:lnum)
+ let LABELS_OR_PREPROC = '^\s*\(\<\k\+\>:\s*$\|#.*\)'
+ let LABELS_OR_PREPROC_EXCEPT = '^\s*\<default\+\>:'
+ if this_line =~ LABELS_OR_PREPROC && this_line !~ LABELS_OR_PREPROC_EXCEPT
+ return 0
+ endif
+
+ " Find a non-blank line above the current line.
+ " Skip over labels and preprocessor directives.
+ let lnum = a:lnum
+ while lnum > 0
+ let lnum = prevnonblank(lnum - 1)
+ let previous_line = getline(lnum)
+ if previous_line !~ LABELS_OR_PREPROC || previous_line =~ LABELS_OR_PREPROC_EXCEPT
+ break
+ endif
+ endwhile
+
+ " Hit the start of the file, use zero indent.
+ if lnum == 0
+ return 0
+ endif
+
+ let ind = indent(lnum)
+
+ " Add
+ if previous_line =~ '^\s*\<\(function\|begin\|switch\|case\|default\|if.\{-}then\|else\|elseif\|while\|repeat\)\>'
+ let ind = ind + &sw
+ endif
+
+ " Subtract
+ if this_line =~ '^\s*\<endswitch\>'
+ let ind = ind - 2 * &sw
+ elseif this_line =~ '^\s*\<\(begin\|end\|endif\|endwhile\|else\|elseif\|until\)\>'
+ let ind = ind - &sw
+ elseif this_line =~ '^\s*\<\(case\|default\)\>'
+ if previous_line !~ '^\s*\<switch\>'
+ let ind = ind - &sw
+ endif
+ endif
+
+ return ind
+endfun
diff --git a/runtime/indent/java.vim b/runtime/indent/java.vim
new file mode 100644
index 000000000..a600c4bf3
--- /dev/null
+++ b/runtime/indent/java.vim
@@ -0,0 +1,128 @@
+" Vim indent file
+" Language: Java
+" Maintainer: Toby Allsopp <toby.allsopp@peace.com>
+" Last Change: 2003 Oct 21
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+" Indent Java anonymous classes correctly.
+setlocal cinoptions& cinoptions+=j1
+
+" The "extends" and "implements" lines start off with the wrong indent.
+setlocal indentkeys& indentkeys+=0=extends indentkeys+=0=implements
+
+" Set the function to do the work.
+setlocal indentexpr=GetJavaIndent()
+
+" Only define the function once.
+if exists("*GetJavaIndent")
+ finish
+endif
+
+function! SkipJavaBlanksAndComments(startline)
+ let lnum = a:startline
+ while lnum > 1
+ let lnum = prevnonblank(lnum)
+ if getline(lnum) =~ '\*/\s*$'
+ while getline(lnum) !~ '/\*' && lnum > 1
+ let lnum = lnum - 1
+ endwhile
+ if getline(lnum) =~ '^\s*/\*'
+ let lnum = lnum - 1
+ else
+ break
+ endif
+ elseif getline(lnum) =~ '^\s*//'
+ let lnum = lnum - 1
+ else
+ break
+ endif
+ endwhile
+ return lnum
+endfunction
+
+function GetJavaIndent()
+
+ " Java is just like C; use the built-in C indenting and then correct a few
+ " specific cases.
+ let theIndent = cindent(v:lnum)
+
+ " If we're in the middle of a comment then just trust cindent
+ if getline(v:lnum) =~ '^\s*\*'
+ return theIndent
+ endif
+
+ " find start of previous line, in case it was a continuation line
+ let lnum = SkipJavaBlanksAndComments(v:lnum - 1)
+ let prev = lnum
+ while prev > 1
+ let next_prev = SkipJavaBlanksAndComments(prev - 1)
+ if getline(next_prev) !~ ',\s*$'
+ break
+ endif
+ let prev = next_prev
+ endwhile
+
+ " 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
+ endif
+
+ " correct for continuation lines of "throws", "implements" and "extends"
+ let cont_kw = matchstr(getline(prev),
+ \ '^\s*\zs\(throws\|implements\|extends\)\>\ze.*,\s*$')
+ if strlen(cont_kw) > 0
+ let amount = strlen(cont_kw) + 1
+ if getline(lnum) !~ ',\s*$'
+ let theIndent = theIndent - (amount + &sw)
+ if theIndent < 0
+ let theIndent = 0
+ endif
+ elseif prev == lnum
+ let theIndent = theIndent + amount
+ if cont_kw ==# 'throws'
+ let theIndent = theIndent + &sw
+ endif
+ endif
+ elseif getline(prev) =~ '^\s*\(throws\|implements\|extends\)\>'
+ \ && (getline(prev) =~ '{\s*$'
+ \ || getline(v:lnum) =~ '^\s*{\s*$')
+ let theIndent = theIndent - &sw
+ 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 %
+ let lnum = line('.')
+ if lnum < v:lnum
+ while lnum > 1
+ let next_lnum = SkipJavaBlanksAndComments(lnum - 1)
+ if getline(lnum) !~ '^\s*\(throws\|extends\|implements\)\>'
+ \ && getline(next_lnum) !~ ',\s*$'
+ break
+ endif
+ let lnum = prevnonblank(next_lnum)
+ endwhile
+ return indent(lnum)
+ endif
+ endif
+
+ " Below a line starting with "}" never indent more. Needed for a method
+ " below a method with an indented "throws" clause.
+ let lnum = SkipJavaBlanksAndComments(v:lnum - 1)
+ if getline(lnum) =~ '^\s*}\s*\(//.*\|/\*.*\)\=$' && indent(lnum) < theIndent
+ let theIndent = indent(lnum)
+ endif
+
+ return theIndent
+endfunction
+
+" vi: sw=2 et
diff --git a/runtime/indent/lua.vim b/runtime/indent/lua.vim
new file mode 100644
index 000000000..37e397e37
--- /dev/null
+++ b/runtime/indent/lua.vim
@@ -0,0 +1,49 @@
+" Vim indent file
+" Language: Lua script
+" Maintainer: Marcus Aurelius Farias <marcuscf@vant.com.br>
+" First Author: Max Ischenko <mfi@ukr.net>
+" Last Change: 2003 Jan 20
+
+" Only define the function once.
+if exists("*GetLuaIndent") | finish | endif
+
+setlocal indentexpr=GetLuaIndent()
+
+" To make Vim call GetLuaIndent() when it finds '\s*end' or '\s*until'
+" on the current line (else is default).
+setlocal indentkeys+=0=end,0=until
+
+setlocal autoindent
+
+function! GetLuaIndent()
+ " Find a non-blank line above the current line.
+ let lnum = prevnonblank(v:lnum - 1)
+
+ " Hit the start of the file, use zero indent.
+ if lnum == 0
+ return 0
+ endif
+
+ " Add a 'shiftwidth' after lines beginning with:
+ " function, if, for, while, repeat, else, elseif, '{'
+ let ind = indent(lnum)
+ let flag = 0
+ if getline(lnum) =~ '^\s*\(function\>\|if\>\|for\>\|while\>\|repeat\>\|else\>\|elseif\>\|do\>\)' || getline(lnum) =~ '{\s*$' || getline(lnum) =~ '\s*=\s*function'
+ let ind = ind + &sw
+ let flag = 1
+ endif
+
+ " Subtract a 'shiftwidth' after lines ending with
+ " 'end' when they begin with while, if, for, etc.
+ if flag == 1 && getline(lnum) =~ '\<end\>\|\<until\>'
+ let ind = ind - &sw
+ endif
+
+ " Subtract a 'shiftwidth' on end, else (and elseif), until and '}'
+ " This is the part that requires 'indentkeys'.
+ if getline(v:lnum) =~ '^\s*\(end\|else\|until\|}\)'
+ let ind = ind - &sw
+ endif
+
+ return ind
+endfunction
diff --git a/runtime/indent/make.vim b/runtime/indent/make.vim
new file mode 100644
index 000000000..f376424ad
--- /dev/null
+++ b/runtime/indent/make.vim
@@ -0,0 +1,57 @@
+" Vim indent file
+" Language: Makefile
+" Maintainer: Nikolai Weibull <source@pcppopper.org>
+" URL: http://www.pcppopper.org/vim/indent/pcp/make/
+" Latest Revision: 2004-04-25
+" arch-tag: b539e147-a05c-4860-98af-1d2436db2f4b
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+
+let b:did_indent = 1
+
+setlocal indentexpr=GetMakeIndent()
+setlocal indentkeys=!^F,o,O
+
+" Only define the function once.
+if exists("*GetMakeIndent")
+ finish
+endif
+
+function s:GetStringWidth(line, str)
+ let end = matchend(a:line, a:str)
+ let width = 0
+ let i = 0
+ while i < end
+ if a:line[i] != "\t"
+ let width = width + 1
+ else
+ let width = width + &ts - (width % &ts)
+ endif
+ let i = i + 1
+ endwhile
+ return width
+endfunction
+
+function GetMakeIndent()
+ if v:lnum == 1
+ return 0
+ endif
+
+ let ind = indent(v:lnum - 1)
+ let line = getline(v:lnum - 1)
+
+ if line == ''
+ let ind = 0
+ elseif line =~ '^[^ \t#:][^#:]*:\{1,2}\([^=:]\|$\)'
+ let ind = ind + &ts
+ elseif line =~ '^\s*\h\w*\s*=\s*.\+\\$'
+ let ind = s:GetStringWidth(line, '=\s*')
+ endif
+
+ return ind
+endfunction
+
+" vim: set sts=2 sw=2:
diff --git a/runtime/indent/matlab.vim b/runtime/indent/matlab.vim
new file mode 100644
index 000000000..7bccc7c0a
--- /dev/null
+++ b/runtime/indent/matlab.vim
@@ -0,0 +1,74 @@
+" Matlab indent file
+" Language: Matlab
+" Maintainer: Christophe Poucet <christophe.poucet@pandora.be>
+" Last Change: 6 January, 2001
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+" Some preliminary setting
+setlocal indentkeys=!,o,O=end,=case,=else,=elseif,=otherwise,=catch
+
+
+setlocal indentexpr=GetMatlabIndent(v:lnum)
+
+" Only define the function once.
+if exists("*GetMatlabIndent")
+ finish
+endif
+
+function GetMatlabIndent(lnum)
+ " Give up if this line is explicitly joined.
+ if getline(a:lnum - 1) =~ '\\$'
+ return -1
+ endif
+
+ " Search backwards for the first non-empty line.
+ let plnum = a:lnum - 1
+ while plnum > 0 && getline(plnum) =~ '^\s*$'
+ let plnum = plnum - 1
+ endwhile
+
+ if plnum == 0
+ " This is the first non-empty line, use zero indent.
+ return 0
+ endif
+
+ let curind = indent(plnum)
+
+ " If the current line is a stop-block statement...
+ if getline(v:lnum) =~ '^\s*\(end\|else\|elseif\|case\|otherwise\|catch\)\>'
+ " See if this line does not follow the line right after an openblock
+ if getline(plnum) =~ '^\s*\(for\|if\|else\|elseif\|case\|while\|switch\|try\|otherwise\|catch\)\>'
+ " See if the user has already dedented
+ elseif indent(v:lnum) > curind - &sw
+ " If not, recommend one dedent
+ let curind = curind - &sw
+ else
+ " Otherwise, trust the user
+ return -1
+ endif
+" endif
+
+ " If the previous line opened a block
+ elseif getline(plnum) =~ '^\s*\(for\|if\|else\|elseif\|case\|while\|switch\|try\|otherwise\|catch\)\>'
+ " See if the user has already indented
+ if indent(v:lnum) < curind + &sw
+ "If not, recommend indent
+ let curind = curind + &sw
+ else
+ " Otherwise, trust the user
+ return -1
+ endif
+ endif
+
+
+
+ " If we got to here, it means that the user takes the standardversion, so we return it
+ return curind
+endfunction
+
+" vim:sw=2
diff --git a/runtime/indent/mp.vim b/runtime/indent/mp.vim
new file mode 100644
index 000000000..1aea4f809
--- /dev/null
+++ b/runtime/indent/mp.vim
@@ -0,0 +1,206 @@
+" MetaPost indent file
+" Language: MetaPost
+" Maintainer: Eugene Minkovskii <emin@mccme.ru>
+" Last Change: 2003 Nov 21
+" Version: 0.1
+" ==========================================================================
+
+" Identation Rules: {{{1
+" First of all, MetaPost language don't expect any identation rules.
+" This screept need for you only if you (not MetaPost) need to do
+" exactly code. If you don't need to use indentation, see
+" :help filetype-indent-off
+"
+" Note: Every rules of identation in MetaPost or TeX languages (and in some
+" other of course) is very subjective. I can release only my vision of this
+" promlem.
+"
+" ..........................................................................
+" Example of correct (by me) identation {{{2
+" shiftwidth=4
+" ==========================================================================
+" for i=0 upto 99:
+" z[i] = (0,1u) rotated (i*360/100);
+" endfor
+" draw z0 -- z10 -- z20
+" withpen ... % <- 2sw because breaked line
+" withcolor ...; % <- same as previous
+" draw z0 for i=1 upto 99:
+" -- z[i] % <- 1sw from left end of 'for' satement
+" endfor withpen ... % <- 0sw from left end of 'for' satement
+" withcolor ...; % <- 2sw because breaked line
+" draw if One: % <- This is internal if (like 'for' above)
+" one
+" elsif Other:
+" other
+" fi withpen ...;
+" if one: % <- This is external if
+" draw one;
+" elseif other:
+" draw other;
+" fi
+" draw z0; draw z1;
+" }}}
+" }}}
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal indentexpr=GetMetaPostIndent()
+setlocal indentkeys+=;,<:>,=if,=for,=def,=end,=else,=fi
+
+" Only define the function once.
+if exists("*GetMetaPostIndent")
+ finish
+endif
+
+" Auxiliary Definitions: {{{1
+function! MetaNextNonblankNoncomment(pos)
+ " Like nextnonblank() but ignore comment lines
+ let tmp = nextnonblank(a:pos)
+ while tmp && getline(tmp) =~ '^\s*%'
+ let tmp = nextnonblank(tmp+1)
+ endwhile
+ return tmp
+endfunction
+
+function! MetaPrevNonblankNoncomment(pos)
+ " Like prevnonblank() but ignore comment lines
+ let tmp = prevnonblank(a:pos)
+ while tmp && getline(tmp) =~ '^\s*%'
+ let tmp = prevnonblank(tmp-1)
+ endwhile
+ return tmp
+endfunction
+
+function! MetaSearchNoncomment(pattern, ...)
+ " Like search() but ignore commented areas
+ if a:0
+ let flags = a:1
+ elseif &wrapscan
+ let flags = "w"
+ else
+ let flags = "W"
+ endif
+ let cl = line(".")
+ let cc = col(".")
+ let tmp = search(a:pattern, flags)
+ while tmp && synIDattr(synID(line("."), col("."), 1), "name") =~
+ \ 'm[fp]\(Comment\|TeXinsert\|String\)'
+ let tmp = search(a:pattern, flags)
+ endwhile
+ if !tmp
+ call cursor(cl,cc)
+ endif
+ return tmp
+endfunction
+" }}}
+
+function! GetMetaPostIndent()
+ " not indent in comment ???
+ if synIDattr(synID(line("."), col("."), 1), "name") =~
+ \ 'm[fp]\(Comment\|TeXinsert\|String\)'
+ return -1
+ endif
+ " Some RegExps: {{{1
+ " end_of_item: all of end by ';'
+ " + all of end by :endfor, :enddef, :endfig, :endgroup, :fi
+ " + all of start by :beginfig(num), :begingroup
+ " + all of start by :for, :if, :else, :elseif and end by ':'
+ " + all of start by :def, :vardef and end by '='
+ let end_of_item = '\(' .
+ \ ';\|' .
+ \ '\<\(end\(for\|def\|fig\|group\)\|fi\)\>\|' .
+ \ '\<begin\(group\>\|fig\s*(\s*\d\+\s*)\)\|' .
+ \ '\<\(for\|if\|else\(if\)\=\)\>.\+:\|' .
+ \ '\<\(var\)\=def\>.\+=' . '\)'
+ " }}}
+ " Save: current position {{{1
+ let cl = line (".")
+ let cc = col (".")
+ let cs = getline(".")
+ " if it is :beginfig or :endfig use zero indent
+ if cs =~ '^\s*\(begin\|end\)fig\>'
+ return 0
+ endif
+ " }}}
+ " Initialise: ind variable {{{1
+ " search previous item not in current line
+ let p_semicol_l = MetaSearchNoncomment(end_of_item,"bW")
+ while p_semicol_l == cl
+ let p_semicol_l = MetaSearchNoncomment(end_of_item,"bW")
+ endwhile
+ " if this is first item in program use zero indent
+ if !p_semicol_l
+ return 0
+ endif
+ " if this is multiline item, remember first indent
+ if MetaNextNonblankNoncomment(p_semicol_l+1) < cl
+ let ind = indent(MetaNextNonblankNoncomment(p_semicol_l+1))
+ " else --- search pre-previous item for search first line in previous item
+ else
+ " search pre-previous item not in current line
+ let pp_semicol_l = MetaSearchNoncomment(end_of_item,"bW")
+ while pp_semicol_l == p_semicol_l
+ let pp_semicol_l = MetaSearchNoncomment(end_of_item,"bW")
+ endwhile
+ " if we find pre-previous item, remember indent of previous item
+ " else --- remember zero
+ if pp_semicol_l
+ let ind = indent(MetaNextNonblankNoncomment(line(".")+1))
+ else
+ let ind = 0
+ endif
+ endif
+ " }}}
+ " Increase Indent: {{{1
+ " if it is an internal/external :for or :if statements {{{2
+ let pnn_s = getline(MetaPrevNonblankNoncomment(cl-1))
+ if pnn_s =~ '\<\(for\|if\)\>.\+:\s*\($\|%\)'
+ let ind = match(pnn_s, '\<\(for\|if\)\>.\+:\s*\($\|%\)') + &sw
+ " }}}
+ " if it is a :def, :vardef, :beginfig, :begingroup, :else, :elseif {{{2
+ elseif pnn_s =~ '^\s*\(' .
+ \ '\(var\)\=def\|' .
+ \ 'begin\(group\|fig\s*(\s*\d\+\s*)\)\|' .
+ \ 'else\(if\)\=' . '\)\>'
+ let ind = ind + &sw
+ " }}}
+ " if it is a broken line {{{2
+ elseif pnn_s !~ end_of_item.'\s*\($\|%\)'
+ let ind = ind + (2 * &sw)
+ endif
+ " }}}
+ " }}}
+ " Decrease Indent: {{{1
+ " if this is :endfor or :enddef statements {{{2
+ " this is correct because :def cannot be inside :for
+ if cs =~ '\<end\(for\|def\)\=\>'
+ call MetaSearchNoncomment('\<for\>.\+:\s*\($\|%\)' . '\|' .
+ \ '^\s*\(var\)\=def\>',"bW")
+ if col(".") > 1
+ let ind = col(".") - 1
+ else
+ let ind = indent(".")
+ endif
+ " }}}
+ " if this is :fi, :else, :elseif statements {{{2
+ elseif cs =~ '\<\(else\(if\)\=\|fi\)\>'
+ call MetaSearchNoncomment('\<if\>.\+:\s*\($\|%\)',"bW")
+ let ind = col(".") - 1
+ " }}}
+ " if this is :endgroup statement {{{2
+ elseif cs =~ '^\s*endgroup\>'
+ let ind = ind - &sw
+ endif
+ " }}}
+ " }}}
+
+ return ind
+endfunction
+"
+
+" vim:sw=2:fdm=marker
diff --git a/runtime/indent/objc.vim b/runtime/indent/objc.vim
new file mode 100644
index 000000000..beadca9fa
--- /dev/null
+++ b/runtime/indent/objc.vim
@@ -0,0 +1,79 @@
+" Vim indent file
+" Language: Objective-C
+" Maintainer: Kazunobu Kuriyama <kazunobu.kuriyama@nifty.com>
+" Last Change: 2004 May 16
+"
+
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+setlocal cindent
+
+" Set the function to do the work.
+setlocal indentexpr=GetObjCIndent()
+
+" To make a colon (:) suggest an indentation other than a goto/swich label,
+setlocal indentkeys-=:
+setlocal indentkeys+=<:>
+
+" Only define the function once.
+if exists("*GetObjCIndent")
+ finish
+endif
+
+function s:GetWidth(line, regexp)
+ let end = matchend(a:line, a:regexp)
+ let width = 0
+ let i = 0
+ while i < end
+ if a:line[i] != "\t"
+ let width = width + 1
+ else
+ let width = width + &ts - (width % &ts)
+ endif
+ let i = i + 1
+ endwhile
+ return width
+endfunction
+
+function s:LeadingWhiteSpace(line)
+ let end = strlen(a:line)
+ let width = 0
+ let i = 0
+ while i < end
+ let char = a:line[i]
+ if char != " " && char != "\t"
+ break
+ endif
+ if char != "\t"
+ let width = width + 1
+ else
+ let width = width + &ts - (width % &ts)
+ endif
+ let i = i + 1
+ endwhile
+ return width
+endfunction
+
+
+function GetObjCIndent()
+ let theIndent = cindent(v:lnum)
+
+ let prev_line = getline(v:lnum - 1)
+ let cur_line = getline(v:lnum)
+
+ if prev_line !~# ":" || cur_line !~# ":"
+ return theIndent
+ endif
+
+ if prev_line !~# ";"
+ let prev_colon_pos = s:GetWidth(prev_line, ":")
+ let delta = s:GetWidth(cur_line, ":") - s:LeadingWhiteSpace(cur_line)
+ let theIndent = prev_colon_pos - delta
+ endif
+
+ return theIndent
+endfunction
diff --git a/runtime/indent/ocaml.vim b/runtime/indent/ocaml.vim
new file mode 100644
index 000000000..a26b4bc22
--- /dev/null
+++ b/runtime/indent/ocaml.vim
@@ -0,0 +1,311 @@
+" Vim indent file
+" Language: OCaml
+" Maintainers: Jean-Francois Yuen <jfyuen@ifrance.com>
+" Mike Leary <leary@nwlink.com>
+" Markus Mottl <markus@oefai.at>
+" URL: http://www.oefai.at/~markus/vim/indent/ocaml.vim
+" Last Change: 2003 Apr 14
+" 2003 Mar 05 - Added '{<' and some fixes (JY)
+" 2002 Nov 06 - Some fixes (JY)
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal expandtab
+setlocal indentexpr=GetOCamlIndent()
+setlocal indentkeys+=0=and,0=constraint,0=done,0=else,0=end,0=exception,0=external,0=if,0=in,0=include,0=inherit,0=initializer,0=let,0=method,0=open,0=then,0=type,0=val,0=with,0=;;,0=>\],0=\|\],0=\|,0=*),0=>},0},0\],0)
+setlocal nolisp
+setlocal nosmartindent
+setlocal textwidth=80
+
+" Comment formatting
+if (has("comments"))
+ setlocal comments=sr:(*,mb:*,ex:*)
+ setlocal fo=cqort
+endif
+
+" Only define the function once.
+if exists("*GetOCamlIndent")
+ finish
+endif
+
+" Define some patterns:
+let s:beflet = '^\s*\(initializer\|method\|try\)\|\(\<\(begin\|do\|else\|in\|then\|try\)\|->\|;\|(\)\s*$'
+let s:letpat = '^\s*\(let\|type\|module\|class\|open\|exception\|val\|include\|external\)\>'
+let s:letlim = '\(\<\(sig\|struct\)\|;;\)\s*$'
+let s:lim = '^\s*\(exception\|external\|include\|let\|module\|open\|type\|val\)\>'
+let s:module = '\<\%(begin\|sig\|struct\|object\)\>'
+let s:obj = '^\s*\(constraint\|inherit\|initializer\|method\|val\)\>\|\<\(object\|object\s*(.*)\)\s*$'
+let s:type = '^\s*\%(let\|type\)\>.*='
+let s:val = '^\s*\(val\|external\)\>.*:'
+
+" Skipping pattern, for comments
+function s:SkipPattern(lnum, pat)
+ let def = prevnonblank(a:lnum - 1)
+ while def > 0 && getline(def) =~ a:pat
+ let def = prevnonblank(def - 1)
+ endwhile
+ return def
+endfunction
+
+" Indent for ';;' to match multiple 'let'
+function s:GetInd(lnum, pat, lim)
+ let llet = search(a:pat, 'bW')
+ let old = indent(a:lnum)
+ while llet > 0
+ let old = indent(llet)
+ let nb = s:SkipPattern(llet, '^\s*(\*.*\*)\s*$')
+ if getline(nb) =~ a:lim
+ return old
+ endif
+ let llet = search(a:pat, 'bW')
+ endwhile
+ return old
+endfunction
+
+" Indent pairs
+function s:FindPair(pstart, pmid, pend)
+ call search(a:pend, 'bW')
+ return indent(searchpair(a:pstart, a:pmid, a:pend, 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment"'))
+endfunction
+
+" Indent 'let'
+function s:FindLet(pstart, pmid, pend)
+ call search(a:pend, 'bW')
+ return indent(searchpair(a:pstart, a:pmid, a:pend, 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment" || getline(".") =~ "^\\s*let\\>.*=.*\\<in\\s*$" || getline(prevnonblank(".") - 1) =~ "^\\s*let\\>.*=\\s*$\\|" . s:beflet'))
+endfunction
+
+function GetOCamlIndent()
+ " Find a non-blank line above the current line.
+ let lnum = prevnonblank(v:lnum - 1)
+
+ " At the start of the file use zero indent.
+ if lnum == 0
+ return 0
+ endif
+
+ let ind = indent(lnum)
+ let lline = getline(lnum)
+
+ " Return double 'shiftwidth' after lines matching:
+ if lline =~ '^\s*|.*->\s*$'
+ return ind + &sw + &sw
+ endif
+
+ let line = getline(v:lnum)
+
+ " Indent if current line begins with 'end'
+ " for 'sig', 'struct', 'object' and 'begin':
+ if line =~ '^\s*end\>'
+ return s:FindPair(s:module, '','\<end\>')
+
+ " Indent if current line begins with 'done' for 'do':
+ elseif line =~ '^\s*done\>'
+ return s:FindPair('\<do\>', '','\<done\>')
+
+ " Indent if current line begins with '}' or '>}':
+ elseif line =~ '^\s*\(\|>\)}'
+ return s:FindPair('{', '','}')
+
+ " Indent if current line begins with ']', '|]' or '>]':
+ elseif line =~ '^\s*\(\||\|>\)\]'
+ return s:FindPair('\[', '','\]')
+
+ " Indent if current line begins with ')':
+ elseif line =~ '^\s*)'
+ return s:FindPair('(', '',')')
+
+ " Indent if current line begins with 'let'
+ " and last line does not begin with 'let' or end with 'in' or ';;':
+ elseif line =~ '^\s*let\>'
+ if lline !~ s:lim . '\|' . s:letlim . '\|' . s:beflet
+ return s:FindLet(s:type, '','\<let\s*$')
+ else return ind
+ endif
+
+ " Indent if current line begins with 'type'
+ " and last line does not end with 'and' or ';;':
+ elseif line =~ '^\s*type\>'
+ if lline !~ s:lim . '\|\<and\s*$\|' . s:letlim
+ return s:FindLet(s:type, '','\<type\s*$')
+ else return ind
+ endif
+
+ " Indent for pattern matching:
+ elseif line =~ '^\s*|'
+ if lline !~ '^\s*\(|\|\(match\|with\|type\)\>\)\|\<\(function\|parser\|with\)\s*$'
+ call search('|', 'bW')
+ return indent(searchpair('^\s*\(type\|match\)\>\|\<\(with\|function\|parser\)\s*$', '', '|', 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment" || getline(".") =~ "\\[|\\||\\]" && getline(".") !~ "^\\s*|.*->"'))
+ else return ind
+ endif
+
+ " Indent if current line begins with ';;':
+ elseif line =~ '^\s*;;'
+ if lline !~ ';;\s*$'
+ return s:GetInd(v:lnum, s:letpat, s:letlim)
+ else return ind
+ endif
+
+ " Indent if current line begins with 'in' and previous
+ " line does not start with 'let' or 'and':
+ elseif line =~ '^\s*in\>'
+ if lline !~ '^\s*\(let\|and\)\>'
+ return s:FindPair('\<let\>', '', '\<in\>')
+ else return ind
+ endif
+
+ " Indent if current line begins with 'else'
+ " and previous line does not start with 'if', 'then' or 'else':
+ elseif line =~ '^\s*else\>'
+ if lline !~ '^\s*\(if\|else\|then\)\>'
+ return s:FindPair('\<if\>', '', '\<else\>')
+ else return ind
+ endif
+
+ " Indent if current line begins with 'then'
+ " and previous line does not start with 'if', 'then' or 'else':
+ elseif line =~ '^\s*then\>'
+ if lline !~ '^\s*\(if\|else\|then\)\>'
+ return s:FindPair('\<if\>', '', '\<then\>')
+ else return ind
+ endif
+
+ " Subtract a 'shiftwidth' if current line begins with 'and' and previous
+ " line does not start with 'let', 'and' or 'type' or end with 'end'
+ " (for classes):
+ elseif line =~ '^\s*and\>'
+ if lline !~ '^\s*\(and\|let\|type\)\>\|\<end\s*$'
+ return ind - &sw
+ else return ind
+ endif
+
+ " Indent if current line begins with 'with'
+ " and previous line does not start with 'match' or 'try':
+ elseif line =~ '^\s*with\>'
+ if lline !~ '^\s*\(match\|try\)\>'
+ return s:FindPair('\<\%(match\|try\)\>', '','\<with\>')
+ else return ind
+ endif
+
+ " Indent if current line begins with 'exception':
+ elseif line =~ '^\s*exception\>'
+ if lline !~ s:lim . '\|' . s:letlim
+ return indent(search(s:val . '\|^\s*\(external\|include\|open\|type\)\>', 'bW'))
+ else return ind
+ endif
+
+ " Indent if current line begins with 'external':
+ elseif line =~ '^\s*external\>'
+ if lline !~ s:lim . '\|' . s:letlim
+ return indent(search(s:val . '\|^\s*\(exception\|include\|open\|type\)\>', 'bW'))
+ else return ind
+ endif
+
+ " Indent if current line begins with 'include':
+ elseif line =~ '^\s*include\>'
+ if lline !~ s:lim . '\|' . s:letlim
+ return indent(search(s:val . '\|^\s*\(exception\|external\|open\|type\)\>', 'bW'))
+ else return ind
+ endif
+
+ " Indent if current line begins with 'open':
+ elseif line =~ '^\s*open\>'
+ if lline !~ s:lim . '\|' . s:letlim
+ return indent(search(s:val . '\|^\s*\(exception\|external\|include\|type\)\>', 'bW'))
+ else return ind
+ endif
+
+ " Indent if current line begins with 'val':
+ elseif line =~ '^\s*val\>'
+ if lline !~ '^\s*\(exception\|external\|include\|open\)\>\|' . s:obj . '\|' . s:letlim
+ return indent(search(s:val . '\|^\s*\(exception\|include\|initializer\|method\|open\|type\)\>', 'bW'))
+ else return ind
+ endif
+
+ " Indent if current line begins with 'constraint':
+ elseif line =~ '^\s*constraint\>'
+ if lline !~ s:obj
+ return indent(search('^\s*\(inherit\|initializer\|method\|val\)\>', 'bW'))
+ else return ind
+ endif
+
+ " Indent if current line begins with 'inherit':
+ elseif line =~ '^\s*inherit\>'
+ if lline !~ s:obj
+ return indent(search('^\s*\(constraint\|initializer\|method\|val\)\>', 'bW'))
+ else return ind
+ endif
+
+ " Indent if current line begins with 'inherit':
+ elseif line =~ '^\s*initializer\>'
+ if lline !~ s:obj
+ return indent(search('^\s*\(constraint\|inherit\|method\|val\)\>', 'bW'))
+ else return ind
+ endif
+
+ " Indent if current line begins with 'method':
+ elseif line =~ '^\s*method\>'
+ if lline !~ s:obj
+ return indent(search('^\s*\(\(constraint\|inherit\|initializer\|val\)\>\|method\>.*\(:\|=\)\)', 'bW'))
+ else return ind
+ endif
+
+ " Indent back to normal after comments:
+ elseif line =~ '^\s*\*)'
+ call search('\*)', 'bW')
+ return indent(searchpair('(\*', '', '\*)', 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"'))
+
+ endif
+
+ " Add a 'shiftwidth' after lines ending with:
+ if lline =~ '\(:\|=\|->\|<-\|(\|\[\|{\|{<\|\[|\|\[<\|\<\(begin\|struct\|sig\|functor\|initializer\|object\|try\|do\|if\|then\|else\|fun\|function\|parser\)\|\<object\s*(.*)\)\s*$'
+ let ind = ind + &sw
+
+ " Back to normal indent after lines ending with ';;':
+ elseif lline =~ ';;\s*$' && lline !~ '^\s*;;'
+ let ind = s:GetInd(v:lnum, s:letpat, s:letlim)
+
+ " Back to normal indent after lines ending with 'end':
+ elseif lline =~ '\<end\s*$'
+ let ind = s:FindPair(s:module, '','\<end\>')
+
+ " Back to normal indent after lines ending with 'in':
+ elseif lline =~ '\<in\s*$' && lline !~ '^\s*in\>'
+ let ind = s:FindPair('\<let\>', '', '\<in\>')
+
+ " Back to normal indent after lines ending with 'done':
+ elseif lline =~ '\<done\s*$'
+ let ind = s:FindPair('\<do\>', '','\<done\>')
+
+ " Back to normal indent after lines ending with '}' or '>}':
+ elseif lline =~ '\(\|>\)}\s*$'
+ let ind = s:FindPair('{', '','}')
+
+ " Back to normal indent after lines ending with ']', '|]' or '>]':
+ elseif lline =~ '\(\||\|>\)\]\s*$'
+ let ind = s:FindPair('\[', '','\]')
+
+ " Back to normal indent after comments:
+ elseif lline =~ '\*)\s*$'
+ call search('\*)', 'bW')
+ let ind = indent(searchpair('(\*', '', '\*)', 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"'))
+
+ " Back to normal indent after lines ending with ')':
+ elseif lline =~ ')\s*$'
+ let ind = s:FindPair('(', '',')')
+
+ endif
+
+ " Subtract a 'shiftwidth' after lines matching 'match ... with parser':
+ if lline =~ '^\s*match\>.*\<with\>\s*\<parser\s*$'
+ let ind = ind - &sw
+ endif
+
+ return ind
+
+endfunction
+
+" vim:sw=2
diff --git a/runtime/indent/occam.vim b/runtime/indent/occam.vim
new file mode 100644
index 000000000..ba978e006
--- /dev/null
+++ b/runtime/indent/occam.vim
@@ -0,0 +1,182 @@
+" Vim indent file
+" Language: occam
+" Maintainer: Mario Schweigler <ms44@kent.ac.uk>
+" Last Change: 23 April 2003
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+"{{{ Settings
+" Set the occam indent function
+setlocal indentexpr=GetOccamIndent()
+" Indent after new line and after initial colon
+setlocal indentkeys=o,O,0=:
+"}}}
+
+" Only define the function once
+if exists("*GetOccamIndent")
+ finish
+endif
+
+"{{{ Indent definitions
+" Define carriage return indent
+let s:FirstLevelIndent = '^\C\s*\(IF\|ALT\|PRI\s\+ALT\|PAR\|SEQ\|PRI\s\+PAR\|WHILE\|VALOF\|CLAIM\|FORKING\)\>\|\(--.*\)\@<!\(\<PROC\>\|??\|\<CASE\>\s*\(--.*\)\=\_$\)'
+let s:FirstLevelNonColonEndIndent = '^\C\s*PROTOCOL\>\|\(--.*\)\@<!\<\(\(CHAN\|DATA\)\s\+TYPE\|FUNCTION\)\>'
+let s:SecondLevelIndent = '^\C\s*\(IF\|ALT\|PRI\s\+ALT\)\>\|\(--.*\)\@<!?\s*\<CASE\>\s*\(--.*\)\=\_$'
+let s:SecondLevelNonColonEndIndent = '\(--.*\)\@<!\<\(CHAN\|DATA\)\s\+TYPE\>'
+
+" Define colon indent
+let s:ColonIndent = '\(--.*\)\@<!\<PROC\>'
+let s:ColonNonColonEndIndent = '^\C\s*PROTOCOL\>\|\(--.*\)\@<!\<\(\(CHAN\|DATA\)\s\+TYPE\|FUNCTION\)\>'
+
+let s:ColonEnd = '\(--.*\)\@<!:\s*\(--.*\)\=$'
+let s:ColonStart = '^\s*:\s*\(--.*\)\=$'
+
+" Define comment
+let s:CommentLine = '^\s*--'
+"}}}
+
+"{{{ function GetOccamIndent()
+" Auxiliary function to get the correct indent for a line of occam code
+function GetOccamIndent()
+
+ " Ensure magic is on
+ let save_magic = &magic
+ setlocal magic
+
+ " Get reference line number
+ let linenum = prevnonblank(v:lnum - 1)
+ while linenum > 0 && getline(linenum) =~ s:CommentLine
+ let linenum = prevnonblank(linenum - 1)
+ endwhile
+
+ " Get current indent
+ let curindent = indent(linenum)
+
+ " Get current line
+ let line = getline(linenum)
+
+ " Get previous line number
+ let prevlinenum = prevnonblank(linenum - 1)
+ while prevlinenum > 0 && getline(prevlinenum) =~ s:CommentLine
+ let prevlinenum = prevnonblank(prevlinenum - 1)
+ endwhile
+
+ " Get previous line
+ let prevline = getline(prevlinenum)
+
+ " Colon indent
+ if getline(v:lnum) =~ s:ColonStart
+
+ let found = 0
+
+ while found < 1
+
+ if line =~ s:ColonStart
+ let found = found - 1
+ elseif line =~ s:ColonIndent || (line =~ s:ColonNonColonEndIndent && line !~ s:ColonEnd)
+ let found = found + 1
+ endif
+
+ if found < 1
+ let linenum = prevnonblank(linenum - 1)
+ if linenum > 0
+ let line = getline(linenum)
+ else
+ let found = 1
+ endif
+ endif
+
+ endwhile
+
+ if linenum > 0
+ let curindent = indent(linenum)
+ else
+ let colonline = getline(v:lnum)
+ let tabstr = ''
+ while strlen(tabstr) < &tabstop
+ let tabstr = ' ' . tabstr
+ endwhile
+ let colonline = substitute(colonline, '\t', tabstr, 'g')
+ let curindent = match(colonline, ':')
+ endif
+
+ " Restore magic
+ if !save_magic|setlocal nomagic|endif
+
+ return curindent
+ endif
+
+ if getline(v:lnum) =~ '^\s*:'
+ let colonline = getline(v:lnum)
+ let tabstr = ''
+ while strlen(tabstr) < &tabstop
+ let tabstr = ' ' . tabstr
+ endwhile
+ let colonline = substitute(colonline, '\t', tabstr, 'g')
+ let curindent = match(colonline, ':')
+
+ " Restore magic
+ if !save_magic|setlocal nomagic|endif
+
+ return curindent
+ endif
+
+ " Carriage return indenat
+ if line =~ s:FirstLevelIndent || (line =~ s:FirstLevelNonColonEndIndent && line !~ s:ColonEnd)
+ \ || (line !~ s:ColonStart && (prevline =~ s:SecondLevelIndent
+ \ || (prevline =~ s:SecondLevelNonColonEndIndent && prevline !~ s:ColonEnd)))
+ let curindent = curindent + &shiftwidth
+
+ " Restore magic
+ if !save_magic|setlocal nomagic|endif
+
+ return curindent
+ endif
+
+ " Commented line
+ if getline(prevnonblank(v:lnum - 1)) =~ s:CommentLine
+
+ " Restore magic
+ if !save_magic|setlocal nomagic|endif
+
+ return indent(prevnonblank(v:lnum - 1))
+ endif
+
+ " Look for previous second level IF / ALT / PRI ALT
+ let found = 0
+
+ while !found
+
+ if indent(prevlinenum) == curindent - &shiftwidth
+ let found = 1
+ endif
+
+ if !found
+ let prevlinenum = prevnonblank(prevlinenum - 1)
+ while prevlinenum > 0 && getline(prevlinenum) =~ s:CommentLine
+ let prevlinenum = prevnonblank(prevlinenum - 1)
+ endwhile
+ if prevlinenum == 0
+ let found = 1
+ endif
+ endif
+
+ endwhile
+
+ if prevlinenum > 0
+ if getline(prevlinenum) =~ s:SecondLevelIndent
+ let curindent = curindent + &shiftwidth
+ endif
+ endif
+
+ " Restore magic
+ if !save_magic|setlocal nomagic|endif
+
+ return curindent
+
+endfunction
+"}}}
diff --git a/runtime/indent/perl.vim b/runtime/indent/perl.vim
new file mode 100644
index 000000000..1af058043
--- /dev/null
+++ b/runtime/indent/perl.vim
@@ -0,0 +1,180 @@
+" Vim indent file
+" Language: Perl
+" Author: Rafael Garcia-Suarez <rgarciasuarez@free.fr>
+" URL: http://rgarciasuarez.free.fr/vim/indent/perl.vim
+" Last Change: 2003 Apr 25
+
+" Suggestions and improvements by :
+" Aaron J. Sherman (use syntax for hints)
+" Artem Chuprina (play nice with folding)
+
+" TODO things that are not or not properly indented (yet) :
+" - Continued statements
+" print "foo",
+" "bar";
+" print "foo"
+" if bar();
+" - Multiline regular expressions (m//x)
+" (The following probably needs modifying the perl syntax file)
+" - qw() lists
+" - Heredocs with terminators that don't match \I\i*
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+" Is syntax highlighting active ?
+let b:indent_use_syntax = has("syntax") && &syntax == "perl"
+
+let s:cpo_save = &cpo
+set cpo-=C
+
+setlocal indentexpr=GetPerlIndent()
+setlocal indentkeys+=0=,0),0=or,0=and
+if !b:indent_use_syntax
+ setlocal indentkeys+=0=EO
+endif
+
+" Only define the function once.
+if exists("*GetPerlIndent")
+ finish
+endif
+
+function GetPerlIndent()
+
+ " Get the line to be indented
+ let cline = getline(v:lnum)
+
+ " Indent POD markers to column 0
+ if cline =~ '^\s*=\L\@!'
+ return 0
+ endif
+
+ " Don't reindent coments on first column
+ if cline =~ '^#.'
+ return 0
+ endif
+
+ " Get current syntax item at the line's first char
+ let csynid = ''
+ if b:indent_use_syntax
+ let csynid = synIDattr(synID(v:lnum,1,0),"name")
+ endif
+
+ " Don't reindent POD and heredocs
+ if csynid == "perlPOD" || csynid == "perlHereDoc" || csynid =~ "^pod"
+ return indent(v:lnum)
+ endif
+
+ " Indent end-of-heredocs markers to column 0
+ if b:indent_use_syntax
+ " Assumes that an end-of-heredoc marker matches \I\i* to avoid
+ " confusion with other types of strings
+ if csynid == "perlStringStartEnd" && cline =~ '^\I\i*$'
+ return 0
+ endif
+ else
+ " Without syntax hints, assume that end-of-heredocs markers begin with EO
+ if cline =~ '^\s*EO'
+ return 0
+ endif
+ endif
+
+ " Now get the indent of the previous perl line.
+
+ " Find a non-blank line above the current line.
+ let lnum = prevnonblank(v:lnum - 1)
+ " Hit the start of the file, use zero indent.
+ if lnum == 0
+ return 0
+ endif
+ let line = getline(lnum)
+ let ind = indent(lnum)
+ " Skip heredocs, POD, and comments on 1st column
+ if b:indent_use_syntax
+ let skippin = 2
+ while skippin
+ let synid = synIDattr(synID(lnum,1,0),"name")
+ if (synid == "perlStringStartEnd" && line =~ '^\I\i*$')
+ \ || (skippin != 2 && synid == "perlPOD")
+ \ || (skippin != 2 && synid == "perlHereDoc")
+ \ || synid == "perlComment"
+ \ || synid =~ "^pod"
+ let lnum = prevnonblank(lnum - 1)
+ if lnum == 0
+ return 0
+ endif
+ let line = getline(lnum)
+ let ind = indent(lnum)
+ let skippin = 1
+ else
+ let skippin = 0
+ endif
+ endwhile
+ else
+ if line =~ "^EO"
+ let lnum = search("<<[\"']\\=EO", "bW")
+ let line = getline(lnum)
+ let ind = indent(lnum)
+ endif
+ endif
+
+ " Indent blocks enclosed by {} or ()
+ if b:indent_use_syntax
+ " Find a real opening brace
+ let bracepos = match(line, '[(){}]', matchend(line, '^\s*[)}]'))
+ while bracepos != -1
+ let synid = synIDattr(synID(lnum, bracepos + 1, 0), "name")
+ " If the brace is highlighted in one of those groups, indent it.
+ " 'perlHereDoc' is here only to handle the case '&foo(<<EOF)'.
+ if synid == ""
+ \ || synid == "perlMatchStartEnd"
+ \ || synid == "perlHereDoc"
+ \ || synid =~ "^perlFiledescStatement"
+ \ || synid =~ '^perl\(Sub\|BEGINEND\|If\)Fold'
+ let brace = strpart(line, bracepos, 1)
+ if brace == '(' || brace == '{'
+ let ind = ind + &sw
+ else
+ let ind = ind - &sw
+ endif
+ endif
+ let bracepos = match(line, '[(){}]', bracepos + 1)
+ endwhile
+ let bracepos = matchend(cline, '^\s*[)}]')
+ if bracepos != -1
+ let synid = synIDattr(synID(v:lnum, bracepos, 0), "name")
+ if synid == ""
+ \ || synid == "perlMatchStartEnd"
+ \ || synid =~ '^perl\(Sub\|BEGINEND\|If\)Fold'
+ let ind = ind - &sw
+ endif
+ endif
+ else
+ if line =~ '[{(]\s*\(#[^)}]*\)\=$'
+ let ind = ind + &sw
+ endif
+ if cline =~ '^\s*[)}]'
+ let ind = ind - &sw
+ endif
+ endif
+
+ " Indent lines that begin with 'or' or 'and'
+ if cline =~ '^\s*\(or\|and\)\>'
+ if line !~ '^\s*\(or\|and\)\>'
+ let ind = ind + &sw
+ endif
+ elseif line =~ '^\s*\(or\|and\)\>'
+ let ind = ind - &sw
+ endif
+
+ return ind
+
+endfunction
+
+let &cpo = s:cpo_save
+unlet s:cpo_save
+
+" vim:ts=8:sts=2:sw=2
diff --git a/runtime/indent/php.vim b/runtime/indent/php.vim
new file mode 100644
index 000000000..208df3ab0
--- /dev/null
+++ b/runtime/indent/php.vim
@@ -0,0 +1,118 @@
+" Vim indent file
+" Language: PHP
+" Author: Miles Lott <milos@groupwhere.org>
+" URL: http://milosch.dyndns.org/php.vim
+" Last Change: 2004 May 18
+" Version: 0.5
+" Notes: Close all switches with default:\nbreak; and it will look better.
+" Also, open and close brackets should be alone on a line.
+" This is my preference, and the only way this will look nice.
+" Try an older version if you care less about the formatting of
+" switch/case. It is nearly perfect for anyone regardless of your
+" stance on brackets.
+"
+" Changes: 0.5 - fix duplicate indent on open tag, and empty bracketed
+" statements.
+" 0.4 - Fixes for closing php tag, switch statement closure, and php_indent_shortopentags
+" option from Steffen Bruentjen <vim@kontraphon.de>
+"
+" Options: php_noindent_switch=1 -- do not try to indent switch/case statements (version 0.1 behavior)
+" php_indent_shortopentags=1 -- indent after short php open tags, too
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal indentexpr=GetPhpIndent()
+"setlocal indentkeys+=0=,0),=EO
+setlocal indentkeys+=0=,0),=EO,=>
+
+" Only define the function once.
+if exists("*GetPhpIndent")
+ finish
+endif
+
+" Handle option(s)
+if exists("php_noindent_switch")
+ let b:php_noindent_switch=1
+endif
+
+function GetPhpIndent()
+ " Find a non-blank line above the current line.
+ let lnum = prevnonblank(v:lnum - 1)
+ " Hit the start of the file, use zero indent.
+ if lnum == 0
+ return 0
+ endif
+ let line = getline(lnum) " last line
+ let cline = getline(v:lnum) " current line
+ let pline = getline(lnum - 1) " previous to last line
+ let ind = indent(lnum)
+
+ " Indent after php open tag
+ if line =~ '<?php'
+ let ind = ind + &sw
+ elseif exists('g:php_indent_shortopentags')
+ " indent after short open tag
+ if line =~ '<?'
+ let ind = ind + &sw
+ endif
+ endif
+ " indent after php closing tag
+ if cline =~ '\M?>'
+ let ind = ind - &sw
+ endif
+
+ if exists("b:php_noindent_switch") " version 1 behavior, diy switch/case,etc
+ " Indent blocks enclosed by {} or ()
+ if line =~ '[{(]\s*\(#[^)}]*\)\=$'
+ let ind = ind + &sw
+ endif
+ if cline =~ '^\s*[)}]'
+ let ind = ind - &sw
+ endif
+ return ind
+ else
+ " Search the matching bracket (with searchpair()) and set the indent of
+ " to the indent of the matching line.
+ if cline =~ '^\s*}'
+ call cursor(line('.'), 1)
+ let ind = indent(searchpair('{', '', '}',
+ 'bW', 'synIDattr(synID(line("."), col("."),
+ 0), "name") =~? "string"'))
+ return ind
+ endif
+ " Try to indent switch/case statements as well
+ " Indent blocks enclosed by {} or () or case statements, with some anal requirements
+ if line =~ 'case.*:\|[{(]\s*\(#[^)}]*\)\=$'
+ let ind = ind + &sw
+ " return if the current line is not another case statement of the previous line is a bracket open
+ if cline !~ '.*case.*:\|default:' || line =~ '[{(]\s*\(#[^)}]*\)\=$'
+ return ind
+ endif
+ endif
+ if cline =~ '^\s*case.*:\|^\s*default:\|^\s*[)}]'
+ let ind = ind - &sw
+ " if the last line is a break or return, or the current line is a close bracket,
+ " or if the previous line is a default statement, subtract another
+ if line =~ '^\s*break;\|^\s*return\|' && cline =~ '^\s*[)}]' && pline =~ 'default:'
+ let ind = ind - &sw
+ endif
+ endif
+ " Search the matching bracket (with searchpair()) and set the indent of cline
+ " to the indent of the matching line.
+ if cline =~ '^\s*}'
+ call cursor(line('. '), 1)
+ let ind = indent(searchpair('{', '', '}', 'bW', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"'))
+ return ind
+ endif
+
+ if line =~ 'default:'
+ let ind = ind + &sw
+ endif
+ return ind
+ endif
+endfunction
+" vim: set ts=4 sw=4:
diff --git a/runtime/indent/postscr.vim b/runtime/indent/postscr.vim
new file mode 100644
index 000000000..b0ff48e68
--- /dev/null
+++ b/runtime/indent/postscr.vim
@@ -0,0 +1,68 @@
+" PostScript indent file
+" Language: PostScript
+" Maintainer: Mike Williams <mrw@netcomuk.co.uk>
+" Last Change: 2nd July 2001
+"
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal indentexpr=PostscrIndentGet(v:lnum)
+setlocal indentkeys+=0],0=>>,0=%%,0=end,0=restore,0=grestore indentkeys-=:,0#,e
+
+" Catch multiple instantiations
+if exists("*PostscrIndentGet")
+ finish
+endif
+
+function! PostscrIndentGet(lnum)
+ " Find a non-empty non-comment line above the current line.
+ " Note: ignores DSC comments as well!
+ let lnum = a:lnum - 1
+ while lnum != 0
+ let lnum = prevnonblank(lnum)
+ if getline(lnum) !~ '^\s*%.*$'
+ break
+ endif
+ let lnum = lnum - 1
+ endwhile
+
+ " Hit the start of the file, use user indent.
+ if lnum == 0
+ return -1
+ endif
+
+ " Start with the indent of the previous line
+ let ind = indent(lnum)
+ let pline = getline(lnum)
+
+ " Indent for dicts, arrays, and saves with possible trailing comment
+ if pline =~ '\(begin\|<<\|g\=save\|{\|[\)\s*\(%.*\)\=$'
+ let ind = ind + &sw
+ endif
+
+ " Remove indent for popped dicts, and restores.
+ if pline =~ '\(end\|g\=restore\)\s*$'
+ let ind = ind - &sw
+
+ " Else handle immediate dedents of dicts, restores, and arrays.
+ elseif getline(a:lnum) =~ '\(end\|>>\|g\=restore\|}\|]\)'
+ let ind = ind - &sw
+
+ " Else handle DSC comments - always start of line.
+ elseif getline(a:lnum) =~ '^\s*%%'
+ let ind = 0
+ endif
+
+ " For now catch excessive left indents if they occur.
+ if ind < 0
+ let ind = -1
+ endif
+
+ return ind
+endfunction
+
+" vim:sw=2
diff --git a/runtime/indent/pov.vim b/runtime/indent/pov.vim
new file mode 100644
index 000000000..2b197635a
--- /dev/null
+++ b/runtime/indent/pov.vim
@@ -0,0 +1,84 @@
+" Vim indent file
+" Language: PoV-Ray Scene Description Language
+" Maintainer: David Necas (Yeti) <yeti@physics.muni.cz>
+" Last Change: 2002-10-20
+" URI: http://trific.ath.cx/Ftp/vim/indent/pov.vim
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+" Some preliminary settings.
+setlocal nolisp " Make sure lisp indenting doesn't supersede us.
+
+setlocal indentexpr=GetPoVRayIndent()
+setlocal indentkeys+==else,=end,0]
+
+" Only define the function once.
+if exists("*GetPoVRayIndent")
+ finish
+endif
+
+" Counts matches of a regexp <rexp> in line number <line>.
+" Doesn't count matches inside strings and comments (as defined by current
+" syntax).
+function! s:MatchCount(line, rexp)
+ let str = getline(a:line)
+ let i = 0
+ let n = 0
+ while i >= 0
+ let i = matchend(str, a:rexp, i)
+ if i >= 0 && synIDattr(synID(a:line, i, 0), "name") !~? "string\|comment"
+ let n = n + 1
+ endif
+ endwhile
+ return n
+endfunction
+
+" The main function. Returns indent amount.
+function GetPoVRayIndent()
+ " If we are inside a comment (may be nested in obscure ways), give up
+ if synIDattr(synID(v:lnum, indent(v:lnum)+1, 0), "name") =~? "string\|comment"
+ return -1
+ endif
+
+ " Search backwards for the frist non-empty, non-comment line.
+ let plnum = prevnonblank(v:lnum - 1)
+ let plind = indent(plnum)
+ while plnum > 0 && synIDattr(synID(plnum, plind+1, 0), "name") =~? "comment"
+ let plnum = prevnonblank(plnum - 1)
+ let plind = indent(plnum)
+ endwhile
+
+ " Start indenting from zero
+ if plnum == 0
+ return 0
+ endif
+
+ " Analyse previous nonempty line.
+ let chg = 0
+ let chg = chg + s:MatchCount(plnum, '[[{(]')
+ let chg = chg + s:MatchCount(plnum, '#\s*\%(if\|ifdef\|ifndef\|switch\|while\|macro\|else\)\>')
+ let chg = chg - s:MatchCount(plnum, '#\s*end\>')
+ let chg = chg - s:MatchCount(plnum, '[]})]')
+ " Dirty hack for people writing #if and #else on the same line.
+ let chg = chg - s:MatchCount(plnum, '#\s*\%(if\|ifdef\|ifndef\|switch\)\>.*#\s*else\>')
+ " When chg > 0, then we opened groups and we should indent more, but when
+ " chg < 0, we closed groups and this already affected the previous line,
+ " so we should not dedent. And when everything else fails, scream.
+ let chg = chg > 0 ? chg : 0
+
+ " Analyse current line
+ " FIXME: If we have to dedent, we should try to find the indentation of the
+ " opening line.
+ let cur = s:MatchCount(v:lnum, '^\s*\%(#\s*\%(end\|else\)\>\|[]})]\)')
+ if cur > 0
+ let final = plind + (chg - cur) * &sw
+ else
+ let final = plind + chg * &sw
+ endif
+
+ return final < 0 ? 0 : final
+endfunction
diff --git a/runtime/indent/prolog.vim b/runtime/indent/prolog.vim
new file mode 100644
index 000000000..afe448e8f
--- /dev/null
+++ b/runtime/indent/prolog.vim
@@ -0,0 +1,58 @@
+" vim: set sw=4 sts=4:
+" Maintainer : Gergely Kontra <kgergely@mcl.hu>
+" Revised on : 2002.02.18. 23:34:05
+" Language : Prolog
+
+" TODO:
+" checking with respect to syntax highlighting
+" ignoring multiline comments
+" detecting multiline strings
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+
+let b:did_indent = 1
+
+setlocal indentexpr=GetPrologIndent()
+setlocal indentkeys-=:,0#
+setlocal indentkeys+=0%,-,0;,>,0)
+
+" Only define the function once.
+"if exists("*GetPrologIndent")
+" finish
+"endif
+
+function! GetPrologIndent()
+ " Find a non-blank line above the current line.
+ let pnum = prevnonblank(v:lnum - 1)
+ " Hit the start of the file, use zero indent.
+ if pnum == 0
+ return 0
+ endif
+ let line = getline(v:lnum)
+ let pline = getline(pnum)
+
+ let ind = indent(pnum)
+ " Previous line was comment -> use previous line's indent
+ if pline =~ '^\s*%'
+ retu ind
+ endif
+ " Check for clause head on previous line
+ if pline =~ ':-\s*\(%.*\)\?$'
+ let ind = ind + &sw
+ " Check for end of clause on previous line
+ elseif pline =~ '\.\s*\(%.*\)\?$'
+ let ind = ind - &sw
+ endif
+ " Check for opening conditional on previous line
+ if pline =~ '^\s*\([(;]\|->\)'
+ let ind = ind + &sw
+ endif
+ " Check for closing an unclosed paren, or middle ; or ->
+ if line =~ '^\s*\([);]\|->\)'
+ let ind = ind - &sw
+ endif
+ return ind
+endfunction
diff --git a/runtime/indent/pyrex.vim b/runtime/indent/pyrex.vim
new file mode 100644
index 000000000..e7771264e
--- /dev/null
+++ b/runtime/indent/pyrex.vim
@@ -0,0 +1,8 @@
+" Vim indent file
+" Language: Pyrex
+" Maintainer: Marco Barisione <marco.bari@people.it>
+" URL: http://marcobari.altervista.org/pyrex_vim.html
+" Last Change: 2004 May 16
+
+" Use Python formatting rules
+runtime! indent/python.vim
diff --git a/runtime/indent/python.vim b/runtime/indent/python.vim
new file mode 100644
index 000000000..3dbbe10a6
--- /dev/null
+++ b/runtime/indent/python.vim
@@ -0,0 +1,175 @@
+" Vim indent file
+" Language: Python
+" Maintainer: Bram Moolenaar <Bram@vim.org>
+" Original Author: David Bustos <bustos@caltech.edu>
+" Last Change: 2003 Sep 08
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+" Some preliminary settings
+setlocal nolisp " Make sure lisp indenting doesn't supersede us
+setlocal autoindent " indentexpr isn't much help otherwise
+
+setlocal indentexpr=GetPythonIndent(v:lnum)
+setlocal indentkeys+=<:>,=elif,=except
+
+" Only define the function once.
+if exists("*GetPythonIndent")
+ finish
+endif
+
+let s:maxoff = 50 " maximum number of lines to look backwards for ()
+
+function GetPythonIndent(lnum)
+ " If this line is explicitly joined: If the previous line was also joined,
+ " line it up with that one, otherwise add two 'shiftwidth'
+ if getline(a:lnum - 1) =~ '\\$'
+ if a:lnum > 1 && getline(a:lnum - 2) =~ '\\$'
+ return indent(a:lnum - 1)
+ endif
+ return indent(a:lnum - 1) + (&sw * 2)
+ endif
+
+ " If the start of the line is in a string don't change the indent.
+ if has('syntax_items')
+ \ && synIDattr(synID(a:lnum, 1, 1), "name") == "pythonString"
+ return -1
+ endif
+
+ " Search backwards for the previous non-empty line.
+ let plnum = prevnonblank(v:lnum - 1)
+
+ if plnum == 0
+ " This is the first non-empty line, use zero indent.
+ return 0
+ endif
+
+ " If the previous line is inside parenthesis, use the indent of the starting
+ " line.
+ " Trick: use the non-existing "dummy" variable to break out of the loop when
+ " going too far back.
+ call cursor(plnum, 1)
+ let parlnum = searchpair('(', '', ')', 'nbW',
+ \ "line('.') < " . (plnum - s:maxoff) . " ? dummy :"
+ \ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
+ \ . " =~ 'python\\(Comment\\|String\\)'")
+ if parlnum > 0
+ let plindent = indent(parlnum)
+ let plnumstart = parlnum
+ else
+ let plindent = indent(plnum)
+ let plnumstart = plnum
+ endif
+
+
+ " When inside parenthesis: If at the first line below the parenthesis add
+ " two 'shiftwidth', otherwise same as previous line.
+ " i = (a
+ " + b
+ " + c)
+ call cursor(a:lnum, 1)
+ let p = searchpair('(', '', ')', 'bW',
+ \ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :"
+ \ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
+ \ . " =~ 'python\\(Comment\\|String\\)'")
+ if p > 0
+ if p == plnum
+ " When the start is inside parenthesis, only indent one 'shiftwidth'.
+ let pp = searchpair('(', '', ')', 'bW',
+ \ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :"
+ \ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
+ \ . " =~ 'python\\(Comment\\|String\\)'")
+ if pp > 0
+ return indent(plnum) + &sw
+ endif
+ return indent(plnum) + (&sw * 2)
+ endif
+ if plnumstart == p
+ return indent(plnum)
+ endif
+ return plindent
+ endif
+
+
+ " Get the line and remove a trailing comment.
+ " Use syntax highlighting attributes when possible.
+ let pline = getline(plnum)
+ let pline_len = strlen(pline)
+ let col = 0
+ while col < pline_len
+ if pline[col] == '#' && (!has('syntax_items')
+ \ || synIDattr(synID(plnum, col + 1, 1), "name") == "pythonComment")
+ let pline = strpart(pline, 0, col)
+ break
+ endif
+ let col = col + 1
+ endwhile
+
+ " If the previous line ended with a colon, indent this line
+ if pline =~ ':\s*$'
+ return plindent + &sw
+ endif
+
+ " If the previous line was a stop-execution statement...
+ if getline(plnum) =~ '^\s*\(break\|continue\|raise\|return\)\>'
+ " See if the user has already dedented
+ if indent(a:lnum) > indent(plnum) - &sw
+ " If not, recommend one dedent
+ return indent(plnum) - &sw
+ endif
+ " Otherwise, trust the user
+ return -1
+ endif
+
+ " If the current line begins with a keyword that lines up with "try"
+ if getline(a:lnum) =~ '^\s*\(except\|finally\)\>'
+ let lnum = a:lnum - 1
+ while lnum >= 1
+ echomsg 'got here'
+ if getline(lnum) =~ '^\s*\(try\|except\)\>'
+ let ind = indent(lnum)
+ echomsg 'got here, indent is ' . ind
+ if ind >= indent(a:lnum)
+ return -1 " indent is already less than this
+ endif
+ return ind " line up with previous try or except
+ endif
+ let lnum = lnum - 1
+ endwhile
+ echomsg 'got to the end'
+ return -1 " no matching "try"!
+ endif
+
+ " If the current line begins with a header keyword, dedent
+ if getline(a:lnum) =~ '^\s*\(elif\|else\)\>'
+
+ " Unless the previous line was a one-liner
+ if getline(plnumstart) =~ '^\s*\(for\|if\|try\)\>'
+ return plindent
+ endif
+
+ " Or the user has already dedented
+ if indent(a:lnum) <= plindent - &sw
+ return -1
+ endif
+
+ return plindent - &sw
+ endif
+
+ " When after a () construct we probably want to go back to the start line.
+ " a = (b
+ " + c)
+ " here
+ if parlnum > 0
+ return plindent
+ endif
+
+ return -1
+
+endfunction
+
+" vim:sw=2
diff --git a/runtime/indent/readline.vim b/runtime/indent/readline.vim
new file mode 100644
index 000000000..b2640f1f2
--- /dev/null
+++ b/runtime/indent/readline.vim
@@ -0,0 +1,48 @@
+" Vim indent file
+" Language: readline configuration file
+" Maintainer: Nikolai Weibull <source@pcppopper.org>
+" URL: http://www.pcppopper.org/vim/indent/pcp/readline/
+" Latest Revision: 2004-04-25
+" arch-tag: ee681235-3abf-4a42-8587-edabd409a980
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+
+let b:did_indent = 1
+
+setlocal indentexpr=GetReadlineIndent()
+setlocal indentkeys=!^F,o,O,=$else,=$endif
+
+" Only define the function once.
+if exists("*GetReadlineIndent")
+ finish
+endif
+
+function GetReadlineIndent()
+ let lnum = prevnonblank(v:lnum - 1)
+
+ if lnum == 0
+ return 0
+ endif
+
+ let line = getline(lnum)
+ let ind = indent(lnum)
+
+ " increase indent if previous line started with $if or $else
+ if line =~ '^\s*$\(if\|else\)\>'
+ let ind = ind + &sw
+ endif
+
+ let line = getline(v:lnum)
+
+ " decrease indent if this line starts with $else or $endif
+ if line =~ '^\s*$\(else\|endif\)\>'
+ let ind = ind - &sw
+ endif
+
+ return ind
+endfunction
+
+" vim: set sts=2 sw=2:
diff --git a/runtime/indent/rpl.vim b/runtime/indent/rpl.vim
new file mode 100644
index 000000000..341f5f950
--- /dev/null
+++ b/runtime/indent/rpl.vim
@@ -0,0 +1,60 @@
+" Vim indent file
+" Language: RPL/2
+" Version: 0.2
+" Last Change: 2002 August 16
+" Maintainer: BERTRAND Joël <rpl2@free.fr>
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal indentkeys+==~end,=~case,=~if,=~then,=~else,=~do,=~until,=~while,=~repeat,=~select,=~default,=~for,=~start,=~next,=~step,<<>,<>>
+
+" Define the appropriate indent function but only once
+setlocal indentexpr=RplGetFreeIndent()
+if exists("*RplGetFreeIndent")
+ finish
+endif
+
+function RplGetIndent(lnum)
+ let ind = indent(a:lnum)
+ let prevline=getline(a:lnum)
+ " Strip tail comment
+ let prevstat=substitute(prevline, '!.*$', '', '')
+
+ " Add a shiftwidth to statements following if, iferr, then, else, elseif,
+ " case, select, default, do, until, while, repeat, for, start
+ if prevstat =~? '\<\(if\|iferr\|do\|while\)\>' && prevstat =~? '\<end\>'
+ elseif prevstat =~? '\(^\|\s\+\)<<\($\|\s\+\)' && prevstat =~? '\s\+>>\($\|\s\+\)'
+ elseif prevstat =~? '\<\(if\|iferr\|then\|else\|elseif\|select\|case\|do\|until\|while\|repeat\|for\|start\|default\)\>' || prevstat =~? '\(^\|\s\+\)<<\($\|\s\+\)'
+ let ind = ind + &sw
+ endif
+
+ " Subtract a shiftwidth from then, else, elseif, end, until, repeat, next,
+ " step
+ let line = getline(v:lnum)
+ if line =~? '^\s*\(then\|else\|elseif\|until\|repeat\|next\|step\|default\|end\)\>'
+ let ind = ind - &sw
+ elseif line =~? '^\s*>>\($\|\s\+\)'
+ let ind = ind - &sw
+ endif
+
+ return ind
+endfunction
+
+function RplGetFreeIndent()
+ " Find the previous non-blank line
+ let lnum = prevnonblank(v:lnum - 1)
+
+ " Use zero indent at the top of the file
+ if lnum == 0
+ return 0
+ endif
+
+ let ind=RplGetIndent(lnum)
+ return ind
+endfunction
+
+" vim:sw=2 tw=130
diff --git a/runtime/indent/rst.vim b/runtime/indent/rst.vim
new file mode 100644
index 000000000..c6269ec6a
--- /dev/null
+++ b/runtime/indent/rst.vim
@@ -0,0 +1,60 @@
+" Vim indent file
+" Language: reStructuredText Documentation Format
+" Maintainer: Nikolai Weibull <source@pcppopper.org>
+" URL: http://www.pcppopper.org/vim/indent/pcp/rst/
+" Latest Revision: 2004-04-25
+" arch-tag: 3fe10f75-24d0-4d94-a924-0ce945958104
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+
+let b:did_indent = 1
+
+setlocal indentexpr=GetRSTIndent()
+setlocal indentkeys-=:,0# indentkeys-=e
+
+" Only define the function once.
+if exists("*GetRSTIndent")
+ finish
+endif
+
+function GetRSTIndent()
+ let lnum = prevnonblank(v:lnum - 1)
+
+ if lnum == 0
+ return 0
+ endif
+
+ let ind = indent(lnum)
+ let line = getline(lnum)
+
+ if line =~ '^\s*[-*+]\s'
+ let ind = ind + 2
+ elseif line =~ '^\s*\d\+.\s'
+ let ind = ind + matchend(substitute(line, '^\s*', '', ''), '\d\+.\s\+')
+ endif
+
+ let line = getline(v:lnum - 1)
+
+ if line =~ '^\s*$'
+ execute lnum
+ call search('^\s*\%([-*+]\s\|\d\+.\s\|\.\.\|$\)', 'bW')
+ let line = getline('.')
+ if line =~ '^\s*[-*+]'
+ let ind = ind - 2
+ elseif line =~ '^\s*\d\+\.\s'
+ let ind = ind - matchend(substitute(line, '^\s*', '', ''),
+ \ '\d\+\.\s\+')
+ elseif line =~ '^\s*\.\.'
+ let ind = ind - 3
+ else
+ let ind = ind
+ endif
+ endif
+
+ return ind
+endfunction
+
+" vim: set sts=2 sw=2:
diff --git a/runtime/indent/ruby.vim b/runtime/indent/ruby.vim
new file mode 100644
index 000000000..ce078f2a0
--- /dev/null
+++ b/runtime/indent/ruby.vim
@@ -0,0 +1,67 @@
+" Vim indent file
+" Language: Ruby
+" Maintainer: Gavin Sinclair <gsinclair@soyabean.com.au>
+" Last Change: 2003 May 11
+" URL: www.soyabean.com.au/gavin/vim/index.html
+" Changes: (since vim 6.1)
+" - indentation after a line ending in comma, etc, (even in a comment) was
+" broken, now fixed (2002/08/14)
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal indentexpr=GetRubyIndent()
+setlocal nolisp
+setlocal nosmartindent
+setlocal autoindent
+setlocal indentkeys+==end,=else,=elsif,=when,=ensure,=rescue
+
+" Only define the function once.
+if exists("*GetRubyIndent")
+ finish
+endif
+
+function GetRubyIndent()
+ " Find a non-blank line above the current line.
+ let lnum = prevnonblank(v:lnum - 1)
+
+ " At the start of the file use zero indent.
+ if lnum == 0
+ return 0
+ endif
+
+ " If the line trailed with [*+,.(] - but not in a comment - trust the user
+ if getline(lnum) =~ '\(\[^#\].*\)?\(\*\|\.\|+\|,\|(\)\(\s*#.*\)\=$'
+ return -1
+ endif
+
+ " Add a 'shiftwidth' after lines beginning with:
+ " module, class, dev, if, for, while, until, else, elsif, case, when, {
+ let ind = indent(lnum)
+ let flag = 0
+ if getline(lnum) =~ '^\s*\(module\>\|class\>\|def\>\|if\>\|for\>\|while\>\|until\>\|else\>\|elsif\>\|case\>\|when\>\|unless\|begin\|ensure\>\|rescue\>\)'
+ \ || getline(lnum) =~ '{\s*$'
+ \ || getline(lnum) =~ '\({\|\<do\>\).*|.*|\s*$'
+ \ || getline(lnum) =~ '\<do\>\(\s*#.*\)\=$'
+ let ind = ind + &sw
+ let flag = 1
+ endif
+
+ " Subtract a 'shiftwidth' after lines ending with
+ " "end" when they begin with while, if, for, until
+ if flag == 1 && getline(lnum) =~ '\<end\>\(\s*#.*\)\=$'
+ let ind = ind - &sw
+ endif
+
+ " Subtract a 'shiftwidth' on end, else and, elsif, when and }
+ if getline(v:lnum) =~ '^\s*\(end\>\|else\>\|elsif\>\|when\>\|ensure\>\|rescue\>\|}\)'
+ let ind = ind - &sw
+ endif
+
+ return ind
+endfunction
+
+" vim:sw=2
diff --git a/runtime/indent/sdl.vim b/runtime/indent/sdl.vim
new file mode 100644
index 000000000..9dde2c3f5
--- /dev/null
+++ b/runtime/indent/sdl.vim
@@ -0,0 +1,89 @@
+" Vim indent file
+" Language: SDL
+" Maintainer: Michael Piefel <piefel@informatik.hu-berlin.de>
+" Last Change: 2001 Sep 17
+
+" Shamelessly stolen from the Vim-Script indent file
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal indentexpr=GetSDLIndent()
+setlocal indentkeys+==~end,=~state,*<Return>
+
+" Only define the function once.
+if exists("*GetSDLIndent")
+" finish
+endif
+
+set cpo-=C
+
+function! GetSDLIndent()
+ " Find a non-blank line above the current line.
+ let lnum = prevnonblank(v:lnum - 1)
+
+ " At the start of the file use zero indent.
+ if lnum == 0
+ return 0
+ endif
+
+ let ind = indent(lnum)
+ let virtuality = '^\s*\(\(virtual\|redefined\|finalized\)\s\+\)\=\s*'
+
+ " Add a single space to comments which use asterisks
+ if getline(lnum) =~ '^\s*\*'
+ let ind = ind - 1
+ endif
+ if getline(v:lnum) =~ '^\s*\*'
+ let ind = ind + 1
+ endif
+
+ " Add a 'shiftwidth' after states, different blocks, decision (and alternatives), inputs
+ if (getline(lnum) =~? '^\s*\(start\|state\|system\|package\|connection\|channel\|alternative\|macro\|operator\|newtype\|select\|substructure\|decision\|generator\|refinement\|service\|method\|exceptionhandler\|asntype\|syntype\|value\|(.*):\|\(priority\s\+\)\=input\|provided\)'
+ \ || getline(lnum) =~? virtuality . '\(process\|procedure\|block\|object\)')
+ \ && getline(lnum) !~? 'end[[:alpha:]]\+;$'
+ let ind = ind + &sw
+ endif
+
+ " Subtract a 'shiftwidth' after states
+ if getline(lnum) =~? '^\s*\(stop\|return\>\|nextstate\)'
+ let ind = ind - &sw
+ endif
+
+ " Subtract a 'shiftwidth' on on end (uncompleted line)
+ if getline(v:lnum) =~? '^\s*end\>'
+ let ind = ind - &sw
+ endif
+
+ " Put each alternatives where the corresponding decision was
+ if getline(v:lnum) =~? '^\s*\((.*)\|else\):'
+ normal k
+ let ind = indent(searchpair('^\s*decision', '', '^\s*enddecision', 'bW',
+ \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "sdlString"'))
+ endif
+
+ " Put each state where the preceding state was
+ if getline(v:lnum) =~? '^\s*state\>'
+ let ind = indent(search('^\s*start', 'bW'))
+ endif
+
+ " Systems and packages are always in column 0
+ if getline(v:lnum) =~? '^\s*\(\(end\)\=system\|\(end\)\=package\)'
+ return 0;
+ endif
+
+ " Put each end* where the corresponding begin was
+ if getline(v:lnum) =~? '^\s*end[[:alpha:]]'
+ normal k
+ let partner=matchstr(getline(v:lnum), '\(' . virtuality . 'end\)\@<=[[:alpha:]]\+')
+ let ind = indent(searchpair(virtuality . partner, '', '^\s*end' . partner, 'bW',
+ \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "sdlString"'))
+ endif
+
+ return ind
+endfunction
+
+" vim:sw=2
diff --git a/runtime/indent/sh.vim b/runtime/indent/sh.vim
new file mode 100644
index 000000000..880ad12ce
--- /dev/null
+++ b/runtime/indent/sh.vim
@@ -0,0 +1,58 @@
+" Vim indent file
+" Language: Shell Script
+" Maintainer: Nikolai Weibull <source@pcppopper.org>
+" URL: http://www.pcppopper.org/vim/indent/pcp/sh/
+" Latest Revision: 2004-04-25
+" arch-tag: 431c7fc1-12a6-4d71-9636-1498ef56b038
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+
+let b:did_indent = 1
+
+setlocal indentexpr=GetShIndent()
+setlocal indentkeys+==then,=do,=else,=elif,=esac,=fi,=fin,=fil,=done
+setlocal indentkeys-=:,0#
+
+" Only define the function once.
+if exists("*GetShIndent")
+ finish
+endif
+
+set cpoptions-=C
+
+function GetShIndent()
+ " Find a non-blank line above the current line.
+ let lnum = prevnonblank(v:lnum - 1)
+
+ " Hit the start of the file, use zero indent.
+ if lnum == 0
+ return 0
+ endif
+
+ " Add a 'shiftwidth' after if, while, else, case, until, for, function()
+ " Skip if the line also contains the closure for the above
+ let ind = indent(lnum)
+ let line = getline(lnum)
+ if line =~ '^\s*\(if\|then\|do\|else\|elif\|case\|while\|until\|for\)\>'
+ \ || line =~ '^\s*\<\h\w*\>\s*()\s*{'
+ \ || line =~ '^\s*{'
+ if line !~ '\(esac\|fi\|done\)\>\s*$' && line !~ '}\s*$'
+ let ind = ind + &sw
+ endif
+ endif
+
+ " Subtract a 'shiftwidth' on a then, do, else, esac, fi, done
+ " Retain the indentation level if line matches fin (for find)
+ let line = getline(v:lnum)
+ if (line =~ '^\s*\(then\|do\|else\|elif\|esac\|fi\|done\)\>' || line =~ '^\s*}')
+ \ && line !~ '^\s*fi[ln]\>'
+ let ind = ind - &sw
+ endif
+
+ return ind
+endfunction
+
+" vim: set sts=2 sw=2:
diff --git a/runtime/indent/tcl.vim b/runtime/indent/tcl.vim
new file mode 100644
index 000000000..326575e8f
--- /dev/null
+++ b/runtime/indent/tcl.vim
@@ -0,0 +1,123 @@
+" Vim indent file
+" Language: Tcl
+" Maintainer: Nikolai Weibull <source@pcppopper.org>
+" URL: http://www.pcppopper.org/vim/indent/pcp/tcl/
+" Latest Revision: 2004-05-21
+" arch-tag: 64fab1fa-d670-40ab-a191-55678f20ceb0
+
+" only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+
+let b:did_indent = 1
+
+setlocal indentexpr=GetTclIndent()
+setlocal indentkeys-=:,0#
+setlocal indentkeys+=0]
+
+" only define the function once.
+if exists("*GetTclIndent")
+ finish
+endif
+
+function s:PrevNonBlankNonComment(lnum)
+ let lnum = prevnonblank(a:lnum)
+ while lnum > 0
+ let line = getline(lnum)
+ if line !~ '^\s*\(#\|$\)'
+ break
+ endif
+ let lnum = prevnonblank(lnum - 1)
+ endwhile
+ return lnum
+endfunction
+
+function! GetTclIndent()
+ let lnum = s:PrevNonBlankNonComment(v:lnum - 1)
+
+ if lnum == 0
+ return 0
+ endif
+
+ let line = getline(lnum)
+ let ind = indent(lnum)
+
+ " TODO: Possible improvement, check that 'begin' and 'end' aren't inside a
+ " comment or string. This will mess it up. As I am pressed for time and
+ " stuff like this is unlikely to happen I won't deal with it in this
+ " version.
+ let open = 0
+ let begin = match(line, '{', 0)
+ while begin > -1
+ let end = match(line, '}', begin + 1)
+ if end < 0
+ let open = open + 1
+ else
+ let tmp = match(line, '{', begin + 1)
+ if tmp != -1 && tmp < end
+ let open = open + 1
+ endif
+ endif
+ let begin = match(line, '{', begin + 1)
+ endwhile
+
+ let begin = match(line, '[', 0)
+ while begin > -1
+ let end = match(line, ']', begin + 1)
+ if end < 0
+ let open = open + 1
+ else
+ let tmp = match(line, '{', begin + 1)
+ if tmp != -1 && tmp < end
+ let open = open + 1
+ endif
+ endif
+ let begin = match(line, '{', begin + 1)
+ endwhile
+
+ let close = 0
+ let prev = 0
+ let end = matchend(line, '^\s*}.*}', prev)
+ while end > -1
+ let begin = match(line, '{', prev + 1)
+ if begin < 0 || begin > prev
+ let close = close + 1
+ endif
+ let prev = end
+ let end = match(line, '}', prev + 1)
+ endwhile
+
+ let prev = 0
+ let end = match(line, ']', prev)
+ while end > -1
+ let begin = match(line, '[', prev + 1)
+ if begin < 0 || begin > prev
+ let close = close + 1
+ endif
+ let prev = end
+ let end = match(line, ']', prev + 1)
+ endwhile
+
+ let ind = ind + (open - close) * &sw
+
+ let line = getline(v:lnum)
+
+ let close = 0
+ let prev = 0
+ let end = match(line, '}', prev)
+ while end > -1
+ let begin = match(line, '{', prev + 1)
+ if begin < 0 || begin > prev
+ let close = close + 1
+ endif
+ let prev = end
+ let end = match(line, '}', prev + 1)
+ endwhile
+
+ let ind = ind - close * &sw
+
+ return ind >= 0 ? ind : 0
+endfunction
+
+" vim: set sts=2 sw=2:
diff --git a/runtime/indent/tcsh.vim b/runtime/indent/tcsh.vim
new file mode 100644
index 000000000..89403c9c9
--- /dev/null
+++ b/runtime/indent/tcsh.vim
@@ -0,0 +1,51 @@
+" Vim indent file
+" Language: C-shell (tcsh)
+" Maintainor: Gautam Iyer <gautam@math.uchicago.edu>
+" Last Modified: Wed 04 Feb 2004 04:36:07 PM CST
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+
+let b:did_indent = 1
+
+setlocal indentexpr=TcshGetIndent()
+setlocal indentkeys+=e,0=end,0=endsw,*<return> indentkeys-=0{,0},0),:,0#
+
+" Only define the function once.
+if exists("*TcshGetIndent")
+ finish
+endif
+
+set cpoptions-=C
+
+function TcshGetIndent()
+ " Find a non-blank line above the current line.
+ let lnum = prevnonblank(v:lnum - 1)
+
+ " Hit the start of the file, use zero indent.
+ if lnum == 0
+ return 0
+ endif
+
+ " Add indent if previous line begins with while or foreach
+ " OR line ends with case <str>:, default:, else, then or \
+ 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
+ endif
+
+ if line =~ '\v^\s*breaksw>'
+ let ind = ind - &sw
+ 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
+ endif
+
+ return ind
+endfunction
diff --git a/runtime/indent/tilde.vim b/runtime/indent/tilde.vim
new file mode 100644
index 000000000..5fdcfe071
--- /dev/null
+++ b/runtime/indent/tilde.vim
@@ -0,0 +1,36 @@
+"Description: Indent scheme for the tilde weblanguage
+"Author: Tobias Rundström <tobi@tobi.nu>
+"URL: http://tilde.tildesoftware.net
+"Last Change: May 8 09:15:09 CEST 2002
+
+if exists ("b:did_indent")
+ finish
+endif
+
+let b:did_indent = 1
+
+setlocal autoindent
+setlocal indentexpr=GetTildeIndent(v:lnum)
+setlocal indentkeys=o,O,)
+
+if exists("*GetTildeIndent")
+ finish
+endif
+
+function GetTildeIndent(lnum)
+ let plnum = prevnonblank(v:lnum-1)
+
+ if plnum == 0
+ return 0
+ endif
+
+ if getline(v:lnum) =~ '^\s*\~\(endif\|else\|elseif\|end\)\>'
+ return indent(v:lnum) - &sw
+ endif
+
+ if getline(plnum) =~ '^\s*\~\(if\|foreach\|foreach_row\|xml_loop\|file_loop\|file_write\|file_append\|imap_loopsections\|imap_index\|imap_list\|ldap_search\|post_loopall\|post_loop\|file_loop\|sql_loop_num\|sql_dbmsselect\|search\|sql_loop\|post\|for\|function_define\|silent\|while\|setvalbig\|mail_create\|systempipe\|mail_send\|dual\|elseif\|else\)\>'
+ return indent(plnum) + &sw
+ else
+ return -1
+ endif
+endfunction
diff --git a/runtime/indent/vb.vim b/runtime/indent/vb.vim
new file mode 100644
index 000000000..515e4dc6b
--- /dev/null
+++ b/runtime/indent/vb.vim
@@ -0,0 +1,72 @@
+" Vim indent file
+" Language: VisualBasic (ft=vb) / Basic (ft=basic) / SaxBasic (ft=vb)
+" Author: Johannes Zellner <johannes@zellner.org>
+" Last Change: Tue, 27 Apr 2004 14:54:59 CEST
+
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal indentexpr=VbGetIndent(v:lnum)
+setlocal indentkeys&
+setlocal indentkeys+==~else,=~elseif,=~end,=~wend,=~case,=~next,=~select,~=loop,<:>
+
+" Only define the function once.
+if exists("*VbGetIndent")
+ finish
+endif
+
+fun! VbGetIndent(lnum)
+ " labels and preprocessor get zero indent immediately
+ let this_line = getline(a:lnum)
+ let LABELS_OR_PREPROC = '^\s*\(\<\k\+\>:\s*$\|#.*\)'
+ if this_line =~? LABELS_OR_PREPROC
+ return 0
+ endif
+
+ " Find a non-blank line above the current line.
+ " Skip over labels and preprocessor directives.
+ let lnum = a:lnum
+ while lnum > 0
+ let lnum = prevnonblank(lnum - 1)
+ let previous_line = getline(lnum)
+ if previous_line !~? LABELS_OR_PREPROC
+ break
+ endif
+ endwhile
+
+ " Hit the start of the file, use zero indent.
+ if lnum == 0
+ return 0
+ endif
+
+ let ind = indent(lnum)
+
+ " Add
+ if previous_line =~? '^\s*\<\(begin\|\%(\%(private\|public\|friend\)\s\+\)\=\%(function\|sub\|property\)\|select\|case\|default\|if\>.\{-}\<then\>\s*$\|else\|elseif\|do\|for\|while\|enum\|with\)\>'
+ let ind = ind + &sw
+ endif
+
+ " Subtract
+ if this_line =~? '^\s*\<end\>\s\+\<select\>'
+ if previous_line !~? '^\s*\<select\>'
+ let ind = ind - 2 * &sw
+ else
+ " this case is for an empty 'select' -- 'end select'
+ " (w/o any case statements) like:
+ "
+ " select case readwrite
+ " end select
+ let ind = ind - &sw
+ endif
+ elseif this_line =~? '^\s*\<\(end\|else\|until\|loop\|next\|wend\)\>'
+ let ind = ind - &sw
+ elseif this_line =~? '^\s*\<\(case\|default\)\>'
+ if previous_line !~? '^\s*\<select\>'
+ let ind = ind - &sw
+ endif
+ endif
+
+ return ind
+endfun
diff --git a/runtime/indent/verilog.vim b/runtime/indent/verilog.vim
new file mode 100644
index 000000000..74c8c5f6d
--- /dev/null
+++ b/runtime/indent/verilog.vim
@@ -0,0 +1,219 @@
+" Language: Verilog HDL
+" Maintainer: Chih-Tsun Huang <cthuang@larc.ee.nthu.edu.tw>
+" Last Change: Wed Oct 31 16:13:11 CST 2001
+" URL: http://larc.ee.nthu.edu.tw/~cthuang/vim/indent/verilog.vim
+"
+" Credits:
+" Suggestions for improvement, bug reports by
+" Leo Butlero <lbutler@brocade.com>
+"
+" Buffer Variables:
+" b:verilog_indent_modules : indenting after the declaration
+" of module blocks
+" b:verilog_indent_width : indenting width
+" b:verilog_indent_verbose : verbose to each indenting
+"
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal indentexpr=GetVerilogIndent()
+setlocal indentkeys=!^F,o,O,0),=begin,=end,=join,=endcase
+setlocal indentkeys+==endmodule,=endfunction,=endtask,=endspecify
+setlocal indentkeys+==`else,=`endif
+
+" Only define the function once.
+if exists("*GetVerilogIndent")
+ finish
+endif
+
+set cpo-=C
+
+function GetVerilogIndent()
+
+ if exists('b:verilog_indent_width')
+ let offset = b:verilog_indent_width
+ else
+ let offset = &sw
+ endif
+ if exists('b:verilog_indent_modules')
+ let indent_modules = offset
+ else
+ let indent_modules = 0
+ endif
+
+ " Find a non-blank line above the current line.
+ let lnum = prevnonblank(v:lnum - 1)
+
+ " At the start of the file use zero indent.
+ if lnum == 0
+ return 0
+ endif
+
+ let lnum2 = prevnonblank(lnum - 1)
+ let curr_line = getline(v:lnum)
+ let last_line = getline(lnum)
+ let last_line2 = getline(lnum2)
+ let ind = indent(lnum)
+ let ind2 = indent(lnum - 1)
+ let offset_comment1 = 1
+ " Define the condition of an open statement
+ " Exclude the match of //, /* or */
+ let vlog_openstat = '\(\<or\>\|\([*/]\)\@<![*(,{><+-/%^&|!=?:]\([*/]\)\@!\)'
+ " Define the condition when the statement ends with a one-line comment
+ let vlog_comment = '\(//.*\|/\*.*\*/\s*\)'
+ if exists('b:verilog_indent_verbose')
+ let vverb_str = 'INDENT VERBOSE:'
+ let vverb = 1
+ else
+ let vverb = 0
+ endif
+
+ " Indent accoding to last line
+ " End of multiple-line comment
+ if last_line =~ '\*/\s*$' && last_line !~ '/\*.\{-}\*/'
+ let ind = ind - offset_comment1
+ if vverb
+ echo vverb_str "De-indent after a multiple-line comment."
+ endif
+
+ " Indent after if/else/for/case/always/initial/specify/fork blocks
+ elseif last_line =~ '`\@<!\<\(if\|else\)\>' ||
+ \ last_line =~ '^\s*\<\(for\|case\%[[zx]]\)\>' ||
+ \ last_line =~ '^\s*\<\(always\|initial\)\>' ||
+ \ last_line =~ '^\s*\<\(specify\|fork\)\>'
+ if last_line !~ '\(;\|\<end\>\)\s*' . vlog_comment . '*$' ||
+ \ last_line =~ '\(//\|/\*\).*\(;\|\<end\>\)\s*' . vlog_comment . '*$'
+ let ind = ind + offset
+ if vverb | echo vverb_str "Indent after a block statement." | endif
+ endif
+ " Indent after function/task blocks
+ elseif last_line =~ '^\s*\<\(function\|task\)\>'
+ if last_line !~ '\<end\>\s*' . vlog_comment . '*$' ||
+ \ last_line =~ '\(//\|/\*\).*\(;\|\<end\>\)\s*' . vlog_comment . '*$'
+ let ind = ind + offset
+ if vverb
+ echo vverb_str "Indent after function/task block statement."
+ endif
+ endif
+
+ " Indent after module/function/task/specify/fork blocks
+ elseif last_line =~ '^\s*\<module\>'
+ let ind = ind + indent_modules
+ if vverb && indent_modules
+ echo vverb_str "Indent after module statement."
+ endif
+ if last_line =~ '[(,]\s*' . vlog_comment . '*$' &&
+ \ last_line !~ '\(//\|/\*\).*[(,]\s*' . vlog_comment . '*$'
+ let ind = ind + offset
+ if vverb
+ echo vverb_str "Indent after a multiple-line module statement."
+ endif
+ endif
+
+ " Indent after a 'begin' statement
+ elseif last_line =~ '\(\<begin\>\)\(\s*:\s*\w\+\)*' . vlog_comment . '*$' &&
+ \ last_line !~ '\(//\|/\*\).*\(\<begin\>\)' &&
+ \ ( last_line2 !~ vlog_openstat . '\s*' . vlog_comment . '*$' ||
+ \ last_line2 =~ '^\s*[^=!]\+\s*:\s*' . vlog_comment . '*$' )
+ let ind = ind + offset
+ if vverb | echo vverb_str "Indent after begin statement." | endif
+
+ " De-indent for the end of one-line block
+ elseif ( last_line !~ '\<begin\>' ||
+ \ last_line =~ '\(//\|/\*\).*\<begin\>' ) &&
+ \ last_line2 =~ '\<\(`\@<!if\|`\@<!else\|for\|always\|initial\)\>.*' .
+ \ vlog_comment . '*$' &&
+ \ last_line2 !~
+ \ '\(//\|/\*\).*\<\(`\@<!if\|`\@<!else\|for\|always\|initial\)\>' &&
+ \ last_line2 !~ vlog_openstat . '\s*' . vlog_comment . '*$' &&
+ \ ( last_line2 !~ '\<begin\>' ||
+ \ last_line2 =~ '\(//\|/\*\).*\<begin\>' )
+ let ind = ind - offset
+ if vverb
+ echo vverb_str "De-indent after the end of one-line statement."
+ endif
+
+ " Multiple-line statement (including case statement)
+ " Open statement
+ " Ident the first open line
+ elseif last_line =~ vlog_openstat . '\s*' . vlog_comment . '*$' &&
+ \ last_line !~ '\(//\|/\*\).*' . vlog_openstat . '\s*$' &&
+ \ last_line2 !~ vlog_openstat . '\s*' . vlog_comment . '*$'
+ let ind = ind + offset
+ if vverb | echo vverb_str "Indent after an open statement." | endif
+
+ " Close statement
+ " De-indent for an optional close parenthesis and a semicolon, and only
+ " if there exists precedent non-whitespace char
+ elseif last_line =~ ')*\s*;\s*' . vlog_comment . '*$' &&
+ \ last_line !~ '^\s*)*\s*;\s*' . vlog_comment . '*$' &&
+ \ last_line !~ '\(//\|/\*\).*\S)*\s*;\s*' . vlog_comment . '*$' &&
+ \ ( last_line2 =~ vlog_openstat . '\s*' . vlog_comment . '*$' &&
+ \ last_line2 !~ ';\s*//.*$') &&
+ \ last_line2 !~ '^\s*' . vlog_comment . '$'
+ let ind = ind - offset
+ if vverb | echo vverb_str "De-indent after a close statement." | endif
+
+ " `ifdef and `else
+ elseif last_line =~ '^\s*`\<\(ifdef\|else\)\>'
+ let ind = ind + offset
+ if vverb
+ echo vverb_str "Indent after a `ifdef or `else statement."
+ endif
+
+ endif
+
+ " Re-indent current line
+
+ " De-indent on the end of the block
+ " join/end/endcase/endfunction/endtask/endspecify
+ if curr_line =~ '^\s*\<\(join\|end\|endcase\)\>' ||
+ \ curr_line =~ '^\s*\<\(endfunction\|endtask\|endspecify\)\>'
+ let ind = ind - offset
+ if vverb | echo vverb_str "De-indent the end of a block." | endif
+ elseif curr_line =~ '^\s*\<endmodule\>'
+ let ind = ind - indent_modules
+ if vverb && indent_modules
+ echo vverb_str "De-indent the end of a module."
+ endif
+
+ " De-indent on a stand-alone 'begin'
+ elseif curr_line =~ '^\s*\<begin\>'
+ if last_line !~ '^\s*\<\(function\|task\|specify\|module\)\>' &&
+ \ last_line !~ '^\s*\()*\s*;\|)\+\)\s*' . vlog_comment . '*$' &&
+ \ ( last_line =~
+ \ '\<\(`\@<!if\|`\@<!else\|for\|case\%[[zx]]\|always\|initial\)\>' ||
+ \ last_line =~ ')\s*' . vlog_comment . '*$' ||
+ \ last_line =~ vlog_openstat . '\s*' . vlog_comment . '*$' )
+ let ind = ind - offset
+ if vverb
+ echo vverb_str "De-indent a stand alone begin statement."
+ endif
+ endif
+
+ " De-indent after the end of multiple-line statement
+ elseif curr_line =~ '^\s*)' &&
+ \ ( last_line =~ vlog_openstat . '\s*' . vlog_comment . '*$' ||
+ \ last_line !~ vlog_openstat . '\s*' . vlog_comment . '*$' &&
+ \ last_line2 =~ vlog_openstat . '\s*' . vlog_comment . '*$' )
+ let ind = ind - offset
+ if vverb
+ echo vverb_str "De-indent the end of a multiple statement."
+ endif
+
+ " De-indent `else and `endif
+ elseif curr_line =~ '^\s*`\<\(else\|endif\)\>'
+ let ind = ind - offset
+ if vverb | echo vverb_str "De-indent `else and `endif statement." | endif
+
+ endif
+
+ " Return the indention
+ return ind
+endfunction
+
+" vim:sw=2
diff --git a/runtime/indent/vim.vim b/runtime/indent/vim.vim
new file mode 100644
index 000000000..0de77748c
--- /dev/null
+++ b/runtime/indent/vim.vim
@@ -0,0 +1,65 @@
+" Vim indent file
+" Language: Vim script
+" Maintainer: Bram Moolenaar <Bram@vim.org>
+" Last Change: 2003 May 25
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal indentexpr=GetVimIndent()
+setlocal indentkeys+==end,=else,=cat,=fina,=END,0\\
+
+" Only define the function once.
+if exists("*GetVimIndent")
+ finish
+endif
+
+function GetVimIndent()
+ " Find a non-blank line above the current line.
+ let lnum = prevnonblank(v:lnum - 1)
+
+ " If the current line doesn't start with '\' and below a line that starts
+ " with '\', use the indent of the line above it.
+ if getline(v:lnum) !~ '^\s*\\'
+ while lnum > 0 && getline(lnum) =~ '^\s*\\'
+ let lnum = lnum - 1
+ endwhile
+ endif
+
+ " At the start of the file use zero indent.
+ if lnum == 0
+ return 0
+ endif
+
+ " Add a 'shiftwidth' after :if, :while, :try, :catch, :finally, :function
+ " and :else. Add it three times for a line that starts with '\' after
+ " a line that doesn't.
+ let ind = indent(lnum)
+ if getline(v:lnum) =~ '^\s*\\' && v:lnum > 1 && getline(lnum) !~ '^\s*\\'
+ let ind = ind + &sw * 3
+ elseif getline(lnum) =~ '\(^\||\)\s*\(if\|wh\%[ile]\|try\|cat\%[ch]\|fina\%[lly]\|fu\%[nction]\|el\%[seif]\)\>'
+ let ind = ind + &sw
+ elseif getline(lnum) =~ '^\s*aug\%[roup]' && getline(lnum) !~ '^\s*aug\%[roup]\s*!\=\s\+END'
+ let ind = ind + &sw
+ endif
+
+ " If the previous line contains an "end" after a pipe, but not in an ":au"
+ " command.
+ if getline(lnum) =~ '|\s*\(ene\@!\)' && getline(lnum) !~ '^\s*au\%[tocmd]'
+ let ind = ind - &sw
+ endif
+
+
+ " Subtract a 'shiftwidth' on a :endif, :endwhile, :catch, :finally, :endtry,
+ " :endfun, :else and :augroup END.
+ if getline(v:lnum) =~ '^\s*\(ene\@!\|cat\|fina\|el\|aug\%[roup]\s*!\=\s\+END\)'
+ let ind = ind - &sw
+ endif
+
+ return ind
+endfunction
+
+" vim:sw=2
diff --git a/runtime/indent/xf86conf.vim b/runtime/indent/xf86conf.vim
new file mode 100644
index 000000000..f9db1ba96
--- /dev/null
+++ b/runtime/indent/xf86conf.vim
@@ -0,0 +1,42 @@
+" Vim indent file
+" Language: XFree86 Configuration File
+" Maintainer: Nikolai Weibull <source@pcppopper.org>
+" URL: http://www.pcppopper.org/vim/indent/pcp/xf86conf/
+" Latest Revision: 2004-04-25
+" arch-tag: 8a42f7b6-5088-49cf-b15b-07696a91c015
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+
+let b:did_indent = 1
+
+setlocal indentexpr=GetXF86ConfIndent()
+setlocal indentkeys=!^F,o,O,=End
+
+" Only define the function once.
+if exists("*GetXF86ConfIndent")
+ finish
+endif
+
+function GetXF86ConfIndent()
+ let lnum = prevnonblank(v:lnum - 1)
+
+ if lnum == 0
+ return 0
+ endif
+
+ let ind = indent(lnum)
+ let line = getline(lnum)
+
+ if line =~? '^\s*\(Sub\)\=Section'
+ let ind = ind + &sw
+ elseif getline(v:lnum) =~? '^\s*End'
+ let ind = ind - &sw
+ endif
+
+ return ind
+endfunction
+
+" vim: set sts=2 sw=2:
diff --git a/runtime/indent/xhtml.vim b/runtime/indent/xhtml.vim
new file mode 100644
index 000000000..1abf6b75f
--- /dev/null
+++ b/runtime/indent/xhtml.vim
@@ -0,0 +1,7 @@
+" Vim indent file
+" Language: XHTML
+" Maintainer: Bram Moolenaar <Bram@vim.org> (for now)
+" Last Change: 2003 Feb 04
+
+" Handled like HTML for now.
+runtime! indent/html.vim
diff --git a/runtime/indent/xml.vim b/runtime/indent/xml.vim
new file mode 100644
index 000000000..340981b3d
--- /dev/null
+++ b/runtime/indent/xml.vim
@@ -0,0 +1,88 @@
+" Language: xml
+" Maintainer: Johannes Zellner <johannes@zellner.org>
+" Last Change: Tue, 27 Apr 2004 14:54:59 CEST
+" Notes: 1) does not indent pure non-xml code (e.g. embedded scripts)
+" 2) will be confused by unbalanced tags in comments
+" or CDATA sections.
+" TODO: implement pre-like tags, see xml_indent_open / xml_indent_close
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+" [-- local settings (must come before aborting the script) --]
+setlocal indentexpr=XmlIndentGet(v:lnum,1)
+setlocal indentkeys=o,O,*<Return>,<>>,<<>,/,{,}
+
+set cpo-=C
+
+if !exists('b:xml_indent_open')
+ let b:xml_indent_open = '.\{-}<\a'
+ " pre tag, e.g. <address>
+ " let b:xml_indent_open = '.\{-}<[/]\@!\(address\)\@!'
+endif
+
+if !exists('b:xml_indent_close')
+ let b:xml_indent_close = '.\{-}</'
+ " end pre tag, e.g. </address>
+ " let b:xml_indent_close = '.\{-}</\(address\)\@!'
+endif
+
+" [-- finish, if the function already exists --]
+if exists('*XmlIndentGet') | finish | endif
+
+fun! <SID>XmlIndentWithPattern(line, pat)
+ let s = substitute('x'.a:line, a:pat, "\1", 'g')
+ return strlen(substitute(s, "[^\1].*$", '', ''))
+endfun
+
+" [-- check if it's xml --]
+fun! <SID>XmlIndentSynCheck(lnum)
+ if '' != &syntax
+ let syn1 = synIDattr(synID(a:lnum, 1, 1), 'name')
+ let syn2 = synIDattr(synID(a:lnum, strlen(getline(a:lnum)) - 1, 1), 'name')
+ if '' != syn1 && syn1 !~ 'xml' && '' != syn2 && syn2 !~ 'xml'
+ " don't indent pure non-xml code
+ return 0
+ endif
+ endif
+ return 1
+endfun
+
+" [-- return the sum of indents of a:lnum --]
+fun! <SID>XmlIndentSum(lnum, style, add)
+ let line = getline(a:lnum)
+ if a:style == match(line, '^\s*</')
+ return (&sw *
+ \ (<SID>XmlIndentWithPattern(line, b:xml_indent_open)
+ \ - <SID>XmlIndentWithPattern(line, b:xml_indent_close)
+ \ - <SID>XmlIndentWithPattern(line, '.\{-}/>'))) + a:add
+ else
+ return a:add
+ endif
+endfun
+
+fun! XmlIndentGet(lnum, use_syntax_check)
+ " Find a non-empty line above the current line.
+ let lnum = prevnonblank(a:lnum - 1)
+
+ " Hit the start of the file, use zero indent.
+ if lnum == 0
+ return 0
+ endif
+
+ if a:use_syntax_check
+ if 0 == <SID>XmlIndentSynCheck(lnum) || 0 == <SID>XmlIndentSynCheck(a:lnum)
+ return indent(a:lnum)
+ endif
+ endif
+
+ let ind = <SID>XmlIndentSum(lnum, -1, indent(lnum))
+ let ind = <SID>XmlIndentSum(a:lnum, 0, ind)
+
+ return ind
+endfun
+
+" vim:ts=8
diff --git a/runtime/indent/xslt.vim b/runtime/indent/xslt.vim
new file mode 100644
index 000000000..ff93d69d7
--- /dev/null
+++ b/runtime/indent/xslt.vim
@@ -0,0 +1,13 @@
+" Vim indent file
+" Language: XSLT .xslt files
+" Maintainer: David Fishburn <fishburn@ianywhere.com>
+" Last Change: Wed May 14 2003 8:48:41 PM
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+
+" Use XML formatting rules
+runtime! indent/xml.vim
+
diff --git a/runtime/indent/yacc.vim b/runtime/indent/yacc.vim
new file mode 100644
index 000000000..4ea8f6a2d
--- /dev/null
+++ b/runtime/indent/yacc.vim
@@ -0,0 +1,44 @@
+" Vim indent file
+" Language: YACC input file
+" Maintainer: Nikolai Weibull <source@pcppopper.org>
+" URL: http://www.pcppopper.org/vim/indent/pcp/yacc/
+" Latest Revision: 2004-04-25
+" arch-tag: 629aa719-8fe4-4787-adb7-ae94ca801610
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+
+let b:did_indent = 1
+
+setlocal indentexpr=GetYaccIndent()
+setlocal indentkeys=!^F,o,O
+
+" Only define the function once.
+if exists("*GetYaccIndent")
+ finish
+endif
+
+function GetYaccIndent()
+ if v:lnum == 1
+ return 0
+ endif
+
+ let ind = indent(v:lnum - 1)
+ let line = getline(v:lnum - 1)
+
+ if line == ''
+ let ind = 0
+ elseif line =~ '^\w\+\s*:'
+ let ind = ind + matchend(line, '^\w\+\s*')
+ elseif line =~ '^\s*;'
+ let ind = 0
+ else
+ let ind = indent(v:lnum)
+ endif
+
+ return ind
+endfunction
+
+" vim: set sts=2 sw=2:
diff --git a/runtime/indent/zsh.vim b/runtime/indent/zsh.vim
new file mode 100644
index 000000000..ff28d99d7
--- /dev/null
+++ b/runtime/indent/zsh.vim
@@ -0,0 +1,11 @@
+" Vim indent file
+" Language: Zsh Shell Script
+" Maintainer: Nikolai Weibull <source@pcppopper.org>
+" URL: http://www.pcppopper.org/vim/indent/pcp/zsh/
+" Latest Revision: 2004-05-22
+" arch-tag: e566f55f-d8c0-4c60-b4b3-60c0dbd6dea1
+
+" Same as sh indenting for now.
+runtime! indent/sh.vim
+
+" vim: set sts=2 sw=2: