annotate runtime/indent/tf.vim @ 33075:0346ff4c3ee7 v9.0.1824

patch 9.0.1824: Vim9: private members may be modifiable Commit: https://github.com/vim/vim/commit/5bbcfbc4a260bc082829311086c3a1109c40f2d3 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Wed Aug 30 16:38:26 2023 +0200 patch 9.0.1824: Vim9: private members may be modifiable Problem: Vim9: private members may be modifiable Solution: prevent modification for def function closes: #12963 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
author Christian Brabandt <cb@256bit.org>
date Wed, 30 Aug 2023 16:45:10 +0200
parents 4d76b3e07c07
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1624
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
1 " Vim indent file
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
2 " Language: tf (TinyFugue)
2239
732cb7b31956 Crypt the text in the undo file if the file itself is crypted.
Bram Moolenaar <bram@vim.org>
parents: 1624
diff changeset
3 " Maintainer: Christian J. Robinson <heptite@gmail.com>
11062
1218c5353e2b Runtime file updates.
Christian Brabandt <cb@256bit.org>
parents: 2239
diff changeset
4 " URL: http://www.vim.org/scripts/script.php?script_id=174
28620
4d76b3e07c07 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
5 " Last Change: 2022 Apr 25
1624
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
6
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
7 " Only load this indent file when no other was loaded.
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
8 if exists("b:did_indent")
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
9 finish
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
10 endif
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
11 let b:did_indent = 1
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
12
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
13 setlocal indentexpr=GetTFIndent()
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
14 setlocal indentkeys-=0{,0} indentkeys-=0# indentkeys-=:
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
15 setlocal indentkeys+==/endif,=/then,=/else,=/done,0;
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
16
28620
4d76b3e07c07 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
17 let b:undo_indent = "setlocal indentexpr< indentkeys<"
4d76b3e07c07 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
18
1624
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
19 " Only define the function once:
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
20 if exists("*GetTFIndent")
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
21 finish
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
22 endif
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
23
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
24 function GetTFIndent()
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
25 " Find a non-blank line above the current line:
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
26 let lnum = prevnonblank(v:lnum - 1)
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
27
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
28 " No indent for the start of the file:
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
29 if lnum == 0
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
30 return 0
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
31 endif
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
32
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
33 let ind = indent(lnum)
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
34 let line = getline(lnum)
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
35
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
36 " No indentation if the previous line didn't end with "\":
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
37 " (Could be annoying, but it lets you know if you made a mistake.)
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
38 if line !~ '\\$'
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
39 return 0
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
40 endif
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
41
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
42 if line =~ '\(/def.*\\\|/for.*\(%;\s*\)\@\<!\\\)$'
11062
1218c5353e2b Runtime file updates.
Christian Brabandt <cb@256bit.org>
parents: 2239
diff changeset
43 let ind = ind + shiftwidth()
1624
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
44 elseif line =~ '\(/if\|/else\|/then\)'
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
45 if line !~ '/endif'
11062
1218c5353e2b Runtime file updates.
Christian Brabandt <cb@256bit.org>
parents: 2239
diff changeset
46 let ind = ind + shiftwidth()
1624
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
47 endif
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
48 elseif line =~ '/while'
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
49 if line !~ '/done'
11062
1218c5353e2b Runtime file updates.
Christian Brabandt <cb@256bit.org>
parents: 2239
diff changeset
50 let ind = ind + shiftwidth()
1624
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
51 endif
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
52 endif
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
53
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
54 let line = getline(v:lnum)
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
55
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
56 if line =~ '\(/else\|/endif\|/then\)'
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
57 if line !~ '/if'
11062
1218c5353e2b Runtime file updates.
Christian Brabandt <cb@256bit.org>
parents: 2239
diff changeset
58 let ind = ind - shiftwidth()
1624
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
59 endif
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
60 elseif line =~ '/done'
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
61 if line !~ '/while'
11062
1218c5353e2b Runtime file updates.
Christian Brabandt <cb@256bit.org>
parents: 2239
diff changeset
62 let ind = ind - shiftwidth()
1624
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
63 endif
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
64 endif
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
65
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
66 " Comments at the beginning of a line:
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
67 if line =~ '^\s*;'
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
68 let ind = 0
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
69 endif
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
70
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
71
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
72 return ind
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
73
18ee39301b82 updated for version 7.2a
vimboss
parents:
diff changeset
74 endfunction