blob: 045645ddaf21ba33662705faaf623bde4922d50e [file] [log] [blame]
Bram Moolenaar9964e462007-05-05 17:54:07 +00001"------------------------------------------------------------------------------
2" Description: Perform Ada specific completion & tagging.
3" Language: Ada (2005)
4" $Id$
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>
8" $Author$
9" $Date$
Bram Moolenaarc236c162008-07-13 17:41:49 +000010" Version: 4.6
Bram Moolenaar9964e462007-05-05 17:54:07 +000011" $Revision$
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"
45setlocal comments=O:--,:--\ \
46setlocal 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
162"
163call ada#Map_Popup (
164 \ 'Tag.List',
165 \ 'l',
166 \ 'call ada#List_Tag ()')
167call ada#Map_Popup (
168 \'Tag.Jump',
169 \'j',
170 \'call ada#Jump_Tag ()')
171call ada#Map_Menu (
172 \'Tag.Create File',
173 \':AdaTagFile',
174 \'call ada#Create_Tags (''file'')')
175call ada#Map_Menu (
176 \'Tag.Create Dir',
177 \':AdaTagDir',
178 \'call ada#Create_Tags (''dir'')')
Bram Moolenaar071d4272004-06-13 20:20:40 +0000179
Bram Moolenaar9964e462007-05-05 17:54:07 +0000180call ada#Map_Menu (
181 \'Highlight.Toggle Space Errors',
182 \ ':AdaSpaces',
183 \'call ada#Switch_Syntax_Option (''space_errors'')')
184call ada#Map_Menu (
185 \'Highlight.Toggle Lines Errors',
186 \ ':AdaLines',
187 \'call ada#Switch_Syntax_Option (''line_errors'')')
188call ada#Map_Menu (
189 \'Highlight.Toggle Rainbow Color',
190 \ ':AdaRainbow',
191 \'call ada#Switch_Syntax_Option (''rainbow_color'')')
192call ada#Map_Menu (
193 \'Highlight.Toggle Standard Types',
194 \ ':AdaTypes',
195 \'call ada#Switch_Syntax_Option (''standard_types'')')
Bram Moolenaar071d4272004-06-13 20:20:40 +0000196
Bram Moolenaar9964e462007-05-05 17:54:07 +0000197" 1}}}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000198" Reset cpoptions
199let &cpoptions = s:cpoptions
200unlet s:cpoptions
201
Bram Moolenaar9964e462007-05-05 17:54:07 +0000202finish " 1}}}
203
204"------------------------------------------------------------------------------
205" Copyright (C) 2006 Martin Krischik
206"
207" Vim is Charityware - see ":help license" or uganda.txt for licence details.
208"------------------------------------------------------------------------------
209" vim: textwidth=78 nowrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab
210" vim: foldmethod=marker