annotate runtime/indent/pascal.vim @ 31938:96d6d31dd66b v9.0.1301

patch 9.0.1301: virtual text below empty line not displayed Commit: https://github.com/vim/vim/commit/9d9a20ee8799bafe9caac616fef11b7a26db6a8d Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 11 13:49:01 2023 +0000 patch 9.0.1301: virtual text below empty line not displayed Problem: Virtual text below empty line not displayed. Solution: Adjust flags and computations. (closes https://github.com/vim/vim/issues/11959)
author Bram Moolenaar <Bram@vim.org>
date Sat, 11 Feb 2023 15:00:04 +0100
parents 9c221ad9634a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
391
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
1 " Vim indent file
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
2 " Language: Pascal
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
3 " Maintainer: Neil Carter <n.carter@swansea.ac.uk>
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
4 " Created: 2004 Jul 13
25880
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25161
diff changeset
5 " Last Change: 2021 Sep 22
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
6 "
25880
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25161
diff changeset
7 " For further documentation, see https://psy.swansea.ac.uk/staff/carter/vim/
391
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
8
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
9
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
10 if exists("b:did_indent")
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
11 finish
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
12 endif
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
13 let b:did_indent = 1
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
14
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
15 setlocal indentexpr=GetPascalIndent(v:lnum)
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
16 setlocal indentkeys&
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
17 setlocal indentkeys+==end;,==const,==type,==var,==begin,==repeat,==until,==for
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
18 setlocal indentkeys+==program,==function,==procedure,==object,==private
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
19 setlocal indentkeys+==record,==if,==else,==case
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
20
25880
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25161
diff changeset
21 let b:undo_indent = 'setlocal indentexpr< indentkeys<'
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
22
391
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
23 if exists("*GetPascalIndent")
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
24 finish
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
25 endif
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
26
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
27
25880
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25161
diff changeset
28 " ________________________________________________________________
391
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
29 function! s:GetPrevNonCommentLineNum( line_num )
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
30
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
31 " Skip lines starting with a comment
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
32 let SKIP_LINES = '^\s*\(\((\*\)\|\(\*\ \)\|\(\*)\)\|{\|}\)'
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
33
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
34 let nline = a:line_num
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
35 while nline > 0
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
36 let nline = prevnonblank(nline-1)
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
37 if getline(nline) !~? SKIP_LINES
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
38 break
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
39 endif
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
40 endwhile
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
41
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
42 return nline
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
43 endfunction
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
44
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
45
25880
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25161
diff changeset
46 " ________________________________________________________________
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
47 function! s:PurifyCode( line_num )
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
48 " Strip any trailing comments and whitespace
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
49 let pureline = 'TODO'
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
50 return pureline
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
51 endfunction
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
52
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
53
25880
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25161
diff changeset
54 " ________________________________________________________________
391
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
55 function! GetPascalIndent( line_num )
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
56
391
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
57 " Line 0 always goes at column 0
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
58 if a:line_num == 0
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
59 return 0
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
60 endif
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
61
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
62 let this_codeline = getline( a:line_num )
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
63
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
64
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
65 " SAME INDENT
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
66
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
67 " Middle of a three-part comment
391
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
68 if this_codeline =~ '^\s*\*'
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
69 return indent( a:line_num - 1)
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
70 endif
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
71
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
72
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
73 " COLUMN 1 ALWAYS
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
74
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
75 " Last line of the program
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
76 if this_codeline =~ '^\s*end\.'
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
77 return 0
391
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
78 endif
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
79
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
80 " Compiler directives, allowing "(*" and "{"
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
81 "if this_codeline =~ '^\s*\({\|(\*\)$\(IFDEF\|IFNDEF\|ELSE\|ENDIF\)'
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
82 if this_codeline =~ '^\s*\({\|(\*\)\$'
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
83 return 0
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
84 endif
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
85
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
86 " section headers
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
87 if this_codeline =~ '^\s*\(program\|procedure\|function\|type\)\>'
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
88 return 0
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
89 endif
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
90
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
91 " Subroutine separators, lines ending with "const" or "var"
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
92 if this_codeline =~ '^\s*\((\*\ _\+\ \*)\|\(const\|var\)\)$'
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
93 return 0
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
94 endif
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
95
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
96
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
97 " OTHERWISE, WE NEED TO LOOK FURTHER BACK...
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
98
391
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
99 let prev_codeline_num = s:GetPrevNonCommentLineNum( a:line_num )
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
100 let prev_codeline = getline( prev_codeline_num )
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
101 let indnt = indent( prev_codeline_num )
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
102
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
103
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
104 " INCREASE INDENT
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
105
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
106 " If the PREVIOUS LINE ended in these items, always indent
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
107 if prev_codeline =~ '\<\(type\|const\|var\)$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2751
diff changeset
108 return indnt + shiftwidth()
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
109 endif
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
110
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
111 if prev_codeline =~ '\<repeat$'
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
112 if this_codeline !~ '^\s*until\>'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2751
diff changeset
113 return indnt + shiftwidth()
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
114 else
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
115 return indnt
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
116 endif
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
117 endif
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
118
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
119 if prev_codeline =~ '\<\(begin\|record\)$'
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
120 if this_codeline !~ '^\s*end\>'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2751
diff changeset
121 return indnt + shiftwidth()
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
122 else
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
123 return indnt
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
124 endif
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
125 endif
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
126
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
127 " If the PREVIOUS LINE ended with these items, indent if not
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
128 " followed by "begin"
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
129 if prev_codeline =~ '\<\(\|else\|then\|do\)$' || prev_codeline =~ ':$'
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
130 if this_codeline !~ '^\s*begin\>'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2751
diff changeset
131 return indnt + shiftwidth()
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
132 else
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
133 " If it does start with "begin" then keep the same indent
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2751
diff changeset
134 "return indnt + shiftwidth()
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
135 return indnt
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
136 endif
391
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
137 endif
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
138
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
139 " Inside a parameter list (i.e. a "(" without a ")"). ???? Considers
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
140 " only the line before the current one. TODO: Get it working for
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
141 " parameter lists longer than two lines.
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
142 if prev_codeline =~ '([^)]\+$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2751
diff changeset
143 return indnt + shiftwidth()
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
144 endif
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
145
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
146
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
147 " DECREASE INDENT
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
148
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
149 " Lines starting with "else", but not following line ending with
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
150 " "end".
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
151 if this_codeline =~ '^\s*else\>' && prev_codeline !~ '\<end$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2751
diff changeset
152 return indnt - shiftwidth()
391
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
153 endif
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
154
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
155 " Lines after a single-statement branch/loop.
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
156 " Two lines before ended in "then", "else", or "do"
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
157 " Previous line didn't end in "begin"
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
158 let prev2_codeline_num = s:GetPrevNonCommentLineNum( prev_codeline_num )
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
159 let prev2_codeline = getline( prev2_codeline_num )
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
160 if prev2_codeline =~ '\<\(then\|else\|do\)$' && prev_codeline !~ '\<begin$'
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
161 " If the next code line after a single statement branch/loop
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
162 " starts with "end", "except" or "finally", we need an
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
163 " additional unindentation.
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
164 if this_codeline =~ '^\s*\(end;\|except\|finally\|\)$'
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
165 " Note that we don't return from here.
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2751
diff changeset
166 return indnt - 2 * shiftwidth()
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
167 endif
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2751
diff changeset
168 return indnt - shiftwidth()
391
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
169 endif
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
170
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
171 " Lines starting with "until" or "end". This rule must be overridden
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
172 " by the one for "end" after a single-statement branch/loop. In
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
173 " other words that rule should come before this one.
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
174 if this_codeline =~ '^\s*\(end\|until\)\>'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2751
diff changeset
175 return indnt - shiftwidth()
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
176 endif
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
177
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
178
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
179 " MISCELLANEOUS THINGS TO CATCH
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
180
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
181 " Most "begin"s will have been handled by now. Any remaining
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
182 " "begin"s on their own line should go in column 1.
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
183 if this_codeline =~ '^\s*begin$'
391
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
184 return 0
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
185 endif
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
186
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
187
25880
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25161
diff changeset
188 " ________________________________________________________________
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
189 " Object/Borland Pascal/Delphi Extensions
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
190 "
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
191 " Note that extended-pascal is handled here, unless it is simpler to
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
192 " handle them in the standard-pascal section above.
391
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
193
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
194
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
195 " COLUMN 1 ALWAYS
391
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
196
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
197 " section headers at start of line.
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
198 if this_codeline =~ '^\s*\(interface\|implementation\|uses\|unit\)\>'
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
199 return 0
391
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
200 endif
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
201
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
202
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
203 " INDENT ONCE
391
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
204
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
205 " If the PREVIOUS LINE ended in these items, always indent.
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
206 if prev_codeline =~ '^\s*\(unit\|uses\|try\|except\|finally\|private\|protected\|public\|published\)$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2751
diff changeset
207 return indnt + shiftwidth()
391
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
208 endif
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
209
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
210 " ???? Indent "procedure" and "functions" if they appear within an
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
211 " class/object definition. But that means overriding standard-pascal
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
212 " rule where these words always go in column 1.
391
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
213
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
214
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
215 " UNINDENT ONCE
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
216
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
217 if this_codeline =~ '^\s*\(except\|finally\)$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2751
diff changeset
218 return indnt - shiftwidth()
391
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
219 endif
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
220
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
221 if this_codeline =~ '^\s*\(private\|protected\|public\|published\)$'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 2751
diff changeset
222 return indnt - shiftwidth()
391
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
223 endif
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
224
2751
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
225
b0d34143ebfc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 391
diff changeset
226 " If nothing changed, return same indent.
391
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
227 return indnt
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
228 endfunction
289b19a6f2ed updated for version 7.0103
vimboss
parents: 333
diff changeset
229