blob: 688cf97f70ab9a01512952461fe9da432fdb13e3 [file] [log] [blame]
Bram Moolenaar9964e462007-05-05 17:54:07 +00001"------------------------------------------------------------------------------
2" Description: Perform Ada specific completion & tagging.
3" Language: Ada (2005)
4" $Id$
5" Maintainer: Martin Krischik
6" Neil Bird <neil@fnxweb.com>
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"------------------------------------------------------------------------------
Bram Moolenaar071d4272004-06-13 20:20:40 +000022" 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.
Bram Moolenaar9964e462007-05-05 17:54:07 +000025"------------------------------------------------------------------------------
Bram Moolenaar071d4272004-06-13 20:20:40 +000026
Bram Moolenaar071d4272004-06-13 20:20:40 +000027" Only do this when not done yet for this buffer
Bram Moolenaar9964e462007-05-05 17:54:07 +000028if exists ("b:did_ftplugin") || version < 700
29 finish
Bram Moolenaar071d4272004-06-13 20:20:40 +000030endif
31
32" Don't load another plugin for this buffer
Bram Moolenaar9964e462007-05-05 17:54:07 +000033let b:did_ftplugin = 38
Bram Moolenaar071d4272004-06-13 20:20:40 +000034
Bram Moolenaar9964e462007-05-05 17:54:07 +000035"
Bram Moolenaar071d4272004-06-13 20:20:40 +000036" Temporarily set cpoptions to ensure the script loads OK
Bram Moolenaar9964e462007-05-05 17:54:07 +000037"
Bram Moolenaar071d4272004-06-13 20:20:40 +000038let s:cpoptions = &cpoptions
Bram Moolenaar9964e462007-05-05 17:54:07 +000039set cpoptions-=C
Bram Moolenaar071d4272004-06-13 20:20:40 +000040
Bram Moolenaar9964e462007-05-05 17:54:07 +000041" Section: Comments {{{1
42"
43setlocal comments=O:--,:--\ \
44setlocal commentstring=--\ \ %s
45setlocal complete=.,w,b,u,t,i
Bram Moolenaar071d4272004-06-13 20:20:40 +000046
Bram Moolenaar9964e462007-05-05 17:54:07 +000047" 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>
Bram Moolenaar071d4272004-06-13 20:20:40 +000054 endif
Bram Moolenaar9964e462007-05-05 17:54:07 +000055 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
Bram Moolenaar071d4272004-06-13 20:20:40 +000067
Bram Moolenaar9964e462007-05-05 17:54:07 +000068" Section: Completion {{{1
69"
70setlocal completefunc=ada#User_Complete
71setlocal omnifunc=adacomplete#Complete
Bram Moolenaar071d4272004-06-13 20:20:40 +000072
Bram Moolenaar9964e462007-05-05 17:54:07 +000073if 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
Bram Moolenaar071d4272004-06-13 20:20:40 +000087
Bram Moolenaar9964e462007-05-05 17:54:07 +000088" 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
Bram Moolenaar071d4272004-06-13 20:20:40 +0000106
Bram Moolenaar9964e462007-05-05 17:54:07 +0000107" Section: Compiler {{{1
108"
109if ! exists("current_compiler") ||
110 \ current_compiler != g:ada_default_compiler
111 execute "compiler " . g:ada_default_compiler
112endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000113
Bram Moolenaar9964e462007-05-05 17:54:07 +0000114" 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
Bram Moolenaar071d4272004-06-13 20:20:40 +0000131
Bram Moolenaar9964e462007-05-05 17:54:07 +0000132" 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
Bram Moolenaar071d4272004-06-13 20:20:40 +0000140
Bram Moolenaar9964e462007-05-05 17:54:07 +0000141" 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'')')
Bram Moolenaar071d4272004-06-13 20:20:40 +0000159
Bram Moolenaar9964e462007-05-05 17:54:07 +0000160call 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'')')
Bram Moolenaar071d4272004-06-13 20:20:40 +0000176
Bram Moolenaar9964e462007-05-05 17:54:07 +0000177" 1}}}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000178" Reset cpoptions
179let &cpoptions = s:cpoptions
180unlet s:cpoptions
181
Bram Moolenaar9964e462007-05-05 17:54:07 +0000182finish " 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