blob: b446faf17355a90dbc922aa3288c4273b869da37 [file] [log] [blame]
Bram Moolenaarb1c91982018-05-17 17:04:55 +02001*ft_ada.txt* For Vim version 8.1. Last change: 2010 Jul 20
Bram Moolenaar8c8de832008-06-24 22:58:06 +00002
3
4 ADA FILE TYPE PLUG-INS REFERENCE MANUAL~
5
6ADA *ada.vim*
7
81. Syntax Highlighting |ft-ada-syntax|
Bram Moolenaar24ea3ba2010-09-19 19:01:21 +020092. File type Plug-in |ft-ada-plugin|
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000103. Omni Completion |ft-ada-omni|
11 3.1 Omni Completion with "gnat xref" |gnat-xref|
12 3.2 Omni Completion with "ctags" |ada-ctags|
134. Compiler Support |ada-compiler|
14 4.1 GNAT |compiler-gnat|
Bram Moolenaar24ea3ba2010-09-19 19:01:21 +020015 4.2 Dec Ada |compiler-decada|
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000165. References |ada-reference|
17 5.1 Options |ft-ada-options|
Bram Moolenaar24ea3ba2010-09-19 19:01:21 +020018 5.2 Commands |ft-ada-commands|
19 5.3 Variables |ft-ada-variables|
20 5.4 Constants |ft-ada-constants|
21 5.5 Functions |ft-ada-functions|
226. Extra Plug-ins |ada-extra-plugins|
Bram Moolenaar8c8de832008-06-24 22:58:06 +000023
24==============================================================================
251. Syntax Highlighting ~
26 *ft-ada-syntax*
27
28This mode is designed for the 2005 edition of Ada ("Ada 2005"), which includes
29support for objected-programming, protected types, and so on. It handles code
30written for the original Ada language ("Ada83", "Ada87", "Ada95") as well,
31though code which uses Ada 2005-only keywords will be wrongly colored (such
32code should be fixed anyway). For more information about Ada, see
33http://www.adapower.com.
34
35The Ada mode handles a number of situations cleanly.
36
37For example, it knows that the "-" in "-5" is a number, but the same character
38in "A-5" is an operator. Normally, a "with" or "use" clause referencing
39another compilation unit is coloured the same way as C's "#include" is coloured.
40If you have "Conditional" or "Repeat" groups coloured differently, then "end
41if" and "end loop" will be coloured as part of those respective groups.
42
43You can set these to different colours using vim's "highlight" command (e.g.,
44to change how loops are displayed, enter the command ":hi Repeat" followed by
45the colour specification; on simple terminals the colour specification
46ctermfg=White often shows well).
47
Bram Moolenaar9855d6b2010-07-18 14:34:51 +020048There are several options you can select in this Ada mode. See |ft-ada-options|
Bram Moolenaar8c8de832008-06-24 22:58:06 +000049for a complete list.
50
51To enable them, assign a value to the option. For example, to turn one on:
52 >
53 > let g:ada_standard_types = 1
54>
55To disable them use ":unlet". Example:
56>
57 > unlet g:ada_standard_types
58
59You can just use ":" and type these into the command line to set these
60temporarily before loading an Ada file. You can make these option settings
61permanent by adding the "let" command(s), without a colon, to your "~/.vimrc"
62file.
63
64Even on a slow (90Mhz) PC this mode works quickly, but if you find the
65performance unacceptable, turn on |g:ada_withuse_ordinary|.
66
67Syntax folding instructions (|fold-syntax|) are added when |g:ada_folding| is
68set.
69
70==============================================================================
712. File type Plug-in ~
72 *ft-ada-indent* *ft-ada-plugin*
73
74The Ada plug-in provides support for:
75
76 - auto indenting (|indent.txt|)
77 - insert completion (|i_CTRL-N|)
78 - user completion (|i_CTRL-X_CTRL-U|)
79 - tag searches (|tagsrch.txt|)
80 - Quick Fix (|quickfix.txt|)
81 - backspace handling (|'backspace'|)
82 - comment handling (|'comments'|, |'commentstring'|)
83
84The plug-in only activates the features of the Ada mode whenever an Ada
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +010085file is opened and adds Ada related entries to the main and pop-up menu.
Bram Moolenaar8c8de832008-06-24 22:58:06 +000086
87==============================================================================
883. Omni Completion ~
89 *ft-ada-omni*
90
91The Ada omni-completions (|i_CTRL-X_CTRL-O|) uses tags database created either
92by "gnat xref -v" or the "exuberant Ctags (http://ctags.sourceforge.net). The
93complete function will automatically detect which tool was used to create the
94tags file.
95
96------------------------------------------------------------------------------
973.1 Omni Completion with "gnat xref" ~
98 *gnat-xref*
99
100GNAT XREF uses the compiler internal information (ali-files) to produce the
101tags file. This has the advantage to be 100% correct and the option of deep
102nested analysis. However the code must compile, the generator is quite
103slow and the created tags file contains only the basic Ctags information for
104each entry - not enough for some of the more advanced Vim code browser
105plug-ins.
106
107NOTE: "gnat xref -v" is very tricky to use as it has almost no diagnostic
108 output - If nothing is printed then usually the parameters are wrong.
109 Here some important tips:
110
1111) You need to compile your code first and use the "-aO" option to point to
112 your .ali files.
1132) "gnat xref -v ../Include/adacl.ads" won't work - use the "gnat xref -v
114 -aI../Include adacl.ads" instead.
1153) "gnat xref -v -aI../Include *.ad?" won't work - use "cd ../Include" and
116 then "gnat xref -v *.ad?"
1174) Project manager support is completely broken - don't even try "gnat xref
118 -Padacl.gpr".
Bram Moolenaar6aa8cea2017-06-05 14:44:35 +02001195) Vim is faster when the tags file is sorted - use "sort --unique
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000120 --ignore-case --output=tags tags" .
1216) Remember to insert "!_TAG_FILE_SORTED 2 %sort ui" as first line to mark
122 the file assorted.
123
124------------------------------------------------------------------------------
1253.2 Omni Completion with "ctags"~
126 *ada-ctags*
127
128Exuberant Ctags uses its own multi-language code parser. The parser is quite
129fast, produces a lot of extra information (hence the name "Exuberant Ctags")
130and can run on files which currently do not compile.
131
132There are also lots of other Vim-tools which use exuberant Ctags.
133
134You will need to install a version of the Exuberant Ctags which has Ada
135support patched in. Such a version is available from the GNU Ada Project
136(http://gnuada.sourceforge.net).
137
138The Ada parser for Exuberant Ctags is fairly new - don't expect complete
139support yet.
140
141==============================================================================
Bram Moolenaar24ea3ba2010-09-19 19:01:21 +02001424. Compiler Support ~
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000143 *ada-compiler*
144
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100145The Ada mode supports more than one Ada compiler and will automatically load the
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200146compiler set in |g:ada_default_compiler| whenever an Ada source is opened. The
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000147provided compiler plug-ins are split into the actual compiler plug-in and a
148collection of support functions and variables. This allows the easy
149development of specialized compiler plug-ins fine tuned to your development
150environment.
151
152------------------------------------------------------------------------------
1534.1 GNAT ~
154 *compiler-gnat*
155
156GNAT is the only free (beer and speech) Ada compiler available. There are
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100157several versions available which differ in the licence terms used.
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000158
159The GNAT compiler plug-in will perform a compile on pressing <F7> and then
160immediately shows the result. You can set the project file to be used by
161setting:
162 >
163 > call g:gnat.Set_Project_File ('my_project.gpr')
164
165Setting a project file will also create a Vim session (|views-sessions|) so -
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100166like with the GPS - opened files, window positions etc. will be remembered
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000167separately for all projects.
168
169 *gnat_members*
170GNAT OBJECT ~
171
172 *g:gnat.Make()*
173g:gnat.Make()
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200174 Calls |g:gnat.Make_Command| and displays the result inside a
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000175 |quickfix| window.
176
177 *g:gnat.Pretty()*
178g:gnat.Pretty()
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200179 Calls |g:gnat.Pretty_Program|
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000180
181 *g:gnat.Find()*
182g:gnat.Find()
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200183 Calls |g:gnat.Find_Program|
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000184
185 *g:gnat.Tags()*
186g:gnat.Tags()
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200187 Calls |g:gnat.Tags_Command|
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000188
189 *g:gnat.Set_Project_File()*
190g:gnat.Set_Project_File([{file}])
191 Set gnat project file and load associated session. An open
192 project will be closed and the session written. If called
193 without file name the file selector opens for selection of a
194 project file. If called with an empty string then the project
195 and associated session are closed.
196
197 *g:gnat.Project_File*
198g:gnat.Project_File string
199 Current project file.
200
201 *g:gnat.Make_Command*
202g:gnat.Make_Command string
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200203 External command used for |g:gnat.Make()| (|'makeprg'|).
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000204
205 *g:gnat.Pretty_Program*
206g:gnat.Pretty_Program string
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200207 External command used for |g:gnat.Pretty()|
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000208
209 *g:gnat.Find_Program*
210g:gnat.Find_Program string
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200211 External command used for |g:gnat.Find()|
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000212
213 *g:gnat.Tags_Command*
214g:gnat.Tags_Command string
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200215 External command used for |g:gnat.Tags()|
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000216
217 *g:gnat.Error_Format*
218g:gnat.Error_Format string
219 Error format (|'errorformat'|)
220
221------------------------------------------------------------------------------
2224.2 Dec Ada ~
223 *compiler-hpada* *compiler-decada*
224 *compiler-vaxada* *compiler-compaqada*
225
226Dec Ada (also known by - in chronological order - VAX Ada, Dec Ada, Compaq Ada
227and HP Ada) is a fairly dated Ada 83 compiler. Support is basic: <F7> will
228compile the current unit.
229
230The Dec Ada compiler expects the package name and not the file name to be
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100231passed as a parameter. The compiler plug-in supports the usual file name
232convention to convert the file into a unit name. Both '-' and '__' are allowed
233as separators.
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000234
235 *decada_members*
236DEC ADA OBJECT ~
237
238 *g:decada.Make()*
239g:decada.Make() function
Bram Moolenaarf91787c2010-07-17 12:47:16 +0200240 Calls |g:decada.Make_Command| and displays the result inside a
241 |quickfix| window.
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000242
243 *g:decada.Unit_Name()*
244g:decada.Unit_Name() function
245 Get the Unit name for the current file.
246
247 *g:decada.Make_Command*
248g:decada.Make_Command string
Bram Moolenaarf91787c2010-07-17 12:47:16 +0200249 External command used for |g:decada.Make()| (|'makeprg'|).
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000250
251 *g:decada.Error_Format*
252g:decada.Error_Format| string
253 Error format (|'errorformat'|).
254
255==============================================================================
2565. References ~
257 *ada-reference*
258
259------------------------------------------------------------------------------
2605.1 Options ~
261 *ft-ada-options*
262
263 *g:ada_standard_types*
264g:ada_standard_types bool (true when exists)
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100265 Highlight types in package Standard (e.g., "Float").
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000266
267 *g:ada_space_errors*
268 *g:ada_no_trail_space_error*
269 *g:ada_no_tab_space_error*
270 *g:ada_all_tab_usage*
271g:ada_space_errors bool (true when exists)
272 Highlight extraneous errors in spaces ...
273 g:ada_no_trail_space_error
274 - but ignore trailing spaces at the end of a line
275 g:ada_no_tab_space_error
276 - but ignore tabs after spaces
277 g:ada_all_tab_usage
278 - highlight all tab use
279
280 *g:ada_line_errors*
281g:ada_line_errors bool (true when exists)
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100282 Highlight lines which are too long. Note: This highlighting
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000283 option is quite CPU intensive.
284
285 *g:ada_rainbow_color*
286g:ada_rainbow_color bool (true when exists)
287 Use rainbow colours for '(' and ')'. You need the
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100288 rainbow_parenthesis for this to work.
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000289
290 *g:ada_folding*
291g:ada_folding set ('sigpft')
292 Use folding for Ada sources.
293 's': activate syntax folding on load
294 'p': fold packages
295 'f': fold functions and procedures
296 't': fold types
297 'c': fold conditionals
298 'g': activate gnat pretty print folding on load
299 'i': lone 'is' folded with line above
300 'b': lone 'begin' folded with line above
301 'p': lone 'private' folded with line above
302 'x': lone 'exception' folded with line above
303 'i': activate indent folding on load
304
305 Note: Syntax folding is in an early (unusable) stage and
306 indent or gnat pretty folding is suggested.
307
308 For gnat pretty folding to work the following settings are
309 suggested: -cl3 -M79 -c2 -c3 -c4 -A1 -A2 -A3 -A4 -A5
310
311 For indent folding to work the following settings are
312 suggested: shiftwidth=3 softtabstop=3
313
314 *g:ada_abbrev*
315g:ada_abbrev bool (true when exists)
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100316 Add some abbreviations. This feature is more or less superseded
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000317 by the various completion methods.
318
319 *g:ada_withuse_ordinary*
320g:ada_withuse_ordinary bool (true when exists)
321 Show "with" and "use" as ordinary keywords (when used to
322 reference other compilation units they're normally highlighted
323 specially).
324
325 *g:ada_begin_preproc*
326g:ada_begin_preproc bool (true when exists)
327 Show all begin-like keywords using the colouring of C
328 preprocessor commands.
329
330 *g:ada_omni_with_keywords*
331g:ada_omni_with_keywords
332 Add Keywords, Pragmas, Attributes to omni-completions
333 (|compl-omni|). Note: You can always complete then with user
334 completion (|i_CTRL-X_CTRL-U|).
335
336 *g:ada_extended_tagging*
337g:ada_extended_tagging enum ('jump', 'list')
338 use extended tagging, two options are available
339 'jump': use tjump to jump.
340 'list': add tags quick fix list.
341 Normal tagging does not support function or operator
342 overloading as these features are not available in C and
343 tagging was originally developed for C.
344
345 *g:ada_extended_completion*
346g:ada_extended_completion
347 Uses extended completion for <C-N> and <C-R> completions
348 (|i_CTRL-N|). In this mode the '.' is used as part of the
349 identifier so that 'Object.Method' or 'Package.Procedure' are
350 completed together.
351
352 *g:ada_gnat_extensions*
353g:ada_gnat_extensions bool (true when exists)
354 Support GNAT extensions.
355
356 *g:ada_with_gnat_project_files*
357g:ada_with_gnat_project_files bool (true when exists)
358 Add gnat project file keywords and Attributes.
359
360 *g:ada_default_compiler*
361g:ada_default_compiler string
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100362 set default compiler. Currently supported are 'gnat' and
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000363 'decada'.
364
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100365An "exists" type is a boolean considered true when the variable is defined and
366false when the variable is undefined. The value to which the variable is set
367makes no difference.
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000368
369------------------------------------------------------------------------------
Bram Moolenaar24ea3ba2010-09-19 19:01:21 +02003705.2 Commands ~
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000371 *ft-ada-commands*
372
373:AdaRainbow *:AdaRainbow*
374 Toggles rainbow colour (|g:ada_rainbow_color|) mode for
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100375 '(' and ')'.
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000376
377:AdaLines *:AdaLines*
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100378 Toggles line error (|g:ada_line_errors|) display.
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000379
380:AdaSpaces *:AdaSpaces*
381 Toggles space error (|g:ada_space_errors|) display.
382
383:AdaTagDir *:AdaTagDir*
384 Creates tags file for the directory of the current file.
385
386:AdaTagFile *:AdaTagFile*
387 Creates tags file for the current file.
388
389:AdaTypes *:AdaTypes*
390 Toggles standard types (|g:ada_standard_types|) colour.
391
392:GnatFind *:GnatFind*
393 Calls |g:gnat.Find()|
394
395:GnatPretty *:GnatPretty*
396 Calls |g:gnat.Pretty()|
397
398:GnatTags *:GnatTags*
399 Calls |g:gnat.Tags()|
400
401------------------------------------------------------------------------------
4025.3 Variables ~
403 *ft-ada-variables*
404
405 *g:gnat*
406g:gnat object
407 Control object which manages GNAT compiles. The object
408 is created when the first Ada source code is loaded provided
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200409 that |g:ada_default_compiler| is set to 'gnat'. See
Bram Moolenaarf91787c2010-07-17 12:47:16 +0200410 |gnat_members| for details.
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000411
412 *g:decada*
413g:decada object
414 Control object which manages Dec Ada compiles. The object
415 is created when the first Ada source code is loaded provided
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200416 that |g:ada_default_compiler| is set to 'decada'. See
417 |decada_members| for details.
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000418
419------------------------------------------------------------------------------
4205.4 Constants ~
421 *ft-ada-constants*
422
423All constants are locked. See |:lockvar| for details.
424
425 *g:ada#WordRegex*
426g:ada#WordRegex string
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100427 Regular expression to search for Ada words.
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000428
429 *g:ada#DotWordRegex*
430g:ada#DotWordRegex string
431 Regular expression to search for Ada words separated by dots.
432
433 *g:ada#Comment*
434g:ada#Comment string
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100435 Regular expression to search for Ada comments.
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000436
437 *g:ada#Keywords*
438g:ada#Keywords list of dictionaries
439 List of keywords, attributes etc. pp. in the format used by
440 omni completion. See |complete-items| for details.
441
442 *g:ada#Ctags_Kinds*
443g:ada#Ctags_Kinds dictionary of lists
444 Dictionary of the various kinds of items which the Ada support
445 for Ctags generates.
446
447------------------------------------------------------------------------------
Bram Moolenaar24ea3ba2010-09-19 19:01:21 +02004485.5 Functions ~
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000449 *ft-ada-functions*
450
451ada#Word([{line}, {col}]) *ada#Word()*
452 Return full name of Ada entity under the cursor (or at given
453 line/column), stripping white space/newlines as necessary.
454
455ada#List_Tag([{line}, {col}]) *ada#Listtags()*
456 List all occurrences of the Ada entity under the cursor (or at
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100457 given line/column) inside the quick-fix window.
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000458
459ada#Jump_Tag ({ident}, {mode}) *ada#Jump_Tag()*
460 List all occurrences of the Ada entity under the cursor (or at
461 given line/column) in the tag jump list. Mode can either be
462 'tjump' or 'stjump'.
463
464ada#Create_Tags ({option}) *ada#Create_Tags()*
465 Creates tag file using Ctags. The option can either be 'file'
466 for the current file, 'dir' for the directory of the current
467 file or a file name.
468
469gnat#Insert_Tags_Header() *gnat#Insert_Tags_Header()*
470 Adds the tag file header (!_TAG_) information to the current
471 file which are missing from the GNAT XREF output.
472
473ada#Switch_Syntax_Option ({option}) *ada#Switch_Syntax_Option()*
474 Toggles highlighting options on or off. Used for the Ada menu.
475
476 *gnat#New()*
477gnat#New ()
478 Create a new gnat object. See |g:gnat| for details.
479
480
481==============================================================================
Bram Moolenaar24ea3ba2010-09-19 19:01:21 +02004826. Extra Plugins ~
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000483 *ada-extra-plugins*
484
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100485You can optionally install the following extra plug-ins. They work well with
486Ada and enhance the ability of the Ada mode:
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000487
488backup.vim
489 http://www.vim.org/scripts/script.php?script_id=1537
490 Keeps as many backups as you like so you don't have to.
491
492rainbow_parenthsis.vim
493 http://www.vim.org/scripts/script.php?script_id=1561
494 Very helpful since Ada uses only '(' and ')'.
495
496nerd_comments.vim
497 http://www.vim.org/scripts/script.php?script_id=1218
498 Excellent commenting and uncommenting support for almost any
499 programming language.
500
501matchit.vim
502 http://www.vim.org/scripts/script.php?script_id=39
503 '%' jumping for any language. The normal '%' jump only works for '{}'
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100504 style languages. The Ada mode will set the needed search patterns.
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000505
506taglist.vim
507 http://www.vim.org/scripts/script.php?script_id=273
508 Source code explorer sidebar. There is a patch for Ada available.
509
510The GNU Ada Project distribution (http://gnuada.sourceforge.net) of Vim
511contains all of the above.
512
513==============================================================================
514vim: textwidth=78 nowrap tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab
515vim: filetype=help