vim: update release.sh to vim 7.3
[msysgit/mtrensch.git] / share / vim / vim72 / indent / prolog.vim
blobafe448e8f3e7a133ad3119afb4db4a6769a738e4
1 "  vim: set sw=4 sts=4:
2 "  Maintainer   : Gergely Kontra <kgergely@mcl.hu>
3 "  Revised on   : 2002.02.18. 23:34:05
4 "  Language     : Prolog
6 " TODO:
7 "   checking with respect to syntax highlighting
8 "   ignoring multiline comments
9 "   detecting multiline strings
11 " Only load this indent file when no other was loaded.
12 if exists("b:did_indent")
13     finish
14 endif
16 let b:did_indent = 1
18 setlocal indentexpr=GetPrologIndent()
19 setlocal indentkeys-=:,0#
20 setlocal indentkeys+=0%,-,0;,>,0)
22 " Only define the function once.
23 "if exists("*GetPrologIndent")
24 "    finish
25 "endif
27 function! GetPrologIndent()
28     " Find a non-blank line above the current line.
29     let pnum = prevnonblank(v:lnum - 1)
30     " Hit the start of the file, use zero indent.
31     if pnum == 0
32        return 0
33     endif
34     let line = getline(v:lnum)
35     let pline = getline(pnum)
37     let ind = indent(pnum)
38     " Previous line was comment -> use previous line's indent
39     if pline =~ '^\s*%'
40         retu ind
41     endif
42     " Check for clause head on previous line
43     if pline =~ ':-\s*\(%.*\)\?$'
44         let ind = ind + &sw
45     " Check for end of clause on previous line
46     elseif pline =~ '\.\s*\(%.*\)\?$'
47         let ind = ind - &sw
48     endif
49     " Check for opening conditional on previous line
50     if pline =~ '^\s*\([(;]\|->\)'
51         let ind = ind + &sw
52     endif
53     " Check for closing an unclosed paren, or middle ; or ->
54     if line =~ '^\s*\([);]\|->\)'
55         let ind = ind - &sw
56     endif
57     return ind
58 endfunction