Mercurial > vim
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 |
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 |