annotate runtime/indent/logtalk.vim @ 29542:61b400b5e1a8 v9.0.0112

patch 9.0.0112: MS-Windows: test fails because file already exists Commit: https://github.com/vim/vim/commit/0f823c360947779d9de6048c6bce51c670a06eb6 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jul 30 15:35:12 2022 +0100 patch 9.0.0112: MS-Windows: test fails because file already exists Problem: MS-Windows: test fails because file already exists. Solution: Wait a little while until the file is gone.
author Bram Moolenaar <Bram@vim.org>
date Sat, 30 Jul 2022 16:45:04 +0200
parents 5c5908e81e93
children 5c220cf30f1f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
1 " Maintainer: Paulo Moura <pmoura@logtalk.org>
14519
5c5908e81e93 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
2 " Revised on: 2018.08.04
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
3 " Language: Logtalk
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
4
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
5 " This Logtalk indent file is a modified version of the Prolog
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
6 " indent file written by Gergely Kontra
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
7
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
8 " Only load this indent file when no other was loaded.
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
9 if exists("b:did_indent")
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
10 finish
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
11 endif
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
12
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
13 let b:did_indent = 1
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
14
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
15 setlocal indentexpr=GetLogtalkIndent()
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
16 setlocal indentkeys-=:,0#
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
17 setlocal indentkeys+=0%,-,0;,>,0)
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
18
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
19 " Only define the function once.
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
20 if exists("*GetLogtalkIndent")
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
21 finish
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
22 endif
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
23
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
24 function! GetLogtalkIndent()
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
25 " Find a non-blank line above the current line.
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
26 let pnum = prevnonblank(v:lnum - 1)
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
27 " Hit the start of the file, use zero indent.
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
28 if pnum == 0
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
29 return 0
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
30 endif
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
31 let line = getline(v:lnum)
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
32 let pline = getline(pnum)
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
33
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
34 let ind = indent(pnum)
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
35 " Previous line was comment -> use previous line's indent
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
36 if pline =~ '^\s*%'
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
37 retu ind
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
38 endif
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
39 " Check for entity opening directive on previous line
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
40 if pline =~ '^\s*:-\s\(object\|protocol\|category\)\ze(.*,$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 1668
diff changeset
41 let ind = ind + shiftwidth()
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
42 " Check for clause head on previous line
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
43 elseif pline =~ ':-\s*\(%.*\)\?$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 1668
diff changeset
44 let ind = ind + shiftwidth()
14519
5c5908e81e93 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
45 " Check for grammar rule head on previous line
5c5908e81e93 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
46 elseif pline =~ '-->\s*\(%.*\)\?$'
5c5908e81e93 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
47 let ind = ind + shiftwidth()
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
48 " Check for entity closing directive on previous line
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
49 elseif pline =~ '^\s*:-\send_\(object\|protocol\|category\)\.\(%.*\)\?$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 1668
diff changeset
50 let ind = ind - shiftwidth()
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
51 " Check for end of clause on previous line
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
52 elseif pline =~ '\.\s*\(%.*\)\?$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 1668
diff changeset
53 let ind = ind - shiftwidth()
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
54 endif
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
55 " Check for opening conditional on previous line
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
56 if pline =~ '^\s*\([(;]\|->\)' && pline !~ '\.\s*\(%.*\)\?$' && pline !~ '^.*\([)][,]\s*\(%.*\)\?$\)'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 1668
diff changeset
57 let ind = ind + shiftwidth()
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
58 endif
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
59 " Check for closing an unclosed paren, or middle ; or ->
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
60 if line =~ '^\s*\([);]\|->\)'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 1668
diff changeset
61 let ind = ind - shiftwidth()
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
62 endif
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
63 return ind
0b796e045c42 updated for version 7.2b-000
vimboss
parents:
diff changeset
64 endfunction