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