2 " Language: Hamster Script
4 " Last Change: Wed Nov 08 2006 12:02:42 PM
5 " Maintainer: David Fishburn <fishburn@ianywhere.com>
7 " Only load this indent file when no other was loaded.
8 if exists("b:did_indent")
13 setlocal indentkeys+==~if,=~else,=~endif,=~endfor,=~endwhile
14 setlocal indentkeys+==~do,=~until,=~while,=~repeat,=~for,=~loop
15 setlocal indentkeys+==~sub,=~endsub
17 " Define the appropriate indent function but only once
18 setlocal indentexpr=HamGetFreeIndent()
19 if exists("*HamGetFreeIndent")
23 function HamGetIndent(lnum)
24 let ind = indent(a:lnum)
25 let prevline=getline(a:lnum)
27 " Add a shiftwidth to statements following if, else, elseif,
28 " case, select, default, do, until, while, for, start
29 if prevline =~? '^\s*\<\(if\|else\%(if\)\?\|for\|repeat\|do\|while\|sub\)\>'
33 " Subtract a shiftwidth from else, elseif, end(if|while|for), until
34 let line = getline(v:lnum)
35 if line =~? '^\s*\(else\|elseif\|loop\|until\|end\%(if\|while\|for\|sub\)\)\>'
42 function HamGetFreeIndent()
43 " Find the previous non-blank line
44 let lnum = prevnonblank(v:lnum - 1)
46 " Use zero indent at the top of the file
51 let ind=HamGetIndent(lnum)