Mercurial > vim
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 |
rev | line source |
---|---|
1624 | 1 " Vim indent file |
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 | 4 " URL: http://www.vim.org/scripts/script.php?script_id=174 |
28620 | 5 " Last Change: 2022 Apr 25 |
1624 | 6 |
7 " Only load this indent file when no other was loaded. | |
8 if exists("b:did_indent") | |
9 finish | |
10 endif | |
11 let b:did_indent = 1 | |
12 | |
13 setlocal indentexpr=GetTFIndent() | |
14 setlocal indentkeys-=0{,0} indentkeys-=0# indentkeys-=: | |
15 setlocal indentkeys+==/endif,=/then,=/else,=/done,0; | |
16 | |
28620 | 17 let b:undo_indent = "setlocal indentexpr< indentkeys<" |
18 | |
1624 | 19 " Only define the function once: |
20 if exists("*GetTFIndent") | |
21 finish | |
22 endif | |
23 | |
24 function GetTFIndent() | |
25 " Find a non-blank line above the current line: | |
26 let lnum = prevnonblank(v:lnum - 1) | |
27 | |
28 " No indent for the start of the file: | |
29 if lnum == 0 | |
30 return 0 | |
31 endif | |
32 | |
33 let ind = indent(lnum) | |
34 let line = getline(lnum) | |
35 | |
36 " No indentation if the previous line didn't end with "\": | |
37 " (Could be annoying, but it lets you know if you made a mistake.) | |
38 if line !~ '\\$' | |
39 return 0 | |
40 endif | |
41 | |
42 if line =~ '\(/def.*\\\|/for.*\(%;\s*\)\@\<!\\\)$' | |
11062 | 43 let ind = ind + shiftwidth() |
1624 | 44 elseif line =~ '\(/if\|/else\|/then\)' |
45 if line !~ '/endif' | |
11062 | 46 let ind = ind + shiftwidth() |
1624 | 47 endif |
48 elseif line =~ '/while' | |
49 if line !~ '/done' | |
11062 | 50 let ind = ind + shiftwidth() |
1624 | 51 endif |
52 endif | |
53 | |
54 let line = getline(v:lnum) | |
55 | |
56 if line =~ '\(/else\|/endif\|/then\)' | |
57 if line !~ '/if' | |
11062 | 58 let ind = ind - shiftwidth() |
1624 | 59 endif |
60 elseif line =~ '/done' | |
61 if line !~ '/while' | |
11062 | 62 let ind = ind - shiftwidth() |
1624 | 63 endif |
64 endif | |
65 | |
66 " Comments at the beginning of a line: | |
67 if line =~ '^\s*;' | |
68 let ind = 0 | |
69 endif | |
70 | |
71 | |
72 return ind | |
73 | |
74 endfunction |