annotate runtime/indent/pascal.vim @ 18733:8c088288a96b

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