Runtime files update
[MacVim.git] / runtime / ftplugin / ada.vim
bloba24ebfb458d82a5b541ddf41a1b3ee925450c243
1 "------------------------------------------------------------------------------
2 "  Description: Perform Ada specific completion & tagging.
3 "     Language: Ada (2005)
4 "          $Id: ada.vim,v 1.3 2007/05/05 17:17:45 vimboss Exp $
5 "   Maintainer: Martin Krischik
6 "               Neil Bird <neil@fnxweb.com>
7 "      $Author: vimboss $
8 "        $Date: 2007/05/05 17:17:45 $
9 "      Version: 4.2
10 "    $Revision: 1.3 $
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 "------------------------------------------------------------------------------
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
29    finish
30 endif
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
39 set cpoptions-=C
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>
54       endif
55       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
66 endif
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>
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
86 endif
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")
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\>'
105 endif
107 " Section: Compiler {{{1
109 if ! exists("current_compiler")                 ||
110    \ current_compiler != g:ada_default_compiler
111    execute "compiler " . g:ada_default_compiler
112 endif
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
126    endif
127    setlocal tabstop=8
128    setlocal softtabstop=3
129    setlocal shiftwidth=3
130 endif
132 " Section: Abbrev {{{1
134 if exists("g:ada_abbrev")
135    iabbrev ret  return
136    iabbrev proc procedure
137    iabbrev pack package
138    iabbrev func function
139 endif
141 " Section: Commands, Mapping, Menus {{{1
143 call ada#Map_Popup (
144    \ 'Tag.List',
145    \  'l',
146    \ 'call ada#List_Tag ()')
147 call ada#Map_Popup (
148    \'Tag.Jump',
149    \'j',
150    \'call ada#Jump_Tag ()')
151 call ada#Map_Menu (
152    \'Tag.Create File',
153    \':AdaTagFile',
154    \'call ada#Create_Tags (''file'')')
155 call ada#Map_Menu (
156    \'Tag.Create Dir',
157    \':AdaTagDir',
158    \'call ada#Create_Tags (''dir'')')
160 call ada#Map_Menu (
161    \'Highlight.Toggle Space Errors',
162    \ ':AdaSpaces',
163    \'call ada#Switch_Syntax_Option (''space_errors'')')
164 call ada#Map_Menu (
165    \'Highlight.Toggle Lines Errors',
166    \ ':AdaLines',
167    \'call ada#Switch_Syntax_Option (''line_errors'')')
168 call ada#Map_Menu (
169    \'Highlight.Toggle Rainbow Color',
170    \ ':AdaRainbow',
171    \'call ada#Switch_Syntax_Option (''rainbow_color'')')
172 call ada#Map_Menu (
173    \'Highlight.Toggle Standard Types',
174    \ ':AdaTypes',
175    \'call ada#Switch_Syntax_Option (''standard_types'')')
177 " 1}}}
178 " Reset cpoptions
179 let &cpoptions = s:cpoptions
180 unlet s:cpoptions
182 finish " 1}}}
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