annotate runtime/indent/rpl.vim @ 34669:fe206762c077

Update README.txt and README.md (#14313) Commit: https://github.com/vim/vim/commit/b75825f749cf87feb9ae8e7e5327bd2efe707c86 Author: Restorer <69863286+RestorerZ@users.noreply.github.com> Date: Thu Mar 28 09:14:47 2024 +0000 Update README.txt and README.md (https://github.com/vim/vim/issues/14313) Signed-off-by: RestorerZ <restorer@mail2k.ru> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Thu, 28 Mar 2024 10:15:11 +0100
parents 5b7ea82bc18f
children
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
22723
5b7ea82bc18f Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
5 " Maintainer: BERTRAND Joël <rpl2@free.fr>
7
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