1 " Maintainer: Paulo Moura <pmoura@logtalk.org>
2 " Revised on: 2008.06.02
5 " This Logtalk indent file is a modified version of the Prolog
6 " indent file written by Gergely Kontra
8 " Only load this indent file when no other was loaded.
9 if exists("b:did_indent")
15 setlocal indentexpr=GetLogtalkIndent()
16 setlocal indentkeys-=:,0#
17 setlocal indentkeys+=0%,-,0;,>,0)
19 " Only define the function once.
20 if exists("*GetLogtalkIndent")
24 function! GetLogtalkIndent()
25 " Find a non-blank line above the current line.
26 let pnum = prevnonblank(v:lnum - 1)
27 " Hit the start of the file, use zero indent.
31 let line = getline(v:lnum)
32 let pline = getline(pnum)
34 let ind = indent(pnum)
35 " Previous line was comment -> use previous line's indent
39 " Check for entity opening directive on previous line
40 if pline =~ '^\s*:-\s\(object\|protocol\|category\)\ze(.*,$'
42 " Check for clause head on previous line
43 elseif pline =~ ':-\s*\(%.*\)\?$'
45 " Check for entity closing directive on previous line
46 elseif pline =~ '^\s*:-\send_\(object\|protocol\|category\)\.\(%.*\)\?$'
48 " Check for end of clause on previous line
49 elseif pline =~ '\.\s*\(%.*\)\?$'
52 " Check for opening conditional on previous line
53 if pline =~ '^\s*\([(;]\|->\)' && pline !~ '\.\s*\(%.*\)\?$' && pline !~ '^.*\([)][,]\s*\(%.*\)\?$\)'
56 " Check for closing an unclosed paren, or middle ; or ->
57 if line =~ '^\s*\([);]\|->\)'