1125
|
1 "------------------------------------------------------------------------------
|
|
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/autoload/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-functions
|
|
21 "------------------------------------------------------------------------------
|
|
22
|
|
23 if version < 700
|
|
24 finish
|
|
25 endif
|
|
26
|
|
27 " Section: Constants {{{1
|
|
28 "
|
|
29 let g:ada#DotWordRegex = '\a\w*\(\_s*\.\_s*\a\w*\)*'
|
|
30 let g:ada#WordRegex = '\a\w*'
|
|
31 let g:ada#Comment = "\\v^(\"[^\"]*\"|'.'|[^\"']){-}\\zs\\s*--.*"
|
|
32 let g:ada#Keywords = []
|
|
33
|
|
34 " Section: g:ada#Keywords {{{1
|
|
35 "
|
|
36 " Section: add Ada keywords {{{2
|
|
37 "
|
|
38 for Item in ['abort', 'else', 'new', 'return', 'abs', 'elsif', 'not', 'reverse', 'abstract', 'end', 'null', 'accept', 'entry', 'select', 'access', 'exception', 'of', 'separate', 'aliased', 'exit', 'or', 'subtype', 'all', 'others', 'synchronized', 'and', 'for', 'out', 'array', 'function', 'overriding', 'tagged', 'at', 'task', 'generic', 'package', 'terminate', 'begin', 'goto', 'pragma', 'then', 'body', 'private', 'type', 'if', 'procedure', 'case', 'in', 'protected', 'until', 'constant', 'interface', 'use', 'is', 'raise', 'declare', 'range', 'when', 'delay', 'limited', 'record', 'while', 'delta', 'loop', 'rem', 'with', 'digits', 'renames', 'do', 'mod', 'requeue', 'xor']
|
|
39 let g:ada#Keywords += [{
|
|
40 \ 'word': Item,
|
|
41 \ 'menu': 'keyword',
|
|
42 \ 'info': 'Ada keyword.',
|
|
43 \ 'kind': 'k',
|
|
44 \ 'icase': 1}]
|
|
45 endfor
|
|
46
|
|
47 " Section: GNAT Project Files {{{3
|
|
48 "
|
|
49 if exists ('g:ada_with_gnat_project_files')
|
|
50 for Item in ['project']
|
|
51 let g:ada#Keywords += [{
|
|
52 \ 'word': Item,
|
|
53 \ 'menu': 'keyword',
|
|
54 \ 'info': 'GNAT projectfile keyword.',
|
|
55 \ 'kind': 'k',
|
|
56 \ 'icase': 1}]
|
|
57 endfor
|
|
58 endif
|
|
59
|
|
60 " Section: add standart exception {{{2
|
|
61 "
|
|
62 for Item in ['Constraint_Error', 'Program_Error', 'Storage_Error', 'Tasking_Error', 'Status_Error', 'Mode_Error', 'Name_Error', 'Use_Error', 'Device_Error', 'End_Error', 'Data_Error', 'Layout_Error', 'Length_Error', 'Pattern_Error', 'Index_Error', 'Translation_Error', 'Time_Error', 'Argument_Error', 'Tag_Error', 'Picture_Error', 'Terminator_Error', 'Conversion_Error', 'Pointer_Error', 'Dereference_Error', 'Update_Error']
|
|
63 let g:ada#Keywords += [{
|
|
64 \ 'word': Item,
|
|
65 \ 'menu': 'exception',
|
|
66 \ 'info': 'Ada standart exception.',
|
|
67 \ 'kind': 'x',
|
|
68 \ 'icase': 1}]
|
|
69 endfor
|
|
70
|
|
71 " Section: add GNAT exception {{{3
|
|
72 "
|
|
73 if exists ('g:ada_gnat_extensions')
|
|
74 for Item in ['Assert_Failure']
|
|
75 let g:ada#Keywords += [{
|
|
76 \ 'word': Item,
|
|
77 \ 'menu': 'exception',
|
|
78 \ 'info': 'GNAT exception.',
|
|
79 \ 'kind': 'x',
|
|
80 \ 'icase': 1}]
|
|
81 endfor
|
|
82 endif
|
|
83
|
|
84 " Section: add Ada buildin types {{{2
|
|
85 "
|
|
86 for Item in ['Boolean', 'Integer', 'Natural', 'Positive', 'Float', 'Character', 'Wide_Character', 'Wide_Wide_Character', 'String', 'Wide_String', 'Wide_Wide_String', 'Duration']
|
|
87 let g:ada#Keywords += [{
|
|
88 \ 'word': Item,
|
|
89 \ 'menu': 'type',
|
|
90 \ 'info': 'Ada buildin type.',
|
|
91 \ 'kind': 't',
|
|
92 \ 'icase': 1}]
|
|
93 endfor
|
|
94
|
|
95 " Section: add GNAT buildin types {{{3
|
|
96 "
|
|
97 if exists ('g:ada_gnat_extensions')
|
|
98 for Item in ['Short_Integer', 'Short_Short_Integer', 'Long_Integer', 'Long_Long_Integer', 'Short_Float', 'Short_Short_Float', 'Long_Float', 'Long_Long_Float']
|
|
99 let g:ada#Keywords += [{
|
|
100 \ 'word': Item,
|
|
101 \ 'menu': 'type',
|
|
102 \ 'info': 'GNAT buildin type.',
|
|
103 \ 'kind': 't',
|
|
104 \ 'icase': 1}]
|
|
105 endfor
|
|
106 endif
|
|
107
|
|
108 " Section: add Ada Attributes {{{2
|
|
109 "
|
|
110 for Item in ['''Access', '''Address', '''Adjacent', '''Aft', '''Alignment', '''Base', '''Bit_Order', '''Body_Version', '''Callable', '''Caller', '''Ceiling', '''Class', '''Component_Size', '''Compose', '''Constrained', '''Copy_Sign', '''Count', '''Definite', '''Delta', '''Denorm', '''Digits', '''Emax', '''Exponent', '''External_Tag', '''Epsilon', '''First', '''First_Bit', '''Floor', '''Fore', '''Fraction', '''Identity', '''Image', '''Input', '''Large', '''Last', '''Last_Bit', '''Leading_Part', '''Length', '''Machine', '''Machine_Emax', '''Machine_Emin', '''Machine_Mantissa', '''Machine_Overflows', '''Machine_Radix', '''Machine_Rounding', '''Machine_Rounds', '''Mantissa', '''Max', '''Max_Size_In_Storage_Elements', '''Min', '''Mod', '''Model', '''Model_Emin', '''Model_Epsilon', '''Model_Mantissa', '''Model_Small', '''Modulus', '''Output', '''Partition_ID', '''Pos', '''Position', '''Pred', '''Priority', '''Range', '''Read', '''Remainder', '''Round', '''Rounding', '''Safe_Emax', '''Safe_First', '''Safe_Large', '''Safe_Last', '''Safe_Small', '''Scale', '''Scaling', '''Signed_Zeros', '''Size', '''Small', '''Storage_Pool', '''Storage_Size', '''Stream_Size', '''Succ', '''Tag', '''Terminated', '''Truncation', '''Unbiased_Rounding', '''Unchecked_Access', '''Val', '''Valid', '''Value', '''Version', '''Wide_Image', '''Wide_Value', '''Wide_Wide_Image', '''Wide_Wide_Value', '''Wide_Wide_Width', '''Wide_Width', '''Width', '''Write']
|
|
111 let g:ada#Keywords += [{
|
|
112 \ 'word': Item,
|
|
113 \ 'menu': 'attribute',
|
|
114 \ 'info': 'Ada attribute.',
|
|
115 \ 'kind': 'a',
|
|
116 \ 'icase': 1}]
|
|
117 endfor
|
|
118
|
|
119 " Section: add GNAT Attributes {{{3
|
|
120 "
|
|
121 if exists ('g:ada_gnat_extensions')
|
|
122 for Item in ['''Abort_Signal', '''Address_Size', '''Asm_Input', '''Asm_Output', '''AST_Entry', '''Bit', '''Bit_Position', '''Code_Address', '''Default_Bit_Order', '''Elaborated', '''Elab_Body', '''Elab_Spec', '''Emax', '''Enum_Rep', '''Epsilon', '''Fixed_Value', '''Has_Access_Values', '''Has_Discriminants', '''Img', '''Integer_Value', '''Machine_Size', '''Max_Interrupt_Priority', '''Max_Priority', '''Maximum_Alignment', '''Mechanism_Code', '''Null_Parameter', '''Object_Size', '''Passed_By_Reference', '''Range_Length', '''Storage_Unit', '''Target_Name', '''Tick', '''To_Address', '''Type_Class', '''UET_Address', '''Unconstrained_Array', '''Universal_Literal_String', '''Unrestricted_Access', '''VADS_Size', '''Value_Size', '''Wchar_T_Size', '''Word_Size']
|
|
123 let g:ada#Keywords += [{
|
|
124 \ 'word': Item,
|
|
125 \ 'menu': 'attribute',
|
|
126 \ 'info': 'GNAT attribute.',
|
|
127 \ 'kind': 'a',
|
|
128 \ 'icase': 1}]
|
|
129 endfor
|
|
130 endif
|
|
131
|
|
132 " Section: add Ada Pragmas {{{2
|
|
133 "
|
|
134 for Item in ['All_Calls_Remote', 'Assert', 'Assertion_Policy', 'Asynchronous', 'Atomic', 'Atomic_Components', 'Attach_Handler', 'Controlled', 'Convention', 'Detect_Blocking', 'Discard_Names', 'Elaborate', 'Elaborate_All', 'Elaborate_Body', 'Export', 'Import', 'Inline', 'Inspection_Point', 'Interface (Obsolescent)', 'Interrupt_Handler', 'Interrupt_Priority', 'Linker_Options', 'List', 'Locking_Policy', 'Memory_Size (Obsolescent)', 'No_Return', 'Normalize_Scalars', 'Optimize', 'Pack', 'Page', 'Partition_Elaboration_Policy', 'Preelaborable_Initialization', 'Preelaborate', 'Priority', 'Priority_Specific_Dispatching', 'Profile', 'Pure', 'Queueing_Policy', 'Relative_Deadline', 'Remote_Call_Interface', 'Remote_Types', 'Restrictions', 'Reviewable', 'Shared (Obsolescent)', 'Shared_Passive', 'Storage_Size', 'Storage_Unit (Obsolescent)', 'Suppress', 'System_Name (Obsolescent)', 'Task_Dispatching_Policy', 'Unchecked_Union', 'Unsuppress', 'Volatile', 'Volatile_Components']
|
|
135 let g:ada#Keywords += [{
|
|
136 \ 'word': Item,
|
|
137 \ 'menu': 'pragma',
|
|
138 \ 'info': 'Ada pragma.',
|
|
139 \ 'kind': 'p',
|
|
140 \ 'icase': 1}]
|
|
141 endfor
|
|
142
|
|
143 " Section: add GNAT Pragmas {{{3
|
|
144 "
|
|
145 if exists ('g:ada_gnat_extensions')
|
|
146 for Item in ['Abort_Defer', 'Ada_83', 'Ada_95', 'Ada_05', 'Annotate', 'Ast_Entry', 'C_Pass_By_Copy', 'Comment', 'Common_Object', 'Compile_Time_Warning', 'Complex_Representation', 'Component_Alignment', 'Convention_Identifier', 'CPP_Class', 'CPP_Constructor', 'CPP_Virtual', 'CPP_Vtable', 'Debug', 'Elaboration_Checks', 'Eliminate', 'Export_Exception', 'Export_Function', 'Export_Object', 'Export_Procedure', 'Export_Value', 'Export_Valued_Procedure', 'Extend_System', 'External', 'External_Name_Casing', 'Finalize_Storage_Only', 'Float_Representation', 'Ident', 'Import_Exception', 'Import_Function', 'Import_Object', 'Import_Procedure', 'Import_Valued_Procedure', 'Initialize_Scalars', 'Inline_Always', 'Inline_Generic', 'Interface_Name', 'Interrupt_State', 'Keep_Names', 'License', 'Link_With', 'Linker_Alias', 'Linker_Section', 'Long_Float', 'Machine_Attribute', 'Main_Storage', 'Obsolescent', 'Passive', 'Polling', 'Profile_Warnings', 'Propagate_Exceptions', 'Psect_Object', 'Pure_Function', 'Restriction_Warnings', 'Source_File_Name', 'Source_File_Name_Project', 'Source_Reference', 'Stream_Convert', 'Style_Checks', 'Subtitle', 'Suppress_All', 'Suppress_Exception_Locations', 'Suppress_Initialization', 'Task_Info', 'Task_Name', 'Task_Storage', 'Thread_Body', 'Time_Slice', 'Title', 'Unimplemented_Unit', 'Universal_Data', 'Unreferenced', 'Unreserve_All_Interrupts', 'Use_VADS_Size', 'Validity_Checks', 'Warnings', 'Weak_External']
|
|
147 let g:ada#Keywords += [{
|
|
148 \ 'word': Item,
|
|
149 \ 'menu': 'pragma',
|
|
150 \ 'info': 'GNAT pragma.',
|
|
151 \ 'kind': 'p',
|
|
152 \ 'icase': 1}]
|
|
153 endfor
|
|
154 endif
|
|
155 " 1}}}
|
|
156
|
|
157 " Section: g:ada#Ctags_Kinds {{{1
|
|
158 "
|
|
159 let g:ada#Ctags_Kinds = {
|
|
160 \ 'P': ["packspec", "package specifications"],
|
|
161 \ 'p': ["package", "packages"],
|
|
162 \ 'T': ["typespec", "type specifications"],
|
|
163 \ 't': ["type", "types"],
|
|
164 \ 'U': ["subspec", "subtype specifications"],
|
|
165 \ 'u': ["subtype", "subtypes"],
|
|
166 \ 'c': ["component", "record type components"],
|
|
167 \ 'l': ["literal", "enum type literals"],
|
|
168 \ 'V': ["varspec", "variable specifications"],
|
|
169 \ 'v': ["variable", "variables"],
|
|
170 \ 'f': ["formal", "generic formal parameters"],
|
|
171 \ 'n': ["constant", "constants"],
|
|
172 \ 'x': ["exception", "user defined exceptions"],
|
|
173 \ 'R': ["subprogspec", "subprogram specifications"],
|
|
174 \ 'r': ["subprogram", "subprograms"],
|
|
175 \ 'K': ["taskspec", "task specifications"],
|
|
176 \ 'k': ["task", "tasks"],
|
|
177 \ 'O': ["protectspec", "protected data specifications"],
|
|
178 \ 'o': ["protected", "protected data"],
|
|
179 \ 'E': ["entryspec", "task/protected data entry specifications"],
|
|
180 \ 'e': ["entry", "task/protected data entries"],
|
|
181 \ 'b': ["label", "labels"],
|
|
182 \ 'i': ["identifier", "loop/declare identifiers"],
|
|
183 \ 'a': ["autovar", "automatic variables"],
|
|
184 \ 'y': ["annon", "loops and blocks with no identifier"]}
|
|
185
|
|
186 " Section: ada#Word (...) {{{1
|
|
187 "
|
|
188 " Extract current Ada word across multiple lines
|
|
189 " AdaWord ([line, column])\
|
|
190 "
|
|
191 function ada#Word (...)
|
|
192 if a:0 > 1
|
|
193 let l:Line_Nr = a:1
|
|
194 let l:Column_Nr = a:2 - 1
|
|
195 else
|
|
196 let l:Line_Nr = line('.')
|
|
197 let l:Column_Nr = col('.') - 1
|
|
198 endif
|
|
199
|
|
200 let l:Line = substitute (getline (l:Line_Nr), g:ada#Comment, '', '' )
|
|
201
|
|
202 " Cope with tag searching for items in comments; if we are, don't loop
|
|
203 " backards looking for previous lines
|
|
204 if l:Column_Nr > strlen(l:Line)
|
|
205 " We were in a comment
|
|
206 let l:Line = getline(l:Line_Nr)
|
|
207 let l:Search_Prev_Lines = 0
|
|
208 else
|
|
209 let l:Search_Prev_Lines = 1
|
|
210 endif
|
|
211
|
|
212 " Go backwards until we find a match (Ada ID) that *doesn't* include our
|
|
213 " location - i.e., the previous ID. This is because the current 'correct'
|
|
214 " match will toggle matching/not matching as we traverse characters
|
|
215 " backwards. Thus, we have to find the previous unrelated match, exclude
|
|
216 " it, then use the next full match (ours).
|
|
217 " Remember to convert vim column 'l:Column_Nr' [1..n] to string offset [0..(n-1)]
|
|
218 " ... but start, here, one after the required char.
|
|
219 let l:New_Column = l:Column_Nr + 1
|
|
220 while 1
|
|
221 let l:New_Column = l:New_Column - 1
|
|
222 if l:New_Column < 0
|
|
223 " Have to include previous l:Line from file
|
|
224 let l:Line_Nr = l:Line_Nr - 1
|
|
225 if l:Line_Nr < 1 || !l:Search_Prev_Lines
|
|
226 " Start of file or matching in a comment
|
|
227 let l:Line_Nr = 1
|
|
228 let l:New_Column = 0
|
|
229 let l:Our_Match = match (l:Line, g:ada#WordRegex )
|
|
230 break
|
|
231 endif
|
|
232 " Get previous l:Line, and prepend it to our search string
|
|
233 let l:New_Line = substitute (getline (l:Line_Nr), g:ada#Comment, '', '' )
|
|
234 let l:New_Column = strlen (l:New_Line) - 1
|
|
235 let l:Column_Nr = l:Column_Nr + l:New_Column
|
|
236 let l:Line = l:New_Line . l:Line
|
|
237 endif
|
|
238 " Check to see if this is a match excluding 'us'
|
|
239 let l:Match_End = l:New_Column +
|
|
240 \ matchend (strpart (l:Line,l:New_Column), g:ada#WordRegex ) - 1
|
|
241 if l:Match_End >= l:New_Column &&
|
|
242 \ l:Match_End < l:Column_Nr
|
|
243 " Yes
|
|
244 let l:Our_Match = l:Match_End+1 +
|
|
245 \ match (strpart (l:Line,l:Match_End+1), g:ada#WordRegex )
|
|
246 break
|
|
247 endif
|
|
248 endwhile
|
|
249
|
|
250 " Got anything?
|
|
251 if l:Our_Match < 0
|
|
252 return ''
|
|
253 else
|
|
254 let l:Line = strpart (l:Line, l:Our_Match)
|
|
255 endif
|
|
256
|
|
257 " Now simply add further lines until the match gets no bigger
|
|
258 let l:Match_String = matchstr (l:Line, g:ada#WordRegex)
|
|
259 let l:Last_Line = line ('$')
|
|
260 let l:Line_Nr = line ('.') + 1
|
|
261 while l:Line_Nr <= l:Last_Line
|
|
262 let l:Last_Match = l:Match_String
|
|
263 let l:Line = l:Line .
|
|
264 \ substitute (getline (l:Line_Nr), g:ada#Comment, '', '')
|
|
265 let l:Match_String = matchstr (l:Line, g:ada#WordRegex)
|
|
266 if l:Match_String == l:Last_Match
|
|
267 break
|
|
268 endif
|
|
269 endwhile
|
|
270
|
|
271 " Strip whitespace & return
|
|
272 return substitute (l:Match_String, '\s\+', '', 'g')
|
|
273 endfunction ada#Word
|
|
274
|
|
275 " Section: ada#List_Tag (...) {{{1
|
|
276 "
|
|
277 " List tags in quickfix window
|
|
278 "
|
|
279 function ada#List_Tag (...)
|
|
280 if a:0 > 1
|
|
281 let l:Tag_Word = ada#Word (a:1, a:2)
|
|
282 elseif a:0 > 0
|
|
283 let l:Tag_Word = a:1
|
|
284 else
|
|
285 let l:Tag_Word = ada#Word ()
|
|
286 endif
|
|
287
|
|
288 echo "Searching for" l:Tag_Word
|
|
289
|
|
290 let l:Pattern = '^' . l:Tag_Word . '$'
|
|
291 let l:Tag_List = taglist (l:Pattern)
|
|
292 let l:Error_List = []
|
|
293 "
|
|
294 " add symbols
|
|
295 "
|
|
296 for Tag_Item in l:Tag_List
|
|
297 if l:Tag_Item['kind'] == ''
|
|
298 let l:Tag_Item['kind'] = 's'
|
|
299 endif
|
|
300
|
|
301 let l:Error_List += [
|
|
302 \ l:Tag_Item['filename'] . '|' .
|
|
303 \ l:Tag_Item['cmd'] . '|' .
|
|
304 \ l:Tag_Item['kind'] . "\t" .
|
|
305 \ l:Tag_Item['name'] ]
|
|
306 endfor
|
|
307 set errorformat=%f\|%l\|%m
|
|
308 cexpr l:Error_List
|
|
309 cwindow
|
|
310 endfunction ada#List_Tag
|
|
311
|
|
312 " Section: ada#Jump_Tag (Word, Mode) {{{1
|
|
313 "
|
|
314 " Word tag - include '.' and if Ada make uppercase
|
|
315 "
|
|
316 function ada#Jump_Tag (Word, Mode)
|
|
317 if a:Word == ''
|
|
318 " Get current word
|
|
319 let l:Word = ada#Word()
|
|
320 if l:Word == ''
|
|
321 throw "NOT_FOUND: no identifier found."
|
|
322 endif
|
|
323 else
|
|
324 let l:Word = a:Word
|
|
325 endif
|
|
326
|
|
327 echo "Searching for " . l:Word
|
|
328
|
|
329 try
|
|
330 execute a:Mode l:Word
|
|
331 catch /.*:E426:.*/
|
|
332 let ignorecase = &ignorecase
|
|
333 set ignorecase
|
|
334 execute a:Mode l:Word
|
|
335 let &ignorecase = ignorecase
|
|
336 endtry
|
|
337
|
|
338 return
|
|
339 endfunction ada#Jump_Tag
|
|
340
|
|
341 " Section: ada#Insert_Backspace () {{{1
|
|
342 "
|
|
343 " Backspace at end of line after auto-inserted commentstring '-- ' wipes it
|
|
344 "
|
|
345 function ada#Insert_Backspace ()
|
|
346 let l:Line = getline ('.')
|
|
347 if col ('.') > strlen (l:Line) &&
|
|
348 \ match (l:Line, '-- $') != -1 &&
|
|
349 \ match (&comments,'--') != -1
|
|
350 return "\<bs>\<bs>\<bs>"
|
|
351 else
|
|
352 return "\<bs>"
|
|
353 endif
|
|
354
|
|
355 return
|
|
356 endfunction ada#InsertBackspace
|
|
357
|
|
358 " Section: Insert Completions {{{1
|
|
359 "
|
|
360 " Section: ada#User_Complete(findstart, base) {{{2
|
|
361 "
|
|
362 " This function is used for the 'complete' option.
|
|
363 "
|
|
364 function! ada#User_Complete(findstart, base)
|
|
365 if a:findstart == 1
|
|
366 "
|
|
367 " locate the start of the word
|
|
368 "
|
|
369 let line = getline ('.')
|
|
370 let start = col ('.') - 1
|
|
371 while start > 0 && line[start - 1] =~ '\i\|'''
|
|
372 let start -= 1
|
|
373 endwhile
|
|
374 return start
|
|
375 else
|
|
376 "
|
|
377 " look up matches
|
|
378 "
|
|
379 let l:Pattern = '^' . a:base . '.*$'
|
|
380 "
|
|
381 " add keywords
|
|
382 "
|
|
383 for Tag_Item in g:ada#Keywords
|
|
384 if l:Tag_Item['word'] =~? l:Pattern
|
|
385 if complete_add (l:Tag_Item) == 0
|
|
386 return []
|
|
387 endif
|
|
388 if complete_check ()
|
|
389 return []
|
|
390 endif
|
|
391 endif
|
|
392 endfor
|
|
393 return []
|
|
394 endif
|
|
395 endfunction ada#User_Complete
|
|
396
|
|
397 " Section: ada#Completion (cmd) {{{2
|
|
398 "
|
|
399 " Word completion (^N/^R/^X^]) - force '.' inclusion
|
|
400 function ada#Completion (cmd)
|
|
401 set iskeyword+=46
|
|
402 return a:cmd . "\<C-R>=ada#Completion_End ()\<CR>"
|
|
403 endfunction ada#Completion
|
|
404
|
|
405 " Section: ada#Completion_End () {{{2
|
|
406 "
|
|
407 function ada#Completion_End ()
|
|
408 set iskeyword-=46
|
|
409 return ''
|
|
410 endfunction ada#Completion_End
|
|
411
|
|
412 " Section: ada#Create_Tags {{{1
|
|
413 "
|
|
414 function ada#Create_Tags (option)
|
|
415 if a:option == 'file'
|
|
416 let l:Filename = fnamemodify (bufname ('%'), ':p')
|
|
417 elseif a:option == 'dir'
|
|
418 let l:Filename =
|
|
419 \ fnamemodify (bufname ('%'), ':p:h') . "*.ada " .
|
|
420 \ fnamemodify (bufname ('%'), ':p:h') . "*.adb " .
|
|
421 \ fnamemodify (bufname ('%'), ':p:h') . "*.ads"
|
|
422 else
|
|
423 let l:Filename = a:option
|
|
424 endif
|
|
425 execute '!ctags --excmd=number ' . l:Filename
|
|
426 endfunction ada#Create_Tags
|
|
427
|
|
428 function ada#Switch_Session (New_Session) "{{{1
|
|
429 if a:New_Session != v:this_session
|
|
430 "
|
|
431 " We actualy got a new session - otherwise there
|
|
432 " is nothing to do.
|
|
433 "
|
|
434 if strlen (v:this_session) > 0
|
|
435 execute 'mksession! ' . v:this_session
|
|
436 endif
|
|
437
|
|
438 let v:this_session = a:New_Session
|
|
439
|
|
440 if filereadable (v:this_session)
|
|
441 execute 'source ' . v:this_session
|
|
442 endif
|
|
443
|
|
444 augroup ada_session
|
|
445 autocmd!
|
|
446 autocmd VimLeavePre * execute 'mksession! ' . v:this_session
|
|
447 augroup END
|
|
448 endif
|
|
449
|
|
450 return
|
|
451 endfunction ada#Switch_Session "}}}1
|
|
452
|
|
453 " Section: GNAT Pretty Printer folding {{{1
|
|
454 "
|
|
455 if exists('g:ada_folding') && g:ada_folding[0] == 'g'
|
|
456 "
|
|
457 " Lines consisting only of ')' ';' are due to a gnat pretty bug and
|
|
458 " have the same level as the line above (can't happen in the first
|
|
459 " line).
|
|
460 "
|
|
461 let s:Fold_Collate = '^\([;)]*$\|'
|
|
462
|
|
463 "
|
|
464 " some lone statements are folded with the line above
|
|
465 "
|
|
466 if stridx (g:ada_folding, 'i') >= 0
|
|
467 let s:Fold_Collate .= '\s\+\<is\>$\|'
|
|
468 endif
|
|
469 if stridx (g:ada_folding, 'b') >= 0
|
|
470 let s:Fold_Collate .= '\s\+\<begin\>$\|'
|
|
471 endif
|
|
472 if stridx (g:ada_folding, 'p') >= 0
|
|
473 let s:Fold_Collate .= '\s\+\<private\>$\|'
|
|
474 endif
|
|
475 if stridx (g:ada_folding, 'x') >= 0
|
|
476 let s:Fold_Collate .= '\s\+\<exception\>$\|'
|
|
477 endif
|
|
478
|
|
479 " We also handle empty lines and
|
|
480 " comments here.
|
|
481 let s:Fold_Collate .= '--\)'
|
|
482
|
|
483 function ada#Pretty_Print_Folding (Line) " {{{2
|
|
484 let l:Text = getline (a:Line)
|
|
485
|
|
486 if l:Text =~ s:Fold_Collate
|
|
487 "
|
|
488 " fold with line above
|
|
489 "
|
|
490 let l:Level = "="
|
|
491 elseif l:Text =~ '^\s\+('
|
|
492 "
|
|
493 " gnat outdents a line which stards with a ( by one characters so
|
|
494 " that parameters which follow are aligned.
|
|
495 "
|
|
496 let l:Level = (indent (a:Line) + 1) / &shiftwidth
|
|
497 else
|
|
498 let l:Level = indent (a:Line) / &shiftwidth
|
|
499 endif
|
|
500
|
|
501 return l:Level
|
|
502 endfunction ada#Pretty_Print_Folding " }}}2
|
|
503 endif
|
|
504
|
|
505 " Section: Options and Menus {{{1
|
|
506 "
|
|
507 " Section: ada#Switch_Syntax_Options {{{2
|
|
508 "
|
|
509 function ada#Switch_Syntax_Option (option)
|
|
510 syntax off
|
|
511 if exists ('g:ada_' . a:option)
|
|
512 unlet g:ada_{a:option}
|
|
513 echo a:option . 'now off'
|
|
514 else
|
|
515 let g:ada_{a:option}=1
|
|
516 echo a:option . 'now on'
|
|
517 endif
|
|
518 syntax on
|
|
519 endfunction ada#Switch_Syntax_Option
|
|
520
|
|
521 " Section: ada#Map_Menu {{{2
|
|
522 "
|
|
523 function ada#Map_Menu (Text, Keys, Command)
|
|
524 if a:Keys[0] == ':'
|
|
525 execute
|
|
526 \ "50amenu " .
|
|
527 \ "Ada." . escape(a:Text, ' ') .
|
|
528 \ "<Tab>" . a:Keys .
|
|
529 \ " :" . a:Command . "<CR>"
|
|
530 execute
|
|
531 \ "command -buffer " .
|
|
532 \ a:Keys[1:] .
|
|
533 \" :" . a:Command . "<CR>"
|
|
534 elseif a:Keys[0] == '<'
|
|
535 execute
|
|
536 \ "50amenu " .
|
|
537 \ "Ada." . escape(a:Text, ' ') .
|
|
538 \ "<Tab>" . a:Keys .
|
|
539 \ " :" . a:Command . "<CR>"
|
|
540 execute
|
|
541 \ "nnoremap <buffer> " .
|
|
542 \ a:Keys .
|
|
543 \" :" . a:Command . "<CR>"
|
|
544 execute
|
|
545 \ "inoremap <buffer> " .
|
|
546 \ a:Keys .
|
|
547 \" <C-O>:" . a:Command . "<CR>"
|
|
548 else
|
|
549 execute
|
|
550 \ "50amenu " .
|
|
551 \ "Ada." . escape(a:Text, ' ') .
|
|
552 \ "<Tab>" . escape(g:mapleader . "a" . a:Keys , '\') .
|
|
553 \ " :" . a:Command . "<CR>"
|
|
554 execute
|
|
555 \ "nnoremap <buffer>" .
|
|
556 \ escape(g:mapleader . "a" . a:Keys , '\') .
|
|
557 \" :" . a:Command
|
|
558 execute
|
|
559 \ "inoremap <buffer>" .
|
|
560 \ escape(g:mapleader . "a" . a:Keys , '\') .
|
|
561 \" <C-O>:" . a:Command
|
|
562 endif
|
|
563 return
|
|
564 endfunction
|
|
565
|
|
566 " Section: ada#Map_Popup {{{2
|
|
567 "
|
|
568 function ada#Map_Popup (Text, Keys, Command)
|
|
569 execute
|
|
570 \ "50amenu " .
|
|
571 \ "PopUp." . escape(a:Text, ' ') .
|
|
572 \ "<Tab>" . escape(g:mapleader . "a" . a:Keys , '\') .
|
|
573 \ " :" . a:Command . "<CR>"
|
|
574
|
|
575 call ada#Map_Menu (a:Text, a:Keys, a:Command)
|
|
576 return
|
|
577 endfunction ada#Map_Popup
|
|
578
|
|
579 " }}}1
|
|
580
|
|
581 lockvar g:ada#WordRegex
|
|
582 lockvar g:ada#DotWordRegex
|
|
583 lockvar g:ada#Comment
|
|
584 lockvar! g:ada#Keywords
|
|
585 lockvar! g:ada#Ctags_Kinds
|
|
586
|
|
587 finish " 1}}}
|
|
588
|
|
589 "------------------------------------------------------------------------------
|
|
590 " Copyright (C) 2006 Martin Krischik
|
|
591 "
|
|
592 " Vim is Charityware - see ":help license" or uganda.txt for licence details.
|
|
593 "------------------------------------------------------------------------------
|
|
594 " vim: textwidth=78 wrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab
|
|
595 " vim: foldmethod=marker
|