1"------------------------------------------------------------------------------ 2" Description: Perform Ada specific completion & tagging. 3" Language: Ada (2005) 4" $Id: ada.vim 887 2008-07-08 14:29:01Z krischik $ 5" Maintainer: Mathias Brousset <[email protected]> 6" Martin Krischik <[email protected]> 7" Taylor Venable <[email protected]> 8" Neil Bird <[email protected]> 9" Ned Okie <[email protected]> 10" $Author: krischik $ 11" $Date: 2017-01-31 20:20:05 +0200 (Mon, 01 Jan 2017) $ 12" Version: 4.6 13" $Revision: 887 $ 14" $HeadURL: https://gnuada.svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/autoload/ada.vim $ 15" History: 24.05.2006 MK Unified Headers 16" 26.05.2006 MK ' should not be in iskeyword. 17" 16.07.2006 MK Ada-Mode as vim-ball 18" 02.10.2006 MK Better folding. 19" 15.10.2006 MK Bram's suggestion for runtime integration 20" 05.11.2006 MK Bram suggested not to use include protection for 21" autoload 22" 05.11.2006 MK Bram suggested to save on spaces 23" 08.07.2007 TV fix mapleader problems. 24" 09.05.2007 MK Session just won't work no matter how much 25" tweaking is done 26" 19.09.2007 NO still some mapleader problems 27" 31.01.2017 MB fix more mapleader problems 28" Help Page: ft-ada-functions 29"------------------------------------------------------------------------------ 30 31if version < 700 32 finish 33endif 34let s:keepcpo= &cpo 35set cpo&vim 36 37" Section: Constants {{{1 38" 39let g:ada#DotWordRegex = '\a\w*\(\_s*\.\_s*\a\w*\)*' 40let g:ada#WordRegex = '\a\w*' 41let g:ada#Comment = "\\v^(\"[^\"]*\"|'.'|[^\"']){-}\\zs\\s*--.*" 42let g:ada#Keywords = [] 43 44" Section: g:ada#Keywords {{{1 45" 46" Section: add Ada keywords {{{2 47" 48for 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'] 49 let g:ada#Keywords += [{ 50 \ 'word': Item, 51 \ 'menu': 'keyword', 52 \ 'info': 'Ada keyword.', 53 \ 'kind': 'k', 54 \ 'icase': 1}] 55endfor 56 57" Section: GNAT Project Files {{{3 58" 59if exists ('g:ada_with_gnat_project_files') 60 for Item in ['project'] 61 let g:ada#Keywords += [{ 62 \ 'word': Item, 63 \ 'menu': 'keyword', 64 \ 'info': 'GNAT projectfile keyword.', 65 \ 'kind': 'k', 66 \ 'icase': 1}] 67 endfor 68endif 69 70" Section: add standard exception {{{2 71" 72for 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'] 73 let g:ada#Keywords += [{ 74 \ 'word': Item, 75 \ 'menu': 'exception', 76 \ 'info': 'Ada standard exception.', 77 \ 'kind': 'x', 78 \ 'icase': 1}] 79endfor 80 81" Section: add GNAT exception {{{3 82" 83if exists ('g:ada_gnat_extensions') 84 for Item in ['Assert_Failure'] 85 let g:ada#Keywords += [{ 86 \ 'word': Item, 87 \ 'menu': 'exception', 88 \ 'info': 'GNAT exception.', 89 \ 'kind': 'x', 90 \ 'icase': 1}] 91 endfor 92endif 93 94" Section: add Ada buildin types {{{2 95" 96for Item in ['Boolean', 'Integer', 'Natural', 'Positive', 'Float', 'Character', 'Wide_Character', 'Wide_Wide_Character', 'String', 'Wide_String', 'Wide_Wide_String', 'Duration'] 97 let g:ada#Keywords += [{ 98 \ 'word': Item, 99 \ 'menu': 'type', 100 \ 'info': 'Ada buildin type.', 101 \ 'kind': 't', 102 \ 'icase': 1}] 103endfor 104 105" Section: add GNAT buildin types {{{3 106" 107if exists ('g:ada_gnat_extensions') 108 for Item in ['Short_Integer', 'Short_Short_Integer', 'Long_Integer', 'Long_Long_Integer', 'Short_Float', 'Short_Short_Float', 'Long_Float', 'Long_Long_Float'] 109 let g:ada#Keywords += [{ 110 \ 'word': Item, 111 \ 'menu': 'type', 112 \ 'info': 'GNAT buildin type.', 113 \ 'kind': 't', 114 \ 'icase': 1}] 115 endfor 116endif 117 118" Section: add Ada Attributes {{{2 119" 120for 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'] 121 let g:ada#Keywords += [{ 122 \ 'word': Item, 123 \ 'menu': 'attribute', 124 \ 'info': 'Ada attribute.', 125 \ 'kind': 'a', 126 \ 'icase': 1}] 127endfor 128 129" Section: add GNAT Attributes {{{3 130" 131if exists ('g:ada_gnat_extensions') 132 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'] 133 let g:ada#Keywords += [{ 134 \ 'word': Item, 135 \ 'menu': 'attribute', 136 \ 'info': 'GNAT attribute.', 137 \ 'kind': 'a', 138 \ 'icase': 1}] 139 endfor 140endif 141 142" Section: add Ada Pragmas {{{2 143" 144for 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'] 145 let g:ada#Keywords += [{ 146 \ 'word': Item, 147 \ 'menu': 'pragma', 148 \ 'info': 'Ada pragma.', 149 \ 'kind': 'p', 150 \ 'icase': 1}] 151endfor 152 153" Section: add GNAT Pragmas {{{3 154" 155if exists ('g:ada_gnat_extensions') 156 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'] 157 let g:ada#Keywords += [{ 158 \ 'word': Item, 159 \ 'menu': 'pragma', 160 \ 'info': 'GNAT pragma.', 161 \ 'kind': 'p', 162 \ 'icase': 1}] 163 endfor 164endif 165" 1}}} 166 167" Section: g:ada#Ctags_Kinds {{{1 168" 169let g:ada#Ctags_Kinds = { 170 \ 'P': ["packspec", "package specifications"], 171 \ 'p': ["package", "packages"], 172 \ 'T': ["typespec", "type specifications"], 173 \ 't': ["type", "types"], 174 \ 'U': ["subspec", "subtype specifications"], 175 \ 'u': ["subtype", "subtypes"], 176 \ 'c': ["component", "record type components"], 177 \ 'l': ["literal", "enum type literals"], 178 \ 'V': ["varspec", "variable specifications"], 179 \ 'v': ["variable", "variables"], 180 \ 'f': ["formal", "generic formal parameters"], 181 \ 'n': ["constant", "constants"], 182 \ 'x': ["exception", "user defined exceptions"], 183 \ 'R': ["subprogspec", "subprogram specifications"], 184 \ 'r': ["subprogram", "subprograms"], 185 \ 'K': ["taskspec", "task specifications"], 186 \ 'k': ["task", "tasks"], 187 \ 'O': ["protectspec", "protected data specifications"], 188 \ 'o': ["protected", "protected data"], 189 \ 'E': ["entryspec", "task/protected data entry specifications"], 190 \ 'e': ["entry", "task/protected data entries"], 191 \ 'b': ["label", "labels"], 192 \ 'i': ["identifier", "loop/declare identifiers"], 193 \ 'a': ["autovar", "automatic variables"], 194 \ 'y': ["annon", "loops and blocks with no identifier"]} 195 196" Section: ada#Word (...) {{{1 197" 198" Extract current Ada word across multiple lines 199" AdaWord ([line, column])\ 200" 201function ada#Word (...) 202 if a:0 > 1 203 let l:Line_Nr = a:1 204 let l:Column_Nr = a:2 - 1 205 else 206 let l:Line_Nr = line('.') 207 let l:Column_Nr = col('.') - 1 208 endif 209 210 let l:Line = substitute (getline (l:Line_Nr), g:ada#Comment, '', '' ) 211 212 " Cope with tag searching for items in comments; if we are, don't loop 213 " backwards looking for previous lines 214 if l:Column_Nr > strlen(l:Line) 215 " We were in a comment 216 let l:Line = getline(l:Line_Nr) 217 let l:Search_Prev_Lines = 0 218 else 219 let l:Search_Prev_Lines = 1 220 endif 221 222 " Go backwards until we find a match (Ada ID) that *doesn't* include our 223 " location - i.e., the previous ID. This is because the current 'correct' 224 " match will toggle matching/not matching as we traverse characters 225 " backwards. Thus, we have to find the previous unrelated match, exclude 226 " it, then use the next full match (ours). 227 " Remember to convert vim column 'l:Column_Nr' [1..n] to string offset [0..(n-1)] 228 " ... but start, here, one after the required char. 229 let l:New_Column = l:Column_Nr + 1 230 while 1 231 let l:New_Column = l:New_Column - 1 232 if l:New_Column < 0 233 " Have to include previous l:Line from file 234 let l:Line_Nr = l:Line_Nr - 1 235 if l:Line_Nr < 1 || !l:Search_Prev_Lines 236 " Start of file or matching in a comment 237 let l:Line_Nr = 1 238 let l:New_Column = 0 239 let l:Our_Match = match (l:Line, g:ada#WordRegex ) 240 break 241 endif 242 " Get previous l:Line, and prepend it to our search string 243 let l:New_Line = substitute (getline (l:Line_Nr), g:ada#Comment, '', '' ) 244 let l:New_Column = strlen (l:New_Line) - 1 245 let l:Column_Nr = l:Column_Nr + l:New_Column 246 let l:Line = l:New_Line . l:Line 247 endif 248 " Check to see if this is a match excluding 'us' 249 let l:Match_End = l:New_Column + 250 \ matchend (strpart (l:Line,l:New_Column), g:ada#WordRegex ) - 1 251 if l:Match_End >= l:New_Column && 252 \ l:Match_End < l:Column_Nr 253 " Yes 254 let l:Our_Match = l:Match_End+1 + 255 \ match (strpart (l:Line,l:Match_End+1), g:ada#WordRegex ) 256 break 257 endif 258 endwhile 259 260 " Got anything? 261 if l:Our_Match < 0 262 return '' 263 else 264 let l:Line = strpart (l:Line, l:Our_Match) 265 endif 266 267 " Now simply add further lines until the match gets no bigger 268 let l:Match_String = matchstr (l:Line, g:ada#WordRegex) 269 let l:Last_Line = line ('$') 270 let l:Line_Nr = line ('.') + 1 271 while l:Line_Nr <= l:Last_Line 272 let l:Last_Match = l:Match_String 273 let l:Line = l:Line . 274 \ substitute (getline (l:Line_Nr), g:ada#Comment, '', '') 275 let l:Match_String = matchstr (l:Line, g:ada#WordRegex) 276 if l:Match_String == l:Last_Match 277 break 278 endif 279 endwhile 280 281 " Strip whitespace & return 282 return substitute (l:Match_String, '\s\+', '', 'g') 283endfunction ada#Word 284 285" Section: ada#List_Tag (...) {{{1 286" 287" List tags in quickfix window 288" 289function ada#List_Tag (...) 290 if a:0 > 1 291 let l:Tag_Word = ada#Word (a:1, a:2) 292 elseif a:0 > 0 293 let l:Tag_Word = a:1 294 else 295 let l:Tag_Word = ada#Word () 296 endif 297 298 echo "Searching for" l:Tag_Word 299 300 let l:Pattern = '^' . l:Tag_Word . '$' 301 let l:Tag_List = taglist (l:Pattern) 302 let l:Error_List = [] 303 " 304 " add symbols 305 " 306 for Tag_Item in l:Tag_List 307 if l:Tag_Item['kind'] == '' 308 let l:Tag_Item['kind'] = 's' 309 endif 310 311 let l:Error_List += [ 312 \ l:Tag_Item['filename'] . '|' . 313 \ l:Tag_Item['cmd'] . '|' . 314 \ l:Tag_Item['kind'] . "\t" . 315 \ l:Tag_Item['name'] ] 316 endfor 317 set errorformat=%f\|%l\|%m 318 cexpr l:Error_List 319 cwindow 320endfunction ada#List_Tag 321 322" Section: ada#Jump_Tag (Word, Mode) {{{1 323" 324" Word tag - include '.' and if Ada make uppercase 325" 326function ada#Jump_Tag (Word, Mode) 327 if a:Word == '' 328 " Get current word 329 let l:Word = ada#Word() 330 if l:Word == '' 331 throw "NOT_FOUND: no identifier found." 332 endif 333 else 334 let l:Word = a:Word 335 endif 336 337 echo "Searching for " . l:Word 338 339 try 340 execute a:Mode l:Word 341 catch /.*:E426:.*/ 342 let ignorecase = &ignorecase 343 set ignorecase 344 execute a:Mode l:Word 345 let &ignorecase = ignorecase 346 endtry 347 348 return 349endfunction ada#Jump_Tag 350 351" Section: ada#Insert_Backspace () {{{1 352" 353" Backspace at end of line after auto-inserted commentstring '-- ' wipes it 354" 355function ada#Insert_Backspace () 356 let l:Line = getline ('.') 357 if col ('.') > strlen (l:Line) && 358 \ match (l:Line, '-- $') != -1 && 359 \ match (&comments,'--') != -1 360 return "\<bs>\<bs>\<bs>" 361 else 362 return "\<bs>" 363 endif 364 365 return 366endfunction ada#InsertBackspace 367 368" Section: Insert Completions {{{1 369" 370" Section: ada#User_Complete(findstart, base) {{{2 371" 372" This function is used for the 'complete' option. 373" 374function! ada#User_Complete(findstart, base) 375 if a:findstart == 1 376 " 377 " locate the start of the word 378 " 379 let line = getline ('.') 380 let start = col ('.') - 1 381 while start > 0 && line[start - 1] =~ '\i\|''' 382 let start -= 1 383 endwhile 384 return start 385 else 386 " 387 " look up matches 388 " 389 let l:Pattern = '^' . a:base . '.*$' 390 " 391 " add keywords 392 " 393 for Tag_Item in g:ada#Keywords 394 if l:Tag_Item['word'] =~? l:Pattern 395 if complete_add (l:Tag_Item) == 0 396 return [] 397 endif 398 if complete_check () 399 return [] 400 endif 401 endif 402 endfor 403 return [] 404 endif 405endfunction ada#User_Complete 406 407" Section: ada#Completion (cmd) {{{2 408" 409" Word completion (^N/^R/^X^]) - force '.' inclusion 410function ada#Completion (cmd) 411 set iskeyword+=46 412 return a:cmd . "\<C-R>=ada#Completion_End ()\<CR>" 413endfunction ada#Completion 414 415" Section: ada#Completion_End () {{{2 416" 417function ada#Completion_End () 418 set iskeyword-=46 419 return '' 420endfunction ada#Completion_End 421 422" Section: ada#Create_Tags {{{1 423" 424function ada#Create_Tags (option) 425 if a:option == 'file' 426 let l:Filename = fnamemodify (bufname ('%'), ':p') 427 elseif a:option == 'dir' 428 let l:Filename = 429 \ fnamemodify (bufname ('%'), ':p:h') . "*.ada " . 430 \ fnamemodify (bufname ('%'), ':p:h') . "*.adb " . 431 \ fnamemodify (bufname ('%'), ':p:h') . "*.ads" 432 else 433 let l:Filename = a:option 434 endif 435 execute '!ctags --excmd=number ' . l:Filename 436endfunction ada#Create_Tags 437 438" Section: ada#Switch_Session {{{1 439" 440function ada#Switch_Session (New_Session) 441 " 442 " you should not save to much date into the seession since they will 443 " be sourced 444 " 445 let l:sessionoptions=&sessionoptions 446 447 try 448 set sessionoptions=buffers,curdir,folds,globals,resize,slash,tabpages,tabpages,unix,winpos,winsize 449 450 if a:New_Session != v:this_session 451 " 452 " We actually got a new session - otherwise there 453 " is nothing to do. 454 " 455 if strlen (v:this_session) > 0 456 execute 'mksession! ' . v:this_session 457 endif 458 459 let v:this_session = a:New_Session 460 461 "if filereadable (v:this_session) 462 "execute 'source ' . v:this_session 463 "endif 464 465 augroup ada_session 466 autocmd! 467 autocmd VimLeavePre * execute 'mksession! ' . v:this_session 468 augroup END 469 470 "if exists ("g:Tlist_Auto_Open") && g:Tlist_Auto_Open 471 "TlistOpen 472 "endif 473 474 endif 475 finally 476 let &sessionoptions=l:sessionoptions 477 endtry 478 479 return 480endfunction ada#Switch_Session 481 482" Section: GNAT Pretty Printer folding {{{1 483" 484if exists('g:ada_folding') && g:ada_folding[0] == 'g' 485 " 486 " Lines consisting only of ')' ';' are due to a gnat pretty bug and 487 " have the same level as the line above (can't happen in the first 488 " line). 489 " 490 let s:Fold_Collate = '^\([;)]*$\|' 491 492 " 493 " some lone statements are folded with the line above 494 " 495 if stridx (g:ada_folding, 'i') >= 0 496 let s:Fold_Collate .= '\s\+\<is\>$\|' 497 endif 498 if stridx (g:ada_folding, 'b') >= 0 499 let s:Fold_Collate .= '\s\+\<begin\>$\|' 500 endif 501 if stridx (g:ada_folding, 'p') >= 0 502 let s:Fold_Collate .= '\s\+\<private\>$\|' 503 endif 504 if stridx (g:ada_folding, 'x') >= 0 505 let s:Fold_Collate .= '\s\+\<exception\>$\|' 506 endif 507 508 " We also handle empty lines and 509 " comments here. 510 let s:Fold_Collate .= '--\)' 511 512 function ada#Pretty_Print_Folding (Line) " {{{2 513 let l:Text = getline (a:Line) 514 515 if l:Text =~ s:Fold_Collate 516 " 517 " fold with line above 518 " 519 let l:Level = "=" 520 elseif l:Text =~ '^\s\+(' 521 " 522 " gnat outdents a line which stards with a ( by one characters so 523 " that parameters which follow are aligned. 524 " 525 let l:Level = (indent (a:Line) + 1) / &shiftwidth 526 else 527 let l:Level = indent (a:Line) / &shiftwidth 528 endif 529 530 return l:Level 531 endfunction ada#Pretty_Print_Folding " }}}2 532endif 533 534" Section: Options and Menus {{{1 535" 536" Section: ada#Switch_Syntax_Options {{{2 537" 538function ada#Switch_Syntax_Option (option) 539 syntax off 540 if exists ('g:ada_' . a:option) 541 unlet g:ada_{a:option} 542 echo a:option . 'now off' 543 else 544 let g:ada_{a:option}=1 545 echo a:option . 'now on' 546 endif 547 syntax on 548endfunction ada#Switch_Syntax_Option 549 550" Section: ada#Map_Menu {{{2 551" 552function ada#Map_Menu (Text, Keys, Command) 553 if a:Keys[0] == ':' 554 execute 555 \ "50amenu " . 556 \ "Ada." . escape(a:Text, ' ') . 557 \ "<Tab>" . a:Keys . 558 \ " :" . a:Command . "<CR>" 559 execute 560 \ "command -buffer " . 561 \ a:Keys[1:] . 562 \" :" . a:Command . "<CR>" 563 elseif a:Keys[0] == '<' 564 execute 565 \ "50amenu " . 566 \ "Ada." . escape(a:Text, ' ') . 567 \ "<Tab>" . a:Keys . 568 \ " :" . a:Command . "<CR>" 569 execute 570 \ "nnoremap <buffer> " . 571 \ a:Keys . 572 \" :" . a:Command . "<CR>" 573 execute 574 \ "inoremap <buffer> " . 575 \ a:Keys . 576 \" <C-O>:" . a:Command . "<CR>" 577 else 578 if exists("g:mapleader") 579 let l:leader = g:mapleader 580 else 581 let l:leader = '\' 582 endif 583 execute 584 \ "50amenu " . 585 \ "Ada." . escape(a:Text, ' ') . 586 \ "<Tab>" . escape(l:leader . "a" . a:Keys , '\') . 587 \ " :" . a:Command . "<CR>" 588 execute 589 \ "nnoremap <buffer>" . 590 \ " <Leader>a" . a:Keys . 591 \" :" . a:Command 592 execute 593 \ "inoremap <buffer>" . 594 \ " <Leader>a" . a:Keys . 595 \" <C-O>:" . a:Command 596 endif 597 return 598endfunction 599 600" Section: ada#Map_Popup {{{2 601" 602function ada#Map_Popup (Text, Keys, Command) 603 if exists("g:mapleader") 604 let l:leader = g:mapleader 605 else 606 let l:leader = '\' 607 endif 608 execute 609 \ "50amenu " . 610 \ "PopUp." . escape(a:Text, ' ') . 611 \ "<Tab>" . escape(l:leader . "a" . a:Keys , '\') . 612 \ " :" . a:Command . "<CR>" 613 614 call ada#Map_Menu (a:Text, a:Keys, a:Command) 615 return 616endfunction ada#Map_Popup 617 618" }}}1 619 620lockvar g:ada#WordRegex 621lockvar g:ada#DotWordRegex 622lockvar g:ada#Comment 623lockvar! g:ada#Keywords 624lockvar! g:ada#Ctags_Kinds 625 626let &cpo = s:keepcpo 627unlet s:keepcpo 628 629finish " 1}}} 630 631"------------------------------------------------------------------------------ 632" Copyright (C) 2006 Martin Krischik 633" 634" Vim is Charityware - see ":help license" or uganda.txt for licence details. 635"------------------------------------------------------------------------------ 636" vim: textwidth=78 wrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab 637" vim: foldmethod=marker 638