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