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