ft_ada.txt 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. *ft_ada.txt* For Vim version 9.0. Last change: 2022 Mar 13
  2. ADA FILE TYPE PLUG-INS REFERENCE MANUAL~
  3. ADA *ada.vim*
  4. 1. Syntax Highlighting |ft-ada-syntax|
  5. 2. File type Plug-in |ft-ada-plugin|
  6. 3. Omni Completion |ft-ada-omni|
  7. 3.1 Omni Completion with "gnat xref" |gnat-xref|
  8. 3.2 Omni Completion with "ctags" |ada-ctags|
  9. 4. Compiler Support |ada-compiler|
  10. 4.1 GNAT |compiler-gnat|
  11. 4.2 Dec Ada |compiler-decada|
  12. 5. References |ada-reference|
  13. 5.1 Options |ft-ada-options|
  14. 5.2 Commands |ft-ada-commands|
  15. 5.3 Variables |ft-ada-variables|
  16. 5.4 Constants |ft-ada-constants|
  17. 5.5 Functions |ft-ada-functions|
  18. 6. Extra Plug-ins |ada-extra-plugins|
  19. ==============================================================================
  20. 1. Syntax Highlighting ~
  21. *ft-ada-syntax*
  22. This mode is designed for the 2005 edition of Ada ("Ada 2005"), which includes
  23. support for objected-programming, protected types, and so on. It handles code
  24. written for the original Ada language ("Ada83", "Ada87", "Ada95") as well,
  25. though code which uses Ada 2005-only keywords will be wrongly colored (such
  26. code should be fixed anyway). For more information about Ada, see
  27. http://www.adapower.com.
  28. The Ada mode handles a number of situations cleanly.
  29. For example, it knows that the "-" in "-5" is a number, but the same character
  30. in "A-5" is an operator. Normally, a "with" or "use" clause referencing
  31. another compilation unit is coloured the same way as C's "#include" is coloured.
  32. If you have "Conditional" or "Repeat" groups coloured differently, then "end
  33. if" and "end loop" will be coloured as part of those respective groups.
  34. You can set these to different colours using vim's "highlight" command (e.g.,
  35. to change how loops are displayed, enter the command ":hi Repeat" followed by
  36. the colour specification; on simple terminals the colour specification
  37. ctermfg=White often shows well).
  38. There are several options you can select in this Ada mode. See |ft-ada-options|
  39. for a complete list.
  40. To enable them, assign a value to the option. For example, to turn one on:
  41. >
  42. > let g:ada_standard_types = 1
  43. >
  44. To disable them use ":unlet". Example:
  45. >
  46. > unlet g:ada_standard_types
  47. You can just use ":" and type these into the command line to set these
  48. temporarily before loading an Ada file. You can make these option settings
  49. permanent by adding the "let" command(s), without a colon, to your "~/.vimrc"
  50. file.
  51. Even on a slow (90Mhz) PC this mode works quickly, but if you find the
  52. performance unacceptable, turn on |g:ada_withuse_ordinary|.
  53. Syntax folding instructions (|fold-syntax|) are added when |g:ada_folding| is
  54. set.
  55. ==============================================================================
  56. 2. File type Plug-in ~
  57. *ft-ada-indent* *ft-ada-plugin*
  58. The Ada plug-in provides support for:
  59. - auto indenting (|indent.txt|)
  60. - insert completion (|i_CTRL-N|)
  61. - user completion (|i_CTRL-X_CTRL-U|)
  62. - tag searches (|tagsrch.txt|)
  63. - Quick Fix (|quickfix.txt|)
  64. - backspace handling (|'backspace'|)
  65. - comment handling (|'comments'|, |'commentstring'|)
  66. The plug-in only activates the features of the Ada mode whenever an Ada
  67. file is opened and adds Ada related entries to the main and pop-up menu.
  68. ==============================================================================
  69. 3. Omni Completion ~
  70. *ft-ada-omni*
  71. The Ada omni-completions (|i_CTRL-X_CTRL-O|) uses tags database created either
  72. by "gnat xref -v" or the "Universal Ctags" (https://ctags.io). The complete
  73. function will automatically detect which tool was used to create the tags
  74. file.
  75. ------------------------------------------------------------------------------
  76. 3.1 Omni Completion with "gnat xref" ~
  77. *gnat-xref*
  78. GNAT XREF uses the compiler internal information (ali-files) to produce the
  79. tags file. This has the advantage to be 100% correct and the option of deep
  80. nested analysis. However the code must compile, the generator is quite
  81. slow and the created tags file contains only the basic Ctags information for
  82. each entry - not enough for some of the more advanced Vim code browser
  83. plug-ins.
  84. NOTE: "gnat xref -v" is very tricky to use as it has almost no diagnostic
  85. output - If nothing is printed then usually the parameters are wrong.
  86. Here some important tips:
  87. 1) You need to compile your code first and use the "-aO" option to point to
  88. your .ali files.
  89. 2) "gnat xref -v ../Include/adacl.ads" won't work - use the "gnat xref -v
  90. -aI../Include adacl.ads" instead.
  91. 3) "gnat xref -v -aI../Include *.ad?" won't work - use "cd ../Include" and
  92. then "gnat xref -v *.ad?"
  93. 4) Project manager support is completely broken - don't even try "gnat xref
  94. -Padacl.gpr".
  95. 5) Vim is faster when the tags file is sorted - use "sort --unique
  96. --ignore-case --output=tags tags" .
  97. 6) Remember to insert "!_TAG_FILE_SORTED 2 %sort ui" as first line to mark
  98. the file assorted.
  99. ------------------------------------------------------------------------------
  100. 3.2 Omni Completion with "ctags"~
  101. *ada-ctags*
  102. Universal/Exuberant Ctags use their own multi-language code parser. The
  103. parser is quite fast, produces a lot of extra information and can run on files
  104. which currently do not compile.
  105. There are also lots of other Vim-tools which use Universal/Exuberant Ctags.
  106. Universal Ctags is preferred, Exuberant Ctags is no longer being developed.
  107. You will need to install Universal Ctags which is available from
  108. https://ctags.io
  109. The Ada parser for Universal/Exuberant Ctags is fairly new - don't expect
  110. complete support yet.
  111. ==============================================================================
  112. 4. Compiler Support ~
  113. *ada-compiler*
  114. The Ada mode supports more than one Ada compiler and will automatically load the
  115. compiler set in |g:ada_default_compiler| whenever an Ada source is opened. The
  116. provided compiler plug-ins are split into the actual compiler plug-in and a
  117. collection of support functions and variables. This allows the easy
  118. development of specialized compiler plug-ins fine tuned to your development
  119. environment.
  120. ------------------------------------------------------------------------------
  121. 4.1 GNAT ~
  122. *compiler-gnat*
  123. GNAT is the only free (beer and speech) Ada compiler available. There are
  124. several versions available which differ in the licence terms used.
  125. The GNAT compiler plug-in will perform a compile on pressing <F7> and then
  126. immediately shows the result. You can set the project file to be used by
  127. setting:
  128. >
  129. > call g:gnat.Set_Project_File ('my_project.gpr')
  130. Setting a project file will also create a Vim session (|views-sessions|) so -
  131. like with the GPS - opened files, window positions etc. will be remembered
  132. separately for all projects.
  133. *gnat_members*
  134. GNAT OBJECT ~
  135. *g:gnat.Make()*
  136. g:gnat.Make()
  137. Calls |g:gnat.Make_Command| and displays the result inside a
  138. |quickfix| window.
  139. *g:gnat.Pretty()*
  140. g:gnat.Pretty()
  141. Calls |g:gnat.Pretty_Program|
  142. *g:gnat.Find()*
  143. g:gnat.Find()
  144. Calls |g:gnat.Find_Program|
  145. *g:gnat.Tags()*
  146. g:gnat.Tags()
  147. Calls |g:gnat.Tags_Command|
  148. *g:gnat.Set_Project_File()*
  149. g:gnat.Set_Project_File([{file}])
  150. Set gnat project file and load associated session. An open
  151. project will be closed and the session written. If called
  152. without file name the file selector opens for selection of a
  153. project file. If called with an empty string then the project
  154. and associated session are closed.
  155. *g:gnat.Project_File*
  156. g:gnat.Project_File string
  157. Current project file.
  158. *g:gnat.Make_Command*
  159. g:gnat.Make_Command string
  160. External command used for |g:gnat.Make()| (|'makeprg'|).
  161. *g:gnat.Pretty_Program*
  162. g:gnat.Pretty_Program string
  163. External command used for |g:gnat.Pretty()|
  164. *g:gnat.Find_Program*
  165. g:gnat.Find_Program string
  166. External command used for |g:gnat.Find()|
  167. *g:gnat.Tags_Command*
  168. g:gnat.Tags_Command string
  169. External command used for |g:gnat.Tags()|
  170. *g:gnat.Error_Format*
  171. g:gnat.Error_Format string
  172. Error format (|'errorformat'|)
  173. ------------------------------------------------------------------------------
  174. 4.2 Dec Ada ~
  175. *compiler-hpada* *compiler-decada*
  176. *compiler-vaxada* *compiler-compaqada*
  177. Dec Ada (also known by - in chronological order - VAX Ada, Dec Ada, Compaq Ada
  178. and HP Ada) is a fairly dated Ada 83 compiler. Support is basic: <F7> will
  179. compile the current unit.
  180. The Dec Ada compiler expects the package name and not the file name to be
  181. passed as a parameter. The compiler plug-in supports the usual file name
  182. convention to convert the file into a unit name. Both '-' and '__' are allowed
  183. as separators.
  184. *decada_members*
  185. DEC ADA OBJECT ~
  186. *g:decada.Make()*
  187. g:decada.Make() function
  188. Calls |g:decada.Make_Command| and displays the result inside a
  189. |quickfix| window.
  190. *g:decada.Unit_Name()*
  191. g:decada.Unit_Name() function
  192. Get the Unit name for the current file.
  193. *g:decada.Make_Command*
  194. g:decada.Make_Command string
  195. External command used for |g:decada.Make()| (|'makeprg'|).
  196. *g:decada.Error_Format*
  197. g:decada.Error_Format string
  198. Error format (|'errorformat'|).
  199. ==============================================================================
  200. 5. References ~
  201. *ada-reference*
  202. ------------------------------------------------------------------------------
  203. 5.1 Options ~
  204. *ft-ada-options*
  205. *g:ada_standard_types*
  206. g:ada_standard_types bool (true when exists)
  207. Highlight types in package Standard (e.g., "Float").
  208. *g:ada_space_errors*
  209. *g:ada_no_trail_space_error*
  210. *g:ada_no_tab_space_error*
  211. *g:ada_all_tab_usage*
  212. g:ada_space_errors bool (true when exists)
  213. Highlight extraneous errors in spaces ...
  214. g:ada_no_trail_space_error
  215. - but ignore trailing spaces at the end of a line
  216. g:ada_no_tab_space_error
  217. - but ignore tabs after spaces
  218. g:ada_all_tab_usage
  219. - highlight all tab use
  220. *g:ada_line_errors*
  221. g:ada_line_errors bool (true when exists)
  222. Highlight lines which are too long. Note: This highlighting
  223. option is quite CPU intensive.
  224. *g:ada_rainbow_color*
  225. g:ada_rainbow_color bool (true when exists)
  226. Use rainbow colours for '(' and ')'. You need the
  227. rainbow_parenthesis for this to work.
  228. *g:ada_folding*
  229. g:ada_folding set ('sigpft')
  230. Use folding for Ada sources.
  231. 's': activate syntax folding on load
  232. 'p': fold packages
  233. 'f': fold functions and procedures
  234. 't': fold types
  235. 'c': fold conditionals
  236. 'g': activate gnat pretty print folding on load
  237. 'i': lone 'is' folded with line above
  238. 'b': lone 'begin' folded with line above
  239. 'p': lone 'private' folded with line above
  240. 'x': lone 'exception' folded with line above
  241. 'i': activate indent folding on load
  242. Note: Syntax folding is in an early (unusable) stage and
  243. indent or gnat pretty folding is suggested.
  244. For gnat pretty folding to work the following settings are
  245. suggested: -cl3 -M79 -c2 -c3 -c4 -A1 -A2 -A3 -A4 -A5
  246. For indent folding to work the following settings are
  247. suggested: shiftwidth=3 softtabstop=3
  248. *g:ada_abbrev*
  249. g:ada_abbrev bool (true when exists)
  250. Add some abbreviations. This feature is more or less superseded
  251. by the various completion methods.
  252. *g:ada_withuse_ordinary*
  253. g:ada_withuse_ordinary bool (true when exists)
  254. Show "with" and "use" as ordinary keywords (when used to
  255. reference other compilation units they're normally highlighted
  256. specially).
  257. *g:ada_begin_preproc*
  258. g:ada_begin_preproc bool (true when exists)
  259. Show all begin-like keywords using the colouring of C
  260. preprocessor commands.
  261. *g:ada_omni_with_keywords*
  262. g:ada_omni_with_keywords
  263. Add Keywords, Pragmas, Attributes to omni-completions
  264. (|compl-omni|). Note: You can always complete then with user
  265. completion (|i_CTRL-X_CTRL-U|).
  266. *g:ada_extended_tagging*
  267. g:ada_extended_tagging enum ('jump', 'list')
  268. use extended tagging, two options are available
  269. 'jump': use tjump to jump.
  270. 'list': add tags quick fix list.
  271. Normal tagging does not support function or operator
  272. overloading as these features are not available in C and
  273. tagging was originally developed for C.
  274. *g:ada_extended_completion*
  275. g:ada_extended_completion
  276. Uses extended completion for <C-N> and <C-R> completions
  277. (|i_CTRL-N|). In this mode the '.' is used as part of the
  278. identifier so that 'Object.Method' or 'Package.Procedure' are
  279. completed together.
  280. *g:ada_gnat_extensions*
  281. g:ada_gnat_extensions bool (true when exists)
  282. Support GNAT extensions.
  283. *g:ada_with_gnat_project_files*
  284. g:ada_with_gnat_project_files bool (true when exists)
  285. Add gnat project file keywords and Attributes.
  286. *g:ada_default_compiler*
  287. g:ada_default_compiler string
  288. set default compiler. Currently supported are 'gnat' and
  289. 'decada'.
  290. An "exists" type is a boolean considered true when the variable is defined and
  291. false when the variable is undefined. The value to which the variable is set
  292. makes no difference.
  293. ------------------------------------------------------------------------------
  294. 5.2 Commands ~
  295. *ft-ada-commands*
  296. :AdaRainbow *:AdaRainbow*
  297. Toggles rainbow colour (|g:ada_rainbow_color|) mode for
  298. '(' and ')'.
  299. :AdaLines *:AdaLines*
  300. Toggles line error (|g:ada_line_errors|) display.
  301. :AdaSpaces *:AdaSpaces*
  302. Toggles space error (|g:ada_space_errors|) display.
  303. :AdaTagDir *:AdaTagDir*
  304. Creates tags file for the directory of the current file.
  305. :AdaTagFile *:AdaTagFile*
  306. Creates tags file for the current file.
  307. :AdaTypes *:AdaTypes*
  308. Toggles standard types (|g:ada_standard_types|) colour.
  309. :GnatFind *:GnatFind*
  310. Calls |g:gnat.Find()|
  311. :GnatPretty *:GnatPretty*
  312. Calls |g:gnat.Pretty()|
  313. :GnatTags *:GnatTags*
  314. Calls |g:gnat.Tags()|
  315. ------------------------------------------------------------------------------
  316. 5.3 Variables ~
  317. *ft-ada-variables*
  318. *g:gnat*
  319. g:gnat object
  320. Control object which manages GNAT compiles. The object
  321. is created when the first Ada source code is loaded provided
  322. that |g:ada_default_compiler| is set to 'gnat'. See
  323. |gnat_members| for details.
  324. *g:decada*
  325. g:decada object
  326. Control object which manages Dec Ada compiles. The object
  327. is created when the first Ada source code is loaded provided
  328. that |g:ada_default_compiler| is set to 'decada'. See
  329. |decada_members| for details.
  330. ------------------------------------------------------------------------------
  331. 5.4 Constants ~
  332. *ft-ada-constants*
  333. All constants are locked. See |:lockvar| for details.
  334. *g:ada#WordRegex*
  335. g:ada#WordRegex string
  336. Regular expression to search for Ada words.
  337. *g:ada#DotWordRegex*
  338. g:ada#DotWordRegex string
  339. Regular expression to search for Ada words separated by dots.
  340. *g:ada#Comment*
  341. g:ada#Comment string
  342. Regular expression to search for Ada comments.
  343. *g:ada#Keywords*
  344. g:ada#Keywords list of dictionaries
  345. List of keywords, attributes etc. pp. in the format used by
  346. omni completion. See |complete-items| for details.
  347. *g:ada#Ctags_Kinds*
  348. g:ada#Ctags_Kinds dictionary of lists
  349. Dictionary of the various kinds of items which the Ada support
  350. for Ctags generates.
  351. ------------------------------------------------------------------------------
  352. 5.5 Functions ~
  353. *ft-ada-functions*
  354. ada#Word([{line}, {col}]) *ada#Word()*
  355. Return full name of Ada entity under the cursor (or at given
  356. line/column), stripping white space/newlines as necessary.
  357. ada#List_Tag([{line}, {col}]) *ada#Listtags()*
  358. List all occurrences of the Ada entity under the cursor (or at
  359. given line/column) inside the quick-fix window.
  360. ada#Jump_Tag ({ident}, {mode}) *ada#Jump_Tag()*
  361. List all occurrences of the Ada entity under the cursor (or at
  362. given line/column) in the tag jump list. Mode can either be
  363. 'tjump' or 'stjump'.
  364. ada#Create_Tags ({option}) *ada#Create_Tags()*
  365. Creates tag file using Ctags. The option can either be 'file'
  366. for the current file, 'dir' for the directory of the current
  367. file or a file name.
  368. gnat#Insert_Tags_Header() *gnat#Insert_Tags_Header()*
  369. Adds the tag file header (!_TAG_) information to the current
  370. file which are missing from the GNAT XREF output.
  371. ada#Switch_Syntax_Option ({option}) *ada#Switch_Syntax_Option()*
  372. Toggles highlighting options on or off. Used for the Ada menu.
  373. *gnat#New()*
  374. gnat#New ()
  375. Create a new gnat object. See |g:gnat| for details.
  376. ==============================================================================
  377. 6. Extra Plugins ~
  378. *ada-extra-plugins*
  379. You can optionally install the following extra plug-ins. They work well with
  380. Ada and enhance the ability of the Ada mode:
  381. backup.vim
  382. http://www.vim.org/scripts/script.php?script_id=1537
  383. Keeps as many backups as you like so you don't have to.
  384. rainbow_parenthsis.vim
  385. http://www.vim.org/scripts/script.php?script_id=1561
  386. Very helpful since Ada uses only '(' and ')'.
  387. nerd_comments.vim
  388. http://www.vim.org/scripts/script.php?script_id=1218
  389. Excellent commenting and uncommenting support for almost any
  390. programming language.
  391. matchit.vim
  392. http://www.vim.org/scripts/script.php?script_id=39
  393. '%' jumping for any language. The normal '%' jump only works for '{}'
  394. style languages. The Ada mode will set the needed search patterns.
  395. taglist.vim
  396. http://www.vim.org/scripts/script.php?script_id=273
  397. Source code explorer sidebar. There is a patch for Ada available.
  398. The GNU Ada Project distribution (http://gnuada.sourceforge.net) of Vim
  399. contains all of the above.
  400. ==============================================================================
  401. vim: textwidth=78 nowrap tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab
  402. vim: filetype=help