robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
5fd21b8d3e
master
1" Vim syntax file 2" Language: IDL (Interface Description Language) 3" Created By: Jody Goldberg 4" Maintainer: Michael Geddes <vim@frog.wheelycreek.net> 5" Last Change: 2012 Jan 11 6 7 8" This is an experiment. IDL's structure is simple enough to permit a full 9" grammar based approach to rather than using a few heuristics. The result 10" is large and somewhat repetitive but seems to work. 11 12" There are some Microsoft extensions to idl files that are here. Some of 13" them are disabled by defining idl_no_ms_extensions. 14" 15" The more complex of the extensions are disabled by defining idl_no_extensions. 16" 17" History: 18" 2.0: Michael's new version 19" 2.1: Support for Vim 7 spell (Anduin Withers) 20" 21 22if exists ( "b:current_syntax" ) 23finish 24endif 25 26let s: cpo_save = & cpo 27try 28set cpo & vim 29 30if exists ( "idlsyntax_showerror" ) 31syn match idlError +\S +skipwhite skipempty nextgroup = idlError 32endif 33 34syn region idlCppQuote start = '\<cpp_quote\s * ( 'end = ') 'contains = idlString 35 36" Misc basic 37syn match idlId contained "[ a-zA-Z ][ a-zA-Z0-9_ ] * "skipwhite skipempty nextgroup = idlEnumComma , idlEnumNumber 38syn match idlEnumComma contained ", " 39syn match idlEnumNumber contained "= "skipwhite skipempty nextgroup = idlString , idlLiteral 40syn match idlSemiColon contained "; " 41syn match idlCommaArg contained ", "skipempty skipwhite nextgroup = idlSimpDecl 42syn region idlArraySize1 contained start = :\[ :end = :\] :skipempty skipwhite nextgroup = idlArraySize1 , idlError , idlSemiColon , idlCommaArg contains = idlArraySize1 , idlLiteral 43syn match idlSimpDecl contained "[ a-zA-Z ][ a-zA-Z0-9_ ] * "skipempty skipwhite nextgroup = idlError , idlSemiColon , idlCommaArg , idlArraySize1 44syn region idlString contained start = +" +skip = +\\\(\\\\\) * " +end = +" +contains = @Spell 45syn match idlLiteral contained "[ 1-9 ] \d * \(\.\d * \)\= " 46syn match idlLiteral contained "0 " 47syn match idlLiteral contained "\.\d\+ " 48syn match idlLiteral contained "0x [ 0-9A-Fa-f ] \+ " 49syn match idlLiteral contained "0 [ 0-7 ] \+ " 50syn keyword idlLiteral contained TRUE FALSE 51 52" Comments 53syn keyword idlTodo contained TODO FIXME XXX 54syn region idlComment start = "/\* "end = "\*/ "contains = idlTodo , @Spell 55syn match idlComment "//. * "contains = idlTodo , @Spell 56syn match idlCommentError "\*/ " 57 58" C style Preprocessor 59syn region idlIncluded contained start = +" +skip = +\\\(\\\\\) * " +end = +" + 60syn match idlIncluded contained "< [ ^> ] * > " 61syn match idlInclude "^ [ \t ] * # [ \t ] * include\> [ \t ] * [ "< ] "contains = idlIncluded , idlString 62syn region idlPreCondit start = "^ [ \t ] * # [ \t ] * \(if\>\|ifdef\>\|ifndef\>\|elif\>\|else\>\|endif\>\) "skip = "\\$ "end = "$ "contains = idlComment , idlCommentError 63syn region idlDefine start = "^ [ \t ] * # [ \t ] * \(define\>\|undef\>\) "skip = "\\$ "end = "$ "contains = idlLiteral , idlString 64 65" Constants 66syn keyword idlConst const skipempty skipwhite nextgroup = idlBaseType , idlBaseTypeInt 67 68" Attribute 69syn keyword idlROAttr readonly skipempty skipwhite nextgroup = idlAttr 70syn keyword idlAttr attribute skipempty skipwhite nextgroup = idlBaseTypeInt , idlBaseType 71 72" Types 73syn region idlD4 contained start = "< "end = "> "skipempty skipwhite nextgroup = idlSimpDecl contains = idlSeqType , idlBaseTypeInt , idlBaseType , idlLiteral 74syn keyword idlSeqType contained sequence skipempty skipwhite nextgroup = idlD4 75syn keyword idlBaseType contained float double char boolean octet any skipempty skipwhite nextgroup = idlSimpDecl 76syn keyword idlBaseTypeInt contained short long skipempty skipwhite nextgroup = idlSimpDecl 77syn keyword idlBaseType contained unsigned skipempty skipwhite nextgroup = idlBaseTypeInt 78syn region idlD1 contained start = "< "end = "> "skipempty skipwhite nextgroup = idlSimpDecl contains = idlString , idlLiteral 79syn keyword idlBaseType contained string skipempty skipwhite nextgroup = idlD1 , idlSimpDecl 80syn match idlBaseType contained "[ a-zA-Z0-9_ ] \+ [ \t ] * \(:: [ \t ] * [ a-zA-Z0-9_ ] \+\) * "skipempty skipwhite nextgroup = idlSimpDecl 81 82" Modules 83syn region idlModuleContent contained start = "{ "end = "} "skipempty skipwhite nextgroup = idlError , idlSemiColon contains = idlUnion , idlStruct , idlEnum , idlInterface , idlComment , idlTypedef , idlConst , idlException , idlModule 84syn match idlModuleName contained "[ a-zA-Z0-9_ ] \+ "skipempty skipwhite nextgroup = idlModuleContent , idlError , idlSemiColon 85syn keyword idlModule module skipempty skipwhite nextgroup = idlModuleName 86 87" Interfaces 88syn cluster idlCommentable contains = idlComment 89syn cluster idlContentCluster contains = idlUnion , idlStruct , idlEnum , idlROAttr , idlAttr , idlOp , idlOneWayOp , idlException , idlConst , idlTypedef , idlAttributes , idlErrorSquareBracket , idlErrorBracket , idlInterfaceSections 90 91syn region idlInterfaceContent contained start = "{ "end = "} "skipempty skipwhite nextgroup = idlError , idlSemiColon contains = @idlContentCluster , @idlCommentable 92syn match idlInheritFrom2 contained ", "skipempty skipwhite nextgroup = idlInheritFrom 93syn match idlInheritFrom contained "[ a-zA-Z0-9_ ] \+ [ \t ] * \(:: [ \t ] * [ a-zA-Z0-9_ ] \+\) * "skipempty skipwhite nextgroup = idlInheritFrom2 , idlInterfaceContent 94syn match idlInherit contained ": "skipempty skipwhite nextgroup = idlInheritFrom 95syn match idlInterfaceName contained "[ a-zA-Z0-9_ ] \+ "skipempty skipwhite nextgroup = idlInterfaceContent , idlInherit , idlError , idlSemiColon 96syn keyword idlInterface interface dispinterface skipempty skipwhite nextgroup = idlInterfaceName 97syn keyword idlInterfaceSections contained properties methods skipempty skipwhite nextgroup = idlSectionColon , idlError 98syn match idlSectionColon contained ": " 99 100 101syn match idlLibraryName contained "[ a-zA-Z0-9_ ] \+ "skipempty skipwhite nextgroup = idlLibraryContent , idlError , idlSemiColon 102syn keyword idlLibrary library skipempty skipwhite nextgroup = idlLibraryName 103syn region idlLibraryContent contained start = "{ "end = "} "skipempty skipwhite nextgroup = idlError , idlSemiColon contains = @idlCommentable , idlAttributes , idlErrorSquareBracket , idlErrorBracket , idlImportlib , idlCoclass , idlTypedef , idlInterface 104 105syn keyword idlImportlib contained importlib skipempty skipwhite nextgroup = idlStringArg 106syn region idlStringArg contained start = "( "end = ") "contains = idlString nextgroup = idlError , idlSemiColon , idlErrorBrace , idlErrorSquareBracket 107 108syn keyword idlCoclass coclass contained skipempty skipwhite nextgroup = idlCoclassName 109syn match idlCoclassName "[ a-zA-Z0-9_ ] \+ "contained skipempty skipwhite nextgroup = idlCoclassDefinition , idlError , idlSemiColon 110 111syn region idlCoclassDefinition contained start = "{ "end = "} "contains = idlCoclassAttributes , idlInterface , idlErrorBracket , idlErrorSquareBracket skipempty skipwhite nextgroup = idlError , idlSemiColon 112syn region idlCoclassAttributes contained start = +\[ +end = +] +skipempty skipwhite nextgroup = idlInterface contains = idlErrorBracket , idlErrorBrace , idlCoclassAttribute 113syn keyword idlCoclassAttribute contained default source 114"syn keyword idlInterface interface skipempty skipwhite nextgroup=idlInterfaceStubName 115 116syn match idlImportString +"\f\+" +skipempty skipwhite nextgroup = idlError , idlSemiColon 117syn keyword idlImport import skipempty skipwhite nextgroup = idlImportString 118 119syn region idlAttributes start = "\[ "end = "\] "contains = idlAttribute , idlAttributeParam , idlErrorBracket , idlErrorBrace , idlComment 120syn keyword idlAttribute contained propput propget propputref id helpstring object uuid pointer_default 121if ! exists ( 'idl_no_ms_extensions' ) 122syn keyword idlAttribute contained nonextensible dual version aggregatable restricted hidden noncreatable oleautomation 123endif 124syn region idlAttributeParam contained start = "( "end = ") "contains = idlString , idlUuid , idlLiteral , idlErrorBrace , idlErrorSquareBracket 125" skipwhite nextgroup=idlArraySize,idlParmList contains=idlArraySize,idlLiteral 126syn match idlErrorBrace contained "} " 127syn match idlErrorBracket contained ") " 128syn match idlErrorSquareBracket contained "\] " 129 130syn match idlUuid contained +[ 0-9a-zA-Z ] \{8}-\( [ 0-9a-zA-Z ] \{4}-\)\{3} [ 0-9a-zA-Z ] \{12} + 131 132" Raises 133syn keyword idlRaises contained raises skipempty skipwhite nextgroup = idlRaises , idlContext , idlError , idlSemiColon 134 135" Context 136syn keyword idlContext contained context skipempty skipwhite nextgroup = idlRaises , idlContext , idlError , idlSemiColon 137 138" Operation 139syn match idlParmList contained ", "skipempty skipwhite nextgroup = idlOpParms 140syn region idlArraySize contained start = "\[ "end = "\] "skipempty skipwhite nextgroup = idlArraySize , idlParmList contains = idlArraySize , idlLiteral 141syn match idlParmName contained "[ a-zA-Z0-9_ ] \+ "skipempty skipwhite nextgroup = idlParmList , idlArraySize 142syn keyword idlParmInt contained short long skipempty skipwhite nextgroup = idlParmName 143syn keyword idlParmType contained unsigned skipempty skipwhite nextgroup = idlParmInt 144syn region idlD3 contained start = "< "end = "> "skipempty skipwhite nextgroup = idlParmName contains = idlString , idlLiteral 145syn keyword idlParmType contained string skipempty skipwhite nextgroup = idlD3 , idlParmName 146syn keyword idlParmType contained void float double char boolean octet any skipempty skipwhite nextgroup = idlParmName 147syn match idlParmType contained "[ a-zA-Z0-9_ ] \+ [ \t ] * \(:: [ \t ] * [ a-zA-Z0-9_ ] \+\) * "skipempty skipwhite nextgroup = idlParmName 148syn keyword idlOpParms contained in out inout skipempty skipwhite nextgroup = idlParmType 149 150if ! exists ( 'idl_no_ms_extensions' ) 151syn keyword idlOpParms contained retval optional skipempty skipwhite nextgroup = idlParmType 152syn match idlOpParms contained +\<\(iid_is\|defaultvalue\)\s * ( [ ^) ] * ) +skipempty skipwhite nextgroup = idlParamType 153 154syn keyword idlVariantType contained BSTR VARIANT VARIANT_BOOL long short unsigned double CURRENCY DATE 155syn region idlSafeArray contained matchgroup = idlVariantType start = +SAFEARRAY(\s * +end = +) +contains = idlVariantType 156endif 157 158syn region idlOpContents contained start = "( "end = ") "skipempty skipwhite nextgroup = idlRaises , idlContext , idlError , idlSemiColon contains = idlOpParms , idlSafeArray , idlVariantType , @idlCommentable 159syn match idlOpName contained "[ a-zA-Z0-9_ ] \+ "skipempty skipwhite nextgroup = idlOpContents 160syn keyword idlOpInt contained short long skipempty skipwhite nextgroup = idlOpName 161syn region idlD2 contained start = "< "end = "> "skipempty skipwhite nextgroup = idlOpName contains = idlString , idlLiteral 162syn keyword idlOp contained unsigned skipempty skipwhite nextgroup = idlOpInt 163syn keyword idlOp contained string skipempty skipwhite nextgroup = idlD2 , idlOpName 164syn keyword idlOp contained void float double char boolean octet any skipempty skipwhite nextgroup = idlOpName 165syn match idlOp contained "[ a-zA-Z0-9_ ] \+ [ \t ] * \(:: [ \t ] * [ a-zA-Z0-9_ ] \+\) * "skipempty skipwhite nextgroup = idlOpName 166syn keyword idlOp contained void skipempty skipwhite nextgroup = idlOpName 167syn keyword idlOneWayOp contained oneway skipempty skipwhite nextgroup = idOp 168 169" Enum 170syn region idlEnumContents contained start = "{ "end = "} "skipempty skipwhite nextgroup = idlError , idlSemiColon , idlSimpDecl contains = idlId , idlAttributes , @idlCommentable 171syn match idlEnumName contained "[ a-zA-Z0-9_ ] \+ "skipempty skipwhite nextgroup = idlEnumContents 172syn keyword idlEnum enum skipempty skipwhite nextgroup = idlEnumName , idlEnumContents 173 174" Typedef 175syn keyword idlTypedef typedef skipempty skipwhite nextgroup = idlTypedefOtherTypeQualifier , idlDefBaseType , idlDefBaseTypeInt , idlDefSeqType , idlDefv1Enum , idlDefEnum , idlDefOtherType , idlDefAttributes , idlError 176 177if ! exists ( 'idl_no_extensions' ) 178syn keyword idlTypedefOtherTypeQualifier contained struct enum interface nextgroup = idlDefBaseType , idlDefBaseTypeInt , idlDefSeqType , idlDefv1Enum , idlDefEnum , idlDefOtherType , idlDefAttributes , idlError skipwhite 179 180syn region idlDefAttributes contained start = "\[ "end = "\] "contains = idlAttribute , idlAttributeParam , idlErrorBracket , idlErrorBrace skipempty skipwhite nextgroup = idlDefBaseType , idlDefBaseTypeInt , idlDefSeqType , idlDefv1Enum , idlDefEnum , idlDefOtherType , idlError 181 182syn keyword idlDefBaseType contained float double char boolean octet any skipempty skipwhite nextgroup = idlTypedefDecl , idlError 183syn keyword idlDefBaseTypeInt contained short long skipempty skipwhite nextgroup = idlTypedefDecl , idlError 184syn match idlDefOtherType contained +\<\k\+\> +skipempty nextgroup = idlTypedefDecl , idlError 185" syn keyword idlDefSeqType contained sequence skipempty skipwhite nextgroup=idlD4 186 187" Enum typedef 188syn keyword idlDefEnum contained enum skipempty skipwhite nextgroup = idlDefEnumName , idlDefEnumContents 189syn match idlDefEnumName contained "[ a-zA-Z0-9_ ] \+ "skipempty skipwhite nextgroup = idlDefEnumContents , idlTypedefDecl 190syn region idlDefEnumContents contained start = "{ "end = "} "skipempty skipwhite nextgroup = idlError , idlTypedefDecl contains = idlId , idlAttributes 191 192syn match idlTypedefDecl contained "[ a-zA-Z0-9_ ] \+ "skipempty skipwhite nextgroup = idlError , idlSemiColon 193endif 194 195" Struct 196syn region idlStructContent contained start = "{ "end = "} "skipempty skipwhite nextgroup = idlError , idlSemiColon , idlSimpDecl contains = idlBaseType , idlBaseTypeInt , idlSeqType , @idlCommentable , idlEnum , idlUnion 197syn match idlStructName contained "[ a-zA-Z0-9_ ] \+ "skipempty skipwhite nextgroup = idlStructContent 198syn keyword idlStruct struct skipempty skipwhite nextgroup = idlStructName 199 200" Exception 201syn keyword idlException exception skipempty skipwhite nextgroup = idlStructName 202 203" Union 204syn match idlColon contained ": "skipempty skipwhite nextgroup = idlCase , idlSeqType , idlBaseType , idlBaseTypeInt 205syn regionidlCaseLabel contained start= "" skip= "::" end=" :"me=e-1 skipempty skipwhite nextgroup=idlColon contains=idlLiteral,idlString 206syn keyword idlCase contained case skipempty skipwhite nextgroup = idlCaseLabel 207syn keyword idlCase contained default skipempty skipwhite nextgroup = idlColon 208syn region idlUnionContent contained start = "{ "end = "} "skipempty skipwhite nextgroup = idlError , idlSemiColon , idlSimpDecl contains = idlCase 209syn region idlSwitchType contained start = "( "end = ") "skipempty skipwhite nextgroup = idlUnionContent 210syn keyword idlUnionSwitch contained switch skipempty skipwhite nextgroup = idlSwitchType 211syn match idlUnionName contained "[ a-zA-Z0-9_ ] \+ "skipempty skipwhite nextgroup = idlUnionSwitch 212syn keyword idlUnion union skipempty skipwhite nextgroup = idlUnionName 213 214if ! exists ( 'idl_no_extensions' ) 215syn syncmatch idlInterfaceSync grouphereidlInterfaceContent "\<\(disp\)\=interface\>\s\+\k\+\s * :\s * \k\+\_s * { " skipempty skipwhite nextgroup=idlError,idlSemiColon contains=@idlContentCluster,@idlCommentable 216syn sync maxlines= 1000 minlines=100 217else 218syn sync lines= 200 219endif 220" syn sync fromstart 221 222if ! exists ( "did_idl_syntax_inits" ) 223let did_idl_syntax_inits = 1 224" The default methods for highlighting. Can be overridden later 225 226hi def link idlInclude Include 227hi def link idlPreProc PreProc 228hi def link idlPreCondit PreCondit 229hi def link idlDefine Macro 230hi def link idlIncluded String 231hi def link idlString String 232hi def link idlComment Comment 233hi def link idlTodo Todo 234hi def link idlLiteral Number 235hi def link idlUuid Number 236hi def link idlType Type 237hi def link idlVariantType idlType 238 239hi def link idlModule Keyword 240hi def link idlInterface Keyword 241hi def link idlEnum Keyword 242hi def link idlStruct Keyword 243hi def link idlUnion Keyword 244hi def link idlTypedef Keyword 245hi def link idlException Keyword 246hi def link idlTypedefOtherTypeQualifier keyword 247 248hi def link idlModuleName Typedef 249hi def link idlInterfaceName Typedef 250hi def link idlEnumName Typedef 251hi def link idlStructName Typedef 252hi def link idlUnionName Typedef 253 254hi def link idlBaseTypeInt idlType 255hi def link idlBaseType idlType 256hi def link idlSeqType idlType 257hi def link idlD1 Paren 258hi def link idlD2 Paren 259hi def link idlD3 Paren 260hi def link idlD4 Paren 261"hi def link idlArraySize Paren 262"hi def link idlArraySize1 Paren 263hi def link idlModuleContent Paren 264hi def link idlUnionContent Paren 265hi def link idlStructContent Paren 266hi def link idlEnumContents Paren 267hi def link idlInterfaceContent Paren 268 269hi def link idlSimpDecl Identifier 270hi def link idlROAttr StorageClass 271hi def link idlAttr Keyword 272hi def link idlConst StorageClass 273 274hi def link idlOneWayOp StorageClass 275hi def link idlOp idlType 276hi def link idlParmType idlType 277hi def link idlOpName Function 278hi def link idlOpParms SpecialComment 279hi def link idlParmName Identifier 280hi def link idlInheritFrom Identifier 281hi def link idlAttribute SpecialComment 282 283hi def link idlId Constant 284"hi def link idlCase Keyword 285hi def link idlCaseLabel Constant 286 287hi def link idlErrorBracket Error 288hi def link idlErrorBrace Error 289hi def link idlErrorSquareBracket Error 290 291hi def link idlImport Keyword 292hi def link idlImportString idlString 293hi def link idlCoclassAttribute StorageClass 294hi def link idlLibrary Keyword 295hi def link idlImportlib Keyword 296hi def link idlCoclass Keyword 297hi def link idlLibraryName Typedef 298hi def link idlCoclassName Typedef 299" hi def link idlLibraryContent guifg=red 300hi def link idlTypedefDecl Typedef 301hi def link idlDefEnum Keyword 302hi def link idlDefv1Enum Keyword 303hi def link idlDefEnumName Typedef 304hi def link idlDefEnumContents Paren 305hi def link idlDefBaseTypeInt idlType 306hi def link idlDefBaseType idlType 307hi def link idlDefSeqType idlType 308hi def link idlInterfaceSections Label 309 310if exists ( "idlsyntax_showerror" ) 311if exists ( "idlsyntax_showerror_soft" ) 312hi default idlError guibg = #d0ffd0 313else 314hi def link idlError Error 315endif 316endif 317endif 318 319let b: current_syntax = "idl" 320finally 321let & cpo = s: cpo_save 322unlet s: cpo_save 323endtry 324" vim: sw=2 et