1 "------------------------------------------------------------------------------
2 " Description: Perform Ada specific completion & tagging.
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>
9 " $Date: 2008-07-08 16:29:01 +0200 (Di, 08 Jul 2008) $
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
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 "------------------------------------------------------------------------------
29 " Only do this when not done yet for this buffer
30 if exists ("b:did_ftplugin") || version < 700
34 " Don't load another plugin for this buffer
35 let b:did_ftplugin = 45
38 " Temporarily set cpoptions to ensure the script loads OK
40 let s:cpoptions = &cpoptions
43 " Section: Comments {{{1
45 setlocal comments=O:--,:--\ \
46 setlocal commentstring=--\ \ %s
47 setlocal complete=.,w,b,u,t,i
54 " Section: formatoptions {{{1
56 setlocal formatoptions+=ron
58 " Section: Tagging {{{1
60 if 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>
66 if mapcheck('g<C-]>','n') == ''
67 nnoremap <unique> <buffer> g<C-]> :call ada#Jump_Tag ('','stjump')<cr>
69 elseif g:ada_extended_tagging == 'list'
70 if mapcheck('<C-]>','n') == ''
71 nnoremap <unique> <buffer> <C-]> :call ada#List_Tag ()<cr>
73 if mapcheck('g<C-]>','n') == ''
74 nnoremap <unique> <buffer> g<C-]> :call ada#List_Tag ()<cr>
79 " Section: Completion {{{1
81 setlocal completefunc=ada#User_Complete
82 setlocal omnifunc=adacomplete#Complete
84 if 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>
88 if mapcheck ('<C-P>','i') == ''
89 inoremap <unique> <buffer> <C-P> <C-R>=ada#Completion("\<lt>C-P>")<cr>
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>
94 if mapcheck ('<bs>','i') == ''
95 inoremap <silent> <unique> <buffer> <bs> <C-R>=ada#Insert_Backspace ()<cr>
99 " Section: Matchit {{{1
101 " Only do this when not done yet for this buffer & matchit is used
103 if !exists ("b:match_words") &&
104 \ exists ("loaded_matchit")
106 " The following lines enable the macros/matchit.vim plugin for
107 " Ada-specific extended matching with the % key.
109 let s:notend = '\%(\<end\s\+\)\@<!'
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\>'
119 " Section: Compiler {{{1
121 if ! exists("g:ada_default_compiler")
123 let g:ada_default_compiler = 'decada'
125 let g:ada_default_compiler = 'gnat'
129 if ! exists("current_compiler") ||
130 \ current_compiler != g:ada_default_compiler
131 execute "compiler " . g:ada_default_compiler
134 " Section: Folding {{{1
136 if 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
148 setlocal softtabstop=3
149 setlocal shiftwidth=3
152 " Section: Abbrev {{{1
154 if exists("g:ada_abbrev")
156 iabbrev proc procedure
158 iabbrev func function
161 " Section: Commands, Mapping, Menus {{{1
166 \ 'call ada#List_Tag ()')
170 \'call ada#Jump_Tag ()')
174 \'call ada#Create_Tags (''file'')')
178 \'call ada#Create_Tags (''dir'')')
181 \'Highlight.Toggle Space Errors',
183 \'call ada#Switch_Syntax_Option (''space_errors'')')
185 \'Highlight.Toggle Lines Errors',
187 \'call ada#Switch_Syntax_Option (''line_errors'')')
189 \'Highlight.Toggle Rainbow Color',
191 \'call ada#Switch_Syntax_Option (''rainbow_color'')')
193 \'Highlight.Toggle Standard Types',
195 \'call ada#Switch_Syntax_Option (''standard_types'')')
199 let &cpoptions = s:cpoptions
204 "------------------------------------------------------------------------------
205 " Copyright (C) 2006 Martin Krischik
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