summaryrefslogtreecommitdiffstats
path: root/runtime/indent
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2004-06-13 20:20:40 +0000
committerBram Moolenaar <Bram@vim.org>2004-06-13 20:20:40 +0000
commit071d4279d6ab81b7187b48f3a0fc61e587b6db6c (patch)
tree221cbe3c40e043163c06f61c52a7ba2eb41e12ce /runtime/indent
parentb4210b3bc14e2918f153a7307530fbe6eba659e1 (diff)
updated for version 7.0001v7.0001
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 0000000000..a424b4f8c0
--- /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 0000000000..78ac0336dd
--- /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 0000000000..72e2e80e55
--- /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 0000000000..067f272133
--- /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 0000000000..60eff07500
--- /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 0000000000..726a5ddbe5
--- /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 0000000000..135251dcad
--- /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 0000000000..db2b9052b2
--- /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
+