1 "------------------------------------------------------------------------------
2 " Description: Perform Ada specific completion & tagging.
4 " $Id: ada.vim,v 1.6 2007/05/12 13:11:20 vimboss Exp $
5 " Maintainer: Martin Krischik
6 " Neil Bird <neil@fnxweb.com>
8 " $Date: 2007/05/12 13:11:20 $
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
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 "------------------------------------------------------------------------------
27 " Only do this when not done yet for this buffer
28 if exists ("b:did_ftplugin") || version < 700
32 " Don't load another plugin for this buffer
33 let b:did_ftplugin = 38
36 " Temporarily set cpoptions to ensure the script loads OK
38 let s:cpoptions = &cpoptions
41 " Section: Comments {{{1
43 setlocal comments=O:--,:--\ \
44 setlocal commentstring=--\ \ %s
45 setlocal complete=.,w,b,u,t,i
47 " Section: Tagging {{{1
49 if 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>
55 if mapcheck('g<C-]>','n') == ''
56 nnoremap <unique> <buffer> g<C-]> :call ada#Jump_Tag ('','stjump')<cr>
58 elseif g:ada_extended_tagging == 'list'
59 if mapcheck('<C-]>','n') == ''
60 nnoremap <unique> <buffer> <C-]> :call ada#List_Tag ()<cr>
62 if mapcheck('g<C-]>','n') == ''
63 nnoremap <unique> <buffer> g<C-]> :call ada#List_Tag ()<cr>
68 " Section: Completion {{{1
70 setlocal completefunc=ada#User_Complete
71 setlocal omnifunc=adacomplete#Complete
73 if 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>
77 if mapcheck ('<C-P>','i') == ''
78 inoremap <unique> <buffer> <C-P> <C-R>=ada#Completion("\<lt>C-P>")<cr>
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>
83 if mapcheck ('<bs>','i') == ''
84 inoremap <silent> <unique> <buffer> <bs> <C-R>=ada#Insert_Backspace ()<cr>
88 " Section: Matchit {{{1
90 " Only do this when not done yet for this buffer & matchit is used
92 if !exists ("b:match_words") &&
93 \ exists ("loaded_matchit")
95 " The following lines enable the macros/matchit.vim plugin for
96 " Ada-specific extended matching with the % key.
98 let s:notend = '\%(\<end\s\+\)\@<!'
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\>'
107 " Section: Compiler {{{1
109 if ! exists("current_compiler") ||
110 \ current_compiler != g:ada_default_compiler
111 execute "compiler " . g:ada_default_compiler
114 " Section: Folding {{{1
116 if 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
128 setlocal softtabstop=3
129 setlocal shiftwidth=3
132 " Section: Abbrev {{{1
134 if exists("g:ada_abbrev")
136 iabbrev proc procedure
138 iabbrev func function
141 " Section: Commands, Mapping, Menus {{{1
146 \ 'call ada#List_Tag ()')
150 \'call ada#Jump_Tag ()')
154 \'call ada#Create_Tags (''file'')')
158 \'call ada#Create_Tags (''dir'')')
161 \'Highlight.Toggle Space Errors',
163 \'call ada#Switch_Syntax_Option (''space_errors'')')
165 \'Highlight.Toggle Lines Errors',
167 \'call ada#Switch_Syntax_Option (''line_errors'')')
169 \'Highlight.Toggle Rainbow Color',
171 \'call ada#Switch_Syntax_Option (''rainbow_color'')')
173 \'Highlight.Toggle Standard Types',
175 \'call ada#Switch_Syntax_Option (''standard_types'')')
179 let &cpoptions = s:cpoptions
184 "------------------------------------------------------------------------------
185 " Copyright (C) 2006 Martin Krischik
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