blob: a0621e1d130a9171ce53860553fc3dc0a2386400 [file] [log] [blame]
Bram Moolenaar9964e462007-05-05 17:54:07 +00001"------------------------------------------------------------------------------
2" Description: Perform Ada specific completion & tagging.
3" Language: Ada (2005)
Bram Moolenaar5c736222010-01-06 20:54:52 +01004" $Id: ada.vim 887 2008-07-08 14:29:01Z krischik $
Bram Moolenaarc236c162008-07-13 17:41:49 +00005" Maintainer: Martin Krischik <krischik@users.sourceforge.net>
6" Taylor Venable <taylor@metasyntax.net>
Bram Moolenaar9964e462007-05-05 17:54:07 +00007" Neil Bird <neil@fnxweb.com>
Bram Moolenaar5c736222010-01-06 20:54:52 +01008" $Author: krischik $
9" $Date: 2008-07-08 16:29:01 +0200 (Di, 08 Jul 2008) $
Bram Moolenaarbf884932013-04-05 22:26:15 +020010" Version: 4.6 with patch from David BΓΌrgin
Bram Moolenaar5c736222010-01-06 20:54:52 +010011" $Revision: 887 $
Bram Moolenaarc236c162008-07-13 17:41:49 +000012" $HeadURL: https://gnuada.svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/ftplugin/ada.vim $
Bram Moolenaar9964e462007-05-05 17:54:07 +000013" 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
Bram Moolenaarc236c162008-07-13 17:41:49 +000021" 08.07.2007 TV fix default compiler problems.
Bram Moolenaar9964e462007-05-05 17:54:07 +000022" Help Page: ft-ada-plugin
23"------------------------------------------------------------------------------
Bram Moolenaar071d4272004-06-13 20:20:40 +000024" 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.
Bram Moolenaar9964e462007-05-05 17:54:07 +000027"------------------------------------------------------------------------------
Bram Moolenaar071d4272004-06-13 20:20:40 +000028
Bram Moolenaar071d4272004-06-13 20:20:40 +000029" Only do this when not done yet for this buffer
Bram Moolenaar9964e462007-05-05 17:54:07 +000030if exists ("b:did_ftplugin") || version < 700
31 finish
Bram Moolenaar071d4272004-06-13 20:20:40 +000032endif
33
34" Don't load another plugin for this buffer
Bram Moolenaarc236c162008-07-13 17:41:49 +000035let b:did_ftplugin = 45
Bram Moolenaar071d4272004-06-13 20:20:40 +000036
Bram Moolenaar9964e462007-05-05 17:54:07 +000037"
Bram Moolenaar071d4272004-06-13 20:20:40 +000038" Temporarily set cpoptions to ensure the script loads OK
Bram Moolenaar9964e462007-05-05 17:54:07 +000039"
Bram Moolenaar071d4272004-06-13 20:20:40 +000040let s:cpoptions = &cpoptions
Bram Moolenaar9964e462007-05-05 17:54:07 +000041set cpoptions-=C
Bram Moolenaar071d4272004-06-13 20:20:40 +000042
Bram Moolenaarc236c162008-07-13 17:41:49 +000043" Section: Comments {{{1
Bram Moolenaar9964e462007-05-05 17:54:07 +000044"
Bram Moolenaarbf884932013-04-05 22:26:15 +020045setlocal comments=O:--,:--\ \
Bram Moolenaar9964e462007-05-05 17:54:07 +000046setlocal commentstring=--\ \ %s
47setlocal complete=.,w,b,u,t,i
Bram Moolenaar071d4272004-06-13 20:20:40 +000048
Bram Moolenaarc236c162008-07-13 17:41:49 +000049" Section: case {{{1
50"
51setlocal nosmartcase
52setlocal ignorecase
53
54" Section: formatoptions {{{1
55"
56setlocal formatoptions+=ron
57
Bram Moolenaar9964e462007-05-05 17:54:07 +000058" Section: Tagging {{{1
59"
60if exists ("g:ada_extended_tagging")
61 " Make local tag mappings for this buffer (if not already set)
62 if g:ada_extended_tagging == 'jump'
63 if mapcheck('<C-]>','n') == ''
64 nnoremap <unique> <buffer> <C-]> :call ada#Jump_Tag ('', 'tjump')<cr>
Bram Moolenaar071d4272004-06-13 20:20:40 +000065 endif
Bram Moolenaar9964e462007-05-05 17:54:07 +000066 if mapcheck('g<C-]>','n') == ''
67 nnoremap <unique> <buffer> g<C-]> :call ada#Jump_Tag ('','stjump')<cr>
68 endif
69 elseif g:ada_extended_tagging == 'list'
70 if mapcheck('<C-]>','n') == ''
71 nnoremap <unique> <buffer> <C-]> :call ada#List_Tag ()<cr>
72 endif
73 if mapcheck('g<C-]>','n') == ''
74 nnoremap <unique> <buffer> g<C-]> :call ada#List_Tag ()<cr>
75 endif
76 endif
77endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000078
Bram Moolenaar9964e462007-05-05 17:54:07 +000079" Section: Completion {{{1
80"
81setlocal completefunc=ada#User_Complete
82setlocal omnifunc=adacomplete#Complete
Bram Moolenaar071d4272004-06-13 20:20:40 +000083
Bram Moolenaar9964e462007-05-05 17:54:07 +000084if exists ("g:ada_extended_completion")
85 if mapcheck ('<C-N>','i') == ''
86 inoremap <unique> <buffer> <C-N> <C-R>=ada#Completion("\<lt>C-N>")<cr>
87 endif
88 if mapcheck ('<C-P>','i') == ''
89 inoremap <unique> <buffer> <C-P> <C-R>=ada#Completion("\<lt>C-P>")<cr>
90 endif
91 if mapcheck ('<C-X><C-]>','i') == ''
92 inoremap <unique> <buffer> <C-X><C-]> <C-R>=<SID>ada#Completion("\<lt>C-X>\<lt>C-]>")<cr>
93 endif
94 if mapcheck ('<bs>','i') == ''
95 inoremap <silent> <unique> <buffer> <bs> <C-R>=ada#Insert_Backspace ()<cr>
96 endif
97endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000098
Bram Moolenaar9964e462007-05-05 17:54:07 +000099" Section: Matchit {{{1
100"
101" Only do this when not done yet for this buffer & matchit is used
102"
103if !exists ("b:match_words") &&
104 \ exists ("loaded_matchit")
105 "
106 " The following lines enable the macros/matchit.vim plugin for
107 " Ada-specific extended matching with the % key.
108 "
109 let s:notend = '\%(\<end\s\+\)\@<!'
110 let b:match_words =
111 \ s:notend . '\<if\>:\<elsif\>:\<else\>:\<end\>\s\+\<if\>,' .
112 \ s:notend . '\<case\>:\<when\>:\<end\>\s\+\<case\>,' .
113 \ '\%(\<while\>.*\|\<for\>.*\|'.s:notend.'\)\<loop\>:\<end\>\s\+\<loop\>,' .
114 \ '\%(\<do\>\|\<begin\>\):\<exception\>:\<end\>\s*\%($\|[;A-Z]\),' .
115 \ s:notend . '\<record\>:\<end\>\s\+\<record\>'
116endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000117
Bram Moolenaarc236c162008-07-13 17:41:49 +0000118
Bram Moolenaar9964e462007-05-05 17:54:07 +0000119" Section: Compiler {{{1
120"
Bram Moolenaarc236c162008-07-13 17:41:49 +0000121if ! exists("g:ada_default_compiler")
122 if has("vms")
123 let g:ada_default_compiler = 'decada'
124 else
125 let g:ada_default_compiler = 'gnat'
126 endif
127endif
128
Bram Moolenaar9964e462007-05-05 17:54:07 +0000129if ! exists("current_compiler") ||
130 \ current_compiler != g:ada_default_compiler
131 execute "compiler " . g:ada_default_compiler
132endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000133
Bram Moolenaar9964e462007-05-05 17:54:07 +0000134" Section: Folding {{{1
135"
136if exists("g:ada_folding")
137 if g:ada_folding[0] == 'i'
138 setlocal foldmethod=indent
139 setlocal foldignore=--
140 setlocal foldnestmax=5
141 elseif g:ada_folding[0] == 'g'
142 setlocal foldmethod=expr
143 setlocal foldexpr=ada#Pretty_Print_Folding(v:lnum)
144 elseif g:ada_folding[0] == 's'
145 setlocal foldmethod=syntax
146 endif
147 setlocal tabstop=8
148 setlocal softtabstop=3
149 setlocal shiftwidth=3
150endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000151
Bram Moolenaar9964e462007-05-05 17:54:07 +0000152" Section: Abbrev {{{1
153"
154if exists("g:ada_abbrev")
155 iabbrev ret return
156 iabbrev proc procedure
157 iabbrev pack package
158 iabbrev func function
159endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000160
Bram Moolenaar9964e462007-05-05 17:54:07 +0000161" Section: Commands, Mapping, Menus {{{1
Bram Moolenaare0e39172021-01-25 21:14:57 +0100162if !exists(':AdaTagFile')
163 call ada#Map_Popup (
164 \ 'Tag.List',
165 \ 'l',
166 \ 'call ada#List_Tag ()')
167 call ada#Map_Popup (
168 \'Tag.Jump',
169 \'j',
170 \'call ada#Jump_Tag ()')
171 call ada#Map_Menu (
172 \'Tag.Create File',
173 \':AdaTagFile',
174 \'call ada#Create_Tags (''file'')')
175 call ada#Map_Menu (
176 \'Tag.Create Dir',
177 \':AdaTagDir',
178 \'call ada#Create_Tags (''dir'')')
Bram Moolenaar071d4272004-06-13 20:20:40 +0000179
Bram Moolenaare0e39172021-01-25 21:14:57 +0100180 call ada#Map_Menu (
181 \'Highlight.Toggle Space Errors',
182 \ ':AdaSpaces',
183 \'call ada#Switch_Syntax_Option (''space_errors'')')
184 call ada#Map_Menu (
185 \'Highlight.Toggle Lines Errors',
186 \ ':AdaLines',
187 \'call ada#Switch_Syntax_Option (''line_errors'')')
188 call ada#Map_Menu (
189 \'Highlight.Toggle Rainbow Color',
190 \ ':AdaRainbow',
191 \'call ada#Switch_Syntax_Option (''rainbow_color'')')
192 call ada#Map_Menu (
193 \'Highlight.Toggle Standard Types',
194 \ ':AdaTypes',
195 \'call ada#Switch_Syntax_Option (''standard_types'')')
196endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000197
Bram Moolenaar9964e462007-05-05 17:54:07 +0000198" 1}}}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000199" Reset cpoptions
200let &cpoptions = s:cpoptions
201unlet s:cpoptions
202
Bram Moolenaar9964e462007-05-05 17:54:07 +0000203finish " 1}}}
204
205"------------------------------------------------------------------------------
206" Copyright (C) 2006 Martin Krischik
207"
208" Vim is Charityware - see ":help license" or uganda.txt for licence details.
209"------------------------------------------------------------------------------
210" vim: textwidth=78 nowrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab
211" vim: foldmethod=marker