ada.vim 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. "------------------------------------------------------------------------------
  2. " Description: Perform Ada specific completion & tagging.
  3. " Language: Ada (2005)
  4. " $Id: ada.vim 887 2008-07-08 14:29:01Z krischik $
  5. " Maintainer: Martin Krischik <krischik@users.sourceforge.net>
  6. " Taylor Venable <taylor@metasyntax.net>
  7. " Neil Bird <neil@fnxweb.com>
  8. " $Author: krischik $
  9. " $Date: 2008-07-08 16:29:01 +0200 (Di, 08 Jul 2008) $
  10. " Version: 4.6 with patch from David Bürgin
  11. " $Revision: 887 $
  12. " $HeadURL: https://gnuada.svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/ftplugin/ada.vim $
  13. " History: 24.05.2006 MK Unified Headers
  14. " 26.05.2006 MK ' should not be in iskeyword.
  15. " 16.07.2006 MK Ada-Mode as vim-ball
  16. " 02.10.2006 MK Better folding.
  17. " 15.10.2006 MK Bram's suggestion for runtime integration
  18. " 05.11.2006 MK Bram suggested not to use include protection for
  19. " autoload
  20. " 05.11.2006 MK Bram suggested to save on spaces
  21. " 08.07.2007 TV fix default compiler problems.
  22. " Help Page: ft-ada-plugin
  23. "------------------------------------------------------------------------------
  24. " Provides mapping overrides for tag jumping that figure out the current
  25. " Ada object and tag jump to that, not the 'simple' vim word.
  26. " Similarly allows <Ctrl-N> matching of full-length ada entities from tags.
  27. "------------------------------------------------------------------------------
  28. " Only do this when not done yet for this buffer
  29. if exists ("b:did_ftplugin") || version < 700
  30. finish
  31. endif
  32. " Don't load another plugin for this buffer
  33. let b:did_ftplugin = 45
  34. "
  35. " Temporarily set cpoptions to ensure the script loads OK
  36. "
  37. let s:cpoptions = &cpoptions
  38. set cpoptions-=C
  39. " Section: Comments {{{1
  40. "
  41. setlocal comments=O:--,:--\ \
  42. setlocal commentstring=--\ \ %s
  43. setlocal complete=.,w,b,u,t,i
  44. " Section: case {{{1
  45. "
  46. setlocal nosmartcase
  47. setlocal ignorecase
  48. " Section: formatoptions {{{1
  49. "
  50. setlocal formatoptions+=ron
  51. " Section: Tagging {{{1
  52. "
  53. if exists ("g:ada_extended_tagging")
  54. " Make local tag mappings for this buffer (if not already set)
  55. if g:ada_extended_tagging == 'jump'
  56. if mapcheck('<C-]>','n') == ''
  57. nnoremap <unique> <buffer> <C-]> :call ada#Jump_Tag ('', 'tjump')<cr>
  58. endif
  59. if mapcheck('g<C-]>','n') == ''
  60. nnoremap <unique> <buffer> g<C-]> :call ada#Jump_Tag ('','stjump')<cr>
  61. endif
  62. elseif g:ada_extended_tagging == 'list'
  63. if mapcheck('<C-]>','n') == ''
  64. nnoremap <unique> <buffer> <C-]> :call ada#List_Tag ()<cr>
  65. endif
  66. if mapcheck('g<C-]>','n') == ''
  67. nnoremap <unique> <buffer> g<C-]> :call ada#List_Tag ()<cr>
  68. endif
  69. endif
  70. endif
  71. " Section: Completion {{{1
  72. "
  73. setlocal completefunc=ada#User_Complete
  74. setlocal omnifunc=adacomplete#Complete
  75. if exists ("g:ada_extended_completion")
  76. if mapcheck ('<C-N>','i') == ''
  77. inoremap <unique> <buffer> <C-N> <C-R>=ada#Completion("\<lt>C-N>")<cr>
  78. endif
  79. if mapcheck ('<C-P>','i') == ''
  80. inoremap <unique> <buffer> <C-P> <C-R>=ada#Completion("\<lt>C-P>")<cr>
  81. endif
  82. if mapcheck ('<C-X><C-]>','i') == ''
  83. inoremap <unique> <buffer> <C-X><C-]> <C-R>=<SID>ada#Completion("\<lt>C-X>\<lt>C-]>")<cr>
  84. endif
  85. if mapcheck ('<bs>','i') == ''
  86. inoremap <silent> <unique> <buffer> <bs> <C-R>=ada#Insert_Backspace ()<cr>
  87. endif
  88. endif
  89. " Section: Matchit {{{1
  90. "
  91. " Only do this when not done yet for this buffer & matchit is used
  92. "
  93. if !exists ("b:match_words") &&
  94. \ exists ("loaded_matchit")
  95. "
  96. " The following lines enable the macros/matchit.vim plugin for
  97. " Ada-specific extended matching with the % key.
  98. "
  99. let s:notend = '\%(\<end\s\+\)\@<!'
  100. let b:match_words =
  101. \ s:notend . '\<if\>:\<elsif\>:\<else\>:\<end\>\s\+\<if\>,' .
  102. \ s:notend . '\<case\>:\<when\>:\<end\>\s\+\<case\>,' .
  103. \ '\%(\<while\>.*\|\<for\>.*\|'.s:notend.'\)\<loop\>:\<end\>\s\+\<loop\>,' .
  104. \ '\%(\<do\>\|\<begin\>\):\<exception\>:\<end\>\s*\%($\|[;A-Z]\),' .
  105. \ s:notend . '\<record\>:\<end\>\s\+\<record\>'
  106. endif
  107. " Section: Compiler {{{1
  108. "
  109. if ! exists("g:ada_default_compiler")
  110. let g:ada_default_compiler = 'gnat'
  111. endif
  112. if ! exists("current_compiler") ||
  113. \ current_compiler != g:ada_default_compiler
  114. execute "compiler " . g:ada_default_compiler
  115. endif
  116. " Section: Folding {{{1
  117. "
  118. if exists("g:ada_folding")
  119. if g:ada_folding[0] == 'i'
  120. setlocal foldmethod=indent
  121. setlocal foldignore=--
  122. setlocal foldnestmax=5
  123. elseif g:ada_folding[0] == 'g'
  124. setlocal foldmethod=expr
  125. setlocal foldexpr=ada#Pretty_Print_Folding(v:lnum)
  126. elseif g:ada_folding[0] == 's'
  127. setlocal foldmethod=syntax
  128. endif
  129. setlocal tabstop=8
  130. setlocal softtabstop=3
  131. setlocal shiftwidth=3
  132. endif
  133. " Section: Abbrev {{{1
  134. "
  135. if exists("g:ada_abbrev")
  136. iabbrev ret return
  137. iabbrev proc procedure
  138. iabbrev pack package
  139. iabbrev func function
  140. endif
  141. " Section: Commands, Mapping, Menus {{{1
  142. "
  143. call ada#Map_Popup (
  144. \ 'Tag.List',
  145. \ 'l',
  146. \ 'call ada#List_Tag ()')
  147. call ada#Map_Popup (
  148. \'Tag.Jump',
  149. \'j',
  150. \'call ada#Jump_Tag ()')
  151. call ada#Map_Menu (
  152. \'Tag.Create File',
  153. \':AdaTagFile',
  154. \'call ada#Create_Tags (''file'')')
  155. call ada#Map_Menu (
  156. \'Tag.Create Dir',
  157. \':AdaTagDir',
  158. \'call ada#Create_Tags (''dir'')')
  159. call ada#Map_Menu (
  160. \'Highlight.Toggle Space Errors',
  161. \ ':AdaSpaces',
  162. \'call ada#Switch_Syntax_Option (''space_errors'')')
  163. call ada#Map_Menu (
  164. \'Highlight.Toggle Lines Errors',
  165. \ ':AdaLines',
  166. \'call ada#Switch_Syntax_Option (''line_errors'')')
  167. call ada#Map_Menu (
  168. \'Highlight.Toggle Rainbow Color',
  169. \ ':AdaRainbow',
  170. \'call ada#Switch_Syntax_Option (''rainbow_color'')')
  171. call ada#Map_Menu (
  172. \'Highlight.Toggle Standard Types',
  173. \ ':AdaTypes',
  174. \'call ada#Switch_Syntax_Option (''standard_types'')')
  175. " 1}}}
  176. " Reset cpoptions
  177. let &cpoptions = s:cpoptions
  178. unlet s:cpoptions
  179. finish " 1}}}
  180. "------------------------------------------------------------------------------
  181. " Copyright (C) 2006 Martin Krischik
  182. "
  183. " Vim is Charityware - see ":help license" or uganda.txt for licence details.
  184. "------------------------------------------------------------------------------
  185. " vim: textwidth=78 nowrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab
  186. " vim: foldmethod=marker