1125
|
1 "----------------------------------------------------------------------------
|
|
2 " Description: Vim Ada syntax file
|
|
3 " Language: Ada (2005)
|
2034
|
4 " $Id: ada.vim 887 2008-07-08 14:29:01Z krischik $
|
1125
|
5 " Copyright: Copyright (C) 2006 Martin Krischik
|
|
6 " Maintainer: Martin Krischik
|
|
7 " David A. Wheeler <dwheeler@dwheeler.com>
|
|
8 " Simon Bradley <simon.bradley@pitechnology.com>
|
|
9 " Contributors: Preben Randhol.
|
2034
|
10 " $Author: krischik $
|
|
11 " $Date: 2008-07-08 16:29:01 +0200 (Di, 08 Jul 2008) $
|
1668
|
12 " Version: 4.6
|
2034
|
13 " $Revision: 887 $
|
1668
|
14 " $HeadURL: https://gnuada.svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/syntax/ada.vim $
|
1125
|
15 " http://www.dwheeler.com/vim
|
|
16 " History: 24.05.2006 MK Unified Headers
|
|
17 " 26.05.2006 MK ' should not be in iskeyword.
|
|
18 " 16.07.2006 MK Ada-Mode as vim-ball
|
|
19 " 02.10.2006 MK Better folding.
|
|
20 " 15.10.2006 MK Bram's suggestion for runtime integration
|
|
21 " 05.11.2006 MK Spell check for comments and strings only
|
|
22 " 05.11.2006 MK Bram suggested to save on spaces
|
|
23 " Help Page: help ft-ada-syntax
|
|
24 "------------------------------------------------------------------------------
|
|
25 " The formal spec of Ada 2005 (ARM) is the "Ada 2005 Reference Manual".
|
|
26 " For more Ada 2005 info, see http://www.gnuada.org and http://www.adapower.com.
|
|
27 "
|
|
28 " This vim syntax file works on vim 7.0 only and makes use of most of Voim 7.0
|
|
29 " advanced features.
|
|
30 "------------------------------------------------------------------------------
|
7
|
31
|
1125
|
32 if exists("b:current_syntax") || version < 700
|
|
33 finish
|
7
|
34 endif
|
|
35
|
1125
|
36 let b:current_syntax = "ada"
|
7
|
37
|
1125
|
38 " Section: Ada is entirely case-insensitive. {{{1
|
|
39 "
|
|
40 syntax case ignore
|
7
|
41
|
1125
|
42 " Section: Highlighting commands {{{1
|
|
43 "
|
|
44 " There are 72 reserved words in total in Ada2005. Some keywords are
|
|
45 " used in more than one way. For example:
|
7
|
46 " 1. "end" is a general keyword, but "end if" ends a Conditional.
|
|
47 " 2. "then" is a conditional, but "and then" is an operator.
|
1125
|
48 "
|
|
49 for b:Item in g:ada#Keywords
|
|
50 " Standard Exceptions (including I/O).
|
|
51 " We'll highlight the standard exceptions, similar to vim's Python mode.
|
|
52 " It's possible to redefine the standard exceptions as something else,
|
|
53 " but doing so is very bad practice, so simply highlighting them makes sense.
|
|
54 if b:Item['kind'] == "x"
|
|
55 execute "syntax keyword adaException " . b:Item['word']
|
|
56 endif
|
|
57 if b:Item['kind'] == "a"
|
|
58 execute 'syntax match adaAttribute "\V' . b:Item['word'] . '"'
|
|
59 endif
|
|
60 " We don't normally highlight types in package Standard
|
|
61 " (Integer, Character, Float, etc.). I don't think it looks good
|
|
62 " with the other type keywords, and many Ada programs define
|
|
63 " so many of their own types that it looks inconsistent.
|
|
64 " However, if you want this highlighting, turn on "ada_standard_types".
|
|
65 " For package Standard's definition, see ARM section A.1.
|
|
66 if b:Item['kind'] == "t" && exists ("g:ada_standard_types")
|
|
67 execute "syntax keyword adaBuiltinType " . b:Item['word']
|
|
68 endif
|
|
69 endfor
|
7
|
70
|
1125
|
71 " Section: others {{{1
|
|
72 "
|
|
73 syntax keyword adaLabel others
|
7
|
74
|
1125
|
75 " Section: Operatoren {{{1
|
|
76 "
|
|
77 syntax keyword adaOperator abs mod not rem xor
|
|
78 syntax match adaOperator "\<and\>"
|
|
79 syntax match adaOperator "\<and\s\+then\>"
|
|
80 syntax match adaOperator "\<or\>"
|
|
81 syntax match adaOperator "\<or\s\+else\>"
|
|
82 syntax match adaOperator "[-+*/<>&]"
|
|
83 syntax keyword adaOperator **
|
|
84 syntax match adaOperator "[/<>]="
|
|
85 syntax keyword adaOperator =>
|
|
86 syntax match adaOperator "\.\."
|
|
87 syntax match adaOperator "="
|
7
|
88
|
1125
|
89 " Section: <> {{{1
|
|
90 "
|
|
91 " Handle the box, <>, specially:
|
|
92 "
|
|
93 syntax keyword adaSpecial <>
|
7
|
94
|
1125
|
95 " Section: rainbow color {{{1
|
|
96 "
|
|
97 if exists("g:ada_rainbow_color")
|
|
98 syntax match adaSpecial "[:;.,]"
|
1668
|
99 call rainbow_parenthsis#LoadRound ()
|
|
100 call rainbow_parenthsis#Activate ()
|
1125
|
101 else
|
|
102 syntax match adaSpecial "[:;().,]"
|
7
|
103 endif
|
|
104
|
1125
|
105 " Section: := {{{1
|
|
106 "
|
7
|
107 " We won't map "adaAssignment" by default, but we need to map ":=" to
|
|
108 " something or the "=" inside it will be mislabelled as an operator.
|
|
109 " Note that in Ada, assignment (:=) is not considered an operator.
|
1125
|
110 "
|
|
111 syntax match adaAssignment ":="
|
7
|
112
|
1125
|
113 " Section: Numbers, including floating point, exponents, and alternate bases. {{{1
|
|
114 "
|
|
115 syntax match adaNumber "\<\d[0-9_]*\(\.\d[0-9_]*\)\=\([Ee][+-]\=\d[0-9_]*\)\=\>"
|
|
116 syntax match adaNumber "\<\d\d\=#\x[0-9A-Fa-f_]*\(\.\x[0-9A-Fa-f_]*\)\=#\([Ee][+-]\=\d[0-9_]*\)\="
|
7
|
117
|
1125
|
118 " Section: Identify leading numeric signs {{{1
|
|
119 "
|
|
120 " In "A-5" the "-" is an operator, " but in "A:=-5" the "-" is a sign. This
|
|
121 " handles "A3+-5" (etc.) correctly. " This assumes that if you put a
|
|
122 " don't put a space after +/- when it's used " as an operator, you won't
|
|
123 " put a space before it either -- which is true " in code I've seen.
|
|
124 "
|
|
125 syntax match adaSign "[[:space:]<>=(,|:;&*/+-][+-]\d"lc=1,hs=s+1,he=e-1,me=e-1
|
7
|
126
|
1125
|
127 " Section: Labels for the goto statement. {{{1
|
|
128 "
|
|
129 syntax region adaLabel start="<<" end=">>"
|
7
|
130
|
1125
|
131 " Section: Boolean Constants {{{1
|
7
|
132 " Boolean Constants.
|
1125
|
133 syntax keyword adaBoolean true false
|
7
|
134
|
1125
|
135 " Section: Warn C/C++ {{{1
|
|
136 "
|
7
|
137 " Warn people who try to use C/C++ notation erroneously:
|
1125
|
138 "
|
|
139 syntax match adaError "//"
|
|
140 syntax match adaError "/\*"
|
|
141 syntax match adaError "=="
|
7
|
142
|
|
143
|
1125
|
144 " Section: Space Errors {{{1
|
|
145 "
|
|
146 if exists("g:ada_space_errors")
|
|
147 if !exists("g:ada_no_trail_space_error")
|
|
148 syntax match adaSpaceError excludenl "\s\+$"
|
|
149 endif
|
|
150 if !exists("g:ada_no_tab_space_error")
|
|
151 syntax match adaSpaceError " \+\t"me=e-1
|
|
152 endif
|
|
153 if !exists("g:ada_all_tab_usage")
|
|
154 syntax match adaSpecial "\t"
|
|
155 endif
|
7
|
156 endif
|
|
157
|
1125
|
158 " Section: end {{{1
|
7
|
159 " Unless special ("end loop", "end if", etc.), "end" marks the end of a
|
|
160 " begin, package, task etc. Assiging it to adaEnd.
|
1668
|
161 syntax match adaEnd /\<end\>/
|
7
|
162
|
1125
|
163 syntax keyword adaPreproc pragma
|
|
164
|
|
165 syntax keyword adaRepeat exit for loop reverse while
|
|
166 syntax match adaRepeat "\<end\s\+loop\>"
|
7
|
167
|
1125
|
168 syntax keyword adaStatement accept delay goto raise requeue return
|
|
169 syntax keyword adaStatement terminate
|
|
170 syntax match adaStatement "\<abort\>"
|
7
|
171
|
1125
|
172 " Section: Handle Ada's record keywords. {{{1
|
|
173 "
|
7
|
174 " 'record' usually starts a structure, but "with null record;" does not,
|
|
175 " and 'end record;' ends a structure. The ordering here is critical -
|
|
176 " 'record;' matches a "with null record", so make it a keyword (this can
|
|
177 " match when the 'with' or 'null' is on a previous line).
|
|
178 " We see the "end" in "end record" before the word record, so we match that
|
|
179 " pattern as adaStructure (and it won't match the "record;" pattern).
|
1125
|
180 "
|
|
181 syntax match adaStructure "\<record\>" contains=adaRecord
|
|
182 syntax match adaStructure "\<end\s\+record\>" contains=adaRecord
|
|
183 syntax match adaKeyword "\<record;"me=e-1
|
7
|
184
|
1125
|
185 " Section: type classes {{{1
|
|
186 "
|
|
187 syntax keyword adaStorageClass abstract access aliased array at constant delta
|
|
188 syntax keyword adaStorageClass digits limited of private range tagged
|
|
189 syntax keyword adaStorageClass interface synchronized
|
|
190 syntax keyword adaTypedef subtype type
|
7
|
191
|
1125
|
192 " Section: Conditionals {{{1
|
|
193 "
|
|
194 " "abort" after "then" is a conditional of its own.
|
|
195 "
|
|
196 syntax match adaConditional "\<then\>"
|
|
197 syntax match adaConditional "\<then\s\+abort\>"
|
|
198 syntax match adaConditional "\<else\>"
|
|
199 syntax match adaConditional "\<end\s\+if\>"
|
|
200 syntax match adaConditional "\<end\s\+case\>"
|
|
201 syntax match adaConditional "\<end\s\+select\>"
|
|
202 syntax keyword adaConditional if case select
|
|
203 syntax keyword adaConditional elsif when
|
7
|
204
|
1125
|
205 " Section: other keywords {{{1
|
|
206 syntax match adaKeyword "\<is\>" contains=adaRecord
|
|
207 syntax keyword adaKeyword all do exception in new null out
|
|
208 syntax keyword adaKeyword separate until overriding
|
7
|
209
|
1125
|
210 " Section: begin keywords {{{1
|
|
211 "
|
7
|
212 " These keywords begin various constructs, and you _might_ want to
|
|
213 " highlight them differently.
|
1125
|
214 "
|
|
215 syntax keyword adaBegin begin body declare entry generic
|
|
216 syntax keyword adaBegin protected renames task
|
7
|
217
|
1125
|
218 syntax match adaBegin "\<function\>" contains=adaFunction
|
|
219 syntax match adaBegin "\<procedure\>" contains=adaProcedure
|
|
220 syntax match adaBegin "\<package\>" contains=adaPackage
|
7
|
221
|
1125
|
222 if exists("ada_with_gnat_project_files")
|
|
223 syntax keyword adaBegin project
|
|
224 endif
|
|
225
|
|
226 " Section: with, use {{{1
|
|
227 "
|
7
|
228 if exists("ada_withuse_ordinary")
|
1125
|
229 " Don't be fancy. Display "with" and "use" as ordinary keywords in all cases.
|
|
230 syntax keyword adaKeyword with use
|
7
|
231 else
|
1125
|
232 " Highlight "with" and "use" clauses like C's "#include" when they're used
|
|
233 " to reference other compilation units; otherwise they're ordinary keywords.
|
|
234 " If we have vim 6.0 or later, we'll use its advanced pattern-matching
|
|
235 " capabilities so that we won't match leading spaces.
|
|
236 syntax match adaKeyword "\<with\>"
|
|
237 syntax match adaKeyword "\<use\>"
|
|
238 syntax match adaBeginWith "^\s*\zs\(\(with\(\s\+type\)\=\)\|\(use\)\)\>" contains=adaInc
|
|
239 syntax match adaSemiWith ";\s*\zs\(\(with\(\s\+type\)\=\)\|\(use\)\)\>" contains=adaInc
|
|
240 syntax match adaInc "\<with\>" contained contains=NONE
|
|
241 syntax match adaInc "\<with\s\+type\>" contained contains=NONE
|
|
242 syntax match adaInc "\<use\>" contained contains=NONE
|
|
243 " Recognize "with null record" as a keyword (even the "record").
|
|
244 syntax match adaKeyword "\<with\s\+null\s\+record\>"
|
|
245 " Consider generic formal parameters of subprograms and packages as keywords.
|
|
246 syntax match adaKeyword ";\s*\zswith\s\+\(function\|procedure\|package\)\>"
|
|
247 syntax match adaKeyword "^\s*\zswith\s\+\(function\|procedure\|package\)\>"
|
|
248 endif
|
|
249
|
|
250 " Section: String and character constants. {{{1
|
|
251 "
|
|
252 syntax region adaString contains=@Spell start=+"+ skip=+""+ end=+"+
|
|
253 syntax match adaCharacter "'.'"
|
|
254
|
|
255 " Section: Todo (only highlighted in comments) {{{1
|
|
256 "
|
|
257 syntax keyword adaTodo contained TODO FIXME XXX NOTE
|
|
258
|
|
259 " Section: Comments. {{{1
|
|
260 "
|
|
261 syntax region adaComment
|
|
262 \ oneline
|
|
263 \ contains=adaTodo,adaLineError,@Spell
|
|
264 \ start="--"
|
|
265 \ end="$"
|
|
266
|
|
267 " Section: line errors {{{1
|
|
268 "
|
|
269 " Note: Line errors have become quite slow with Vim 7.0
|
|
270 "
|
|
271 if exists("g:ada_line_errors")
|
|
272 syntax match adaLineError "\(^.\{79}\)\@<=." contains=ALL containedin=ALL
|
|
273 endif
|
|
274
|
|
275 " Section: syntax folding {{{1
|
|
276 "
|
|
277 " Syntax folding is very tricky - for now I still suggest to use
|
|
278 " indent folding
|
|
279 "
|
|
280 if exists("g:ada_folding") && g:ada_folding[0] == 's'
|
|
281 if stridx (g:ada_folding, 'p') >= 0
|
|
282 syntax region adaPackage
|
|
283 \ start="\(\<package\s\+body\>\|\<package\>\)\s*\z(\k*\)"
|
|
284 \ end="end\s\+\z1\s*;"
|
|
285 \ keepend extend transparent fold contains=ALL
|
|
286 endif
|
|
287 if stridx (g:ada_folding, 'f') >= 0
|
|
288 syntax region adaProcedure
|
|
289 \ start="\<procedure\>\s*\z(\k*\)"
|
|
290 \ end="\<end\>\s\+\z1\s*;"
|
|
291 \ keepend extend transparent fold contains=ALL
|
|
292 syntax region adaFunction
|
|
293 \ start="\<procedure\>\s*\z(\k*\)"
|
|
294 \ end="end\s\+\z1\s*;"
|
|
295 \ keepend extend transparent fold contains=ALL
|
|
296 endif
|
|
297 if stridx (g:ada_folding, 'f') >= 0
|
|
298 syntax region adaRecord
|
|
299 \ start="\<is\s\+record\>"
|
|
300 \ end="\<end\s\+record\>"
|
|
301 \ keepend extend transparent fold contains=ALL
|
|
302 endif
|
|
303 endif
|
|
304
|
|
305 " Section: The default methods for highlighting. Can be overridden later. {{{1
|
|
306 "
|
|
307 highlight def link adaCharacter Character
|
|
308 highlight def link adaComment Comment
|
|
309 highlight def link adaConditional Conditional
|
|
310 highlight def link adaKeyword Keyword
|
|
311 highlight def link adaLabel Label
|
|
312 highlight def link adaNumber Number
|
|
313 highlight def link adaSign Number
|
|
314 highlight def link adaOperator Operator
|
|
315 highlight def link adaPreproc PreProc
|
|
316 highlight def link adaRepeat Repeat
|
|
317 highlight def link adaSpecial Special
|
|
318 highlight def link adaStatement Statement
|
|
319 highlight def link adaString String
|
|
320 highlight def link adaStructure Structure
|
|
321 highlight def link adaTodo Todo
|
|
322 highlight def link adaType Type
|
|
323 highlight def link adaTypedef Typedef
|
|
324 highlight def link adaStorageClass StorageClass
|
|
325 highlight def link adaBoolean Boolean
|
|
326 highlight def link adaException Exception
|
|
327 highlight def link adaAttribute Tag
|
|
328 highlight def link adaInc Include
|
|
329 highlight def link adaError Error
|
|
330 highlight def link adaSpaceError Error
|
|
331 highlight def link adaLineError Error
|
|
332 highlight def link adaBuiltinType Type
|
|
333 highlight def link adaAssignment Special
|
|
334
|
|
335 " Subsection: Begin, End {{{2
|
|
336 "
|
|
337 if exists ("ada_begin_preproc")
|
|
338 " This is the old default display:
|
|
339 highlight def link adaBegin PreProc
|
|
340 highlight def link adaEnd PreProc
|
|
341 else
|
|
342 " This is the new default display:
|
|
343 highlight def link adaBegin Keyword
|
|
344 highlight def link adaEnd Keyword
|
7
|
345 endif
|
|
346
|
|
347
|
|
348
|
1125
|
349 " Section: sync {{{1
|
|
350 "
|
|
351 " We don't need to look backwards to highlight correctly;
|
|
352 " this speeds things up greatly.
|
|
353 syntax sync minlines=1 maxlines=1
|
7
|
354
|
1125
|
355 finish " 1}}}
|
7
|
356
|
1125
|
357 "------------------------------------------------------------------------------
|
|
358 " Copyright (C) 2006 Martin Krischik
|
|
359 "
|
|
360 " Vim is Charityware - see ":help license" or uganda.txt for licence details.
|
|
361 "------------------------------------------------------------------------------
|
|
362 "vim: textwidth=78 nowrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab
|
|
363 "vim: foldmethod=marker
|