vim: update release.sh to vim 7.3
[msysgit/mtrensch.git] / share / vim / vim72 / indent / idlang.vim
blob97c31ada581fe29d35894fb86b654d81f44edab0
1 " IDL (Interactive Data Language) indent file.
2 " Language: IDL (ft=idlang)
3 " Last change:  2002 Sep 23
4 " Maintainer: Aleksandar Jelenak <ajelenak AT yahoo.com>
6 " Only load this indent file when no other was loaded.
7 if exists("b:did_indent")
8    finish
9 endif
10 let b:did_indent = 1
12 setlocal indentkeys=o,O,0=endif,0=ENDIF,0=endelse,0=ENDELSE,0=endwhile,
13                     \0=ENDWHILE,0=endfor,0=ENDFOR,0=endrep,0=ENDREP
15 setlocal indentexpr=GetIdlangIndent(v:lnum)
17 " Only define the function once.
18 if exists("*GetIdlangIndent")
19    finish
20 endif
22 function GetIdlangIndent(lnum)
23    " First non-empty line above the current line.
24    let pnum = prevnonblank(v:lnum-1)
25    " v:lnum is the first non-empty line -- zero indent.
26    if pnum == 0
27       return 0
28    endif
29    " Second non-empty line above the current line.
30    let pnum2 = prevnonblank(pnum-1)
32    " Current indent.
33    let curind = indent(pnum)
35    " Indenting of continued lines.
36    if getline(pnum) =~ '\$\s*\(;.*\)\=$'
37       if getline(pnum2) !~ '\$\s*\(;.*\)\=$'
38          let curind = curind+&sw
39       endif
40    else
41       if getline(pnum2) =~ '\$\s*\(;.*\)\=$'
42          let curind = curind-&sw
43       endif
44    endif
46    " Indenting blocks of statements.
47    if getline(v:lnum) =~? '^\s*\(endif\|endelse\|endwhile\|endfor\|endrep\)\>'
48       if getline(pnum) =~? 'begin\>'
49       elseif indent(v:lnum) > curind-&sw
50          let curind = curind-&sw
51       else
52          return -1
53       endif
54    elseif getline(pnum) =~? 'begin\>'
55       if indent(v:lnum) < curind+&sw
56          let curind = curind+&sw
57       else
58          return -1
59       endif
60    endif
61    return curind
62 endfunction