annotate runtime/indent/rpl.vim @ 15272:0cbbf3874dd4

Added tag v8.1.0644 for changeset a6319aca721b551e62dda2f617c320a4f903c82c
author Bram Moolenaar <Bram@vim.org>
date Thu, 27 Dec 2018 00:30:07 +0100
parents 63b0b7b79b25
children 5b7ea82bc18f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim indent file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Language: RPL/2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 " Version: 0.2
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 233
diff changeset
4 " Last Change: 2017 Jun 13
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 " Maintainer: BERTRAND Joël <rpl2@free.fr>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 " Only load this indent file when no other was loaded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12
233
fca8a9b65afa updated for version 7.0065
vimboss
parents: 7
diff changeset
13 setlocal autoindent
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 setlocal indentkeys+==~end,=~case,=~if,=~then,=~else,=~do,=~until,=~while,=~repeat,=~select,=~default,=~for,=~start,=~next,=~step,<<>,<>>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 " Define the appropriate indent function but only once
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 setlocal indentexpr=RplGetFreeIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 if exists("*RplGetFreeIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21
233
fca8a9b65afa updated for version 7.0065
vimboss
parents: 7
diff changeset
22 let b:undo_indent = "set ai< indentkeys< indentexpr<"
fca8a9b65afa updated for version 7.0065
vimboss
parents: 7
diff changeset
23
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 function RplGetIndent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 let ind = indent(a:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 let prevline=getline(a:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 " Strip tail comment
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 let prevstat=substitute(prevline, '!.*$', '', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 " Add a shiftwidth to statements following if, iferr, then, else, elseif,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 " case, select, default, do, until, while, repeat, for, start
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 if prevstat =~? '\<\(if\|iferr\|do\|while\)\>' && prevstat =~? '\<end\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 elseif prevstat =~? '\(^\|\s\+\)<<\($\|\s\+\)' && prevstat =~? '\s\+>>\($\|\s\+\)'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 elseif prevstat =~? '\<\(if\|iferr\|then\|else\|elseif\|select\|case\|do\|until\|while\|repeat\|for\|start\|default\)\>' || prevstat =~? '\(^\|\s\+\)<<\($\|\s\+\)'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 233
diff changeset
35 let ind = ind + shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 " Subtract a shiftwidth from then, else, elseif, end, until, repeat, next,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 " step
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 let line = getline(v:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 if line =~? '^\s*\(then\|else\|elseif\|until\|repeat\|next\|step\|default\|end\)\>'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 233
diff changeset
42 let ind = ind - shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 elseif line =~? '^\s*>>\($\|\s\+\)'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 233
diff changeset
44 let ind = ind - shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 function RplGetFreeIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 " Find the previous non-blank line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 let lnum = prevnonblank(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 " Use zero indent at the top of the file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 if lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 let ind=RplGetIndent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 " vim:sw=2 tw=130