annotate runtime/indent/tf.vim @ 32086:45142117e206 v9.0.1374

patch 9.0.1374: function for setting options not used consistently Commit: https://github.com/vim/vim/commit/c727b19e9f1df36e44321d933334c7b4961daa54 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Fri Mar 3 12:26:15 2023 +0000 patch 9.0.1374: function for setting options not used consistently Problem: Function for setting options not used consistently. Solution: Use a function for 'encoding' and terminal options. (Yegappan Lakshmanan, closes #12099)
author Bram Moolenaar <Bram@vim.org>
date Fri, 03 Mar 2023 13:30:03 +0100
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