aspvbs.vim 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. " Vim syntax file
  2. " Language: Microsoft VBScript Web Content (ASP)
  3. " Maintainer: Devin Weaver <ktohg@tritarget.com> (non-functional)
  4. " URL: http://tritarget.com/pub/vim/syntax/aspvbs.vim (broken)
  5. " Last Change: 2006 Jun 19
  6. " by Dan Casey
  7. " Version: $Revision: 1.3 $
  8. " Thanks to Jay-Jay <vim@jay-jay.net> for a syntax sync hack, hungarian
  9. " notation, and extra highlighting.
  10. " Thanks to patrick dehne <patrick@steidle.net> for the folding code.
  11. " Thanks to Dean Hall <hall@apt7.com> for testing the use of classes in
  12. " VBScripts which I've been too scared to do.
  13. " quit when a syntax file was already loaded
  14. if exists("b:current_syntax")
  15. finish
  16. endif
  17. if !exists("main_syntax")
  18. let main_syntax = 'aspvbs'
  19. endif
  20. runtime! syntax/html.vim
  21. unlet b:current_syntax
  22. syn cluster htmlPreProc add=AspVBScriptInsideHtmlTags
  23. " Colored variable names, if written in hungarian notation
  24. hi def AspVBSVariableSimple term=standout ctermfg=3 guifg=#99ee99
  25. hi def AspVBSVariableComplex term=standout ctermfg=3 guifg=#ee9900
  26. syn match AspVBSVariableSimple contained "\<\(bln\|byt\|dtm\=\|dbl\|int\|str\)\u\w*"
  27. syn match AspVBSVariableComplex contained "\<\(arr\|ary\|obj\)\u\w*"
  28. " Functions and methods that are in VB but will cause errors in an ASP page
  29. " This is helpful if you're porting VB code to ASP
  30. " I removed (Count, Item) because these are common variable names in AspVBScript
  31. syn keyword AspVBSError contained Val Str CVar CVDate DoEvents GoSub Return GoTo
  32. syn keyword AspVBSError contained Stop LinkExecute Add Type LinkPoke
  33. syn keyword AspVBSError contained LinkRequest LinkSend Declare Optional Sleep
  34. syn keyword AspVBSError contained ParamArray Static Erl TypeOf Like LSet RSet Mid StrConv
  35. " It may seem that most of these can fit into a keyword clause but keyword takes
  36. " priority over all so I can't get the multi-word matches
  37. syn match AspVBSError contained "\<Def[a-zA-Z0-9_]\+\>"
  38. syn match AspVBSError contained "^\s*Open\s\+"
  39. syn match AspVBSError contained "Debug\.[a-zA-Z0-9_]*"
  40. syn match AspVBSError contained "^\s*[a-zA-Z0-9_]\+:"
  41. syn match AspVBSError contained "[a-zA-Z0-9_]\+![a-zA-Z0-9_]\+"
  42. syn match AspVBSError contained "^\s*#.*$"
  43. syn match AspVBSError contained "\<As\s\+[a-zA-Z0-9_]*"
  44. syn match AspVBSError contained "\<End\>\|\<Exit\>"
  45. syn match AspVBSError contained "\<On\s\+Error\>\|\<On\>\|\<Error\>\|\<Resume\s\+Next\>\|\<Resume\>"
  46. syn match AspVBSError contained "\<Option\s\+\(Base\|Compare\|Private\s\+Module\)\>"
  47. " This one I want 'cause I always seem to mis-spell it.
  48. syn match AspVBSError contained "Respon\?ce\.\S*"
  49. syn match AspVBSError contained "Respose\.\S*"
  50. " When I looked up the VBScript syntax it mentioned that Property Get/Set/Let
  51. " statements are illegal, however, I have received reports that they do work.
  52. " So I commented it out for now.
  53. " syn match AspVBSError contained "\<Property\s\+\(Get\|Let\|Set\)\>"
  54. " AspVBScript Reserved Words.
  55. syn match AspVBSStatement contained "\<On\s\+Error\s\+\(Resume\s\+Next\|goto\s\+0\)\>\|\<Next\>"
  56. syn match AspVBSStatement contained "\<End\s\+\(If\|For\|Select\|Class\|Function\|Sub\|With\|Property\)\>"
  57. syn match AspVBSStatement contained "\<Exit\s\+\(Do\|For\|Sub\|Function\)\>"
  58. syn match AspVBSStatement contained "\<Exit\s\+\(Do\|For\|Sub\|Function\|Property\)\>"
  59. syn match AspVBSStatement contained "\<Option\s\+Explicit\>"
  60. syn match AspVBSStatement contained "\<For\s\+Each\>\|\<For\>"
  61. syn match AspVBSStatement contained "\<Set\>"
  62. syn keyword AspVBSStatement contained Call Class Const Default Dim Do Loop Erase And
  63. syn keyword AspVBSStatement contained Function If Then Else ElseIf Or
  64. syn keyword AspVBSStatement contained Private Public Randomize ReDim
  65. syn keyword AspVBSStatement contained Select Case Sub While With Wend Not
  66. " AspVBScript Functions
  67. syn keyword AspVBSFunction contained Abs Array Asc Atn CBool CByte CCur CDate CDbl
  68. syn keyword AspVBSFunction contained Chr CInt CLng Cos CreateObject CSng CStr Date
  69. syn keyword AspVBSFunction contained DateAdd DateDiff DatePart DateSerial DateValue
  70. syn keyword AspVBSFunction contained Date Day Exp Filter Fix FormatCurrency
  71. syn keyword AspVBSFunction contained FormatDateTime FormatNumber FormatPercent
  72. syn keyword AspVBSFunction contained GetObject Hex Hour InputBox InStr InStrRev Int
  73. syn keyword AspVBSFunction contained IsArray IsDate IsEmpty IsNull IsNumeric
  74. syn keyword AspVBSFunction contained IsObject Join LBound LCase Left Len LoadPicture
  75. syn keyword AspVBSFunction contained Log LTrim Mid Minute Month MonthName MsgBox Now
  76. syn keyword AspVBSFunction contained Oct Replace RGB Right Rnd Round RTrim
  77. syn keyword AspVBSFunction contained ScriptEngine ScriptEngineBuildVersion
  78. syn keyword AspVBSFunction contained ScriptEngineMajorVersion
  79. syn keyword AspVBSFunction contained ScriptEngineMinorVersion Second Sgn Sin Space
  80. syn keyword AspVBSFunction contained Split Sqr StrComp StrReverse String Tan Time Timer
  81. syn keyword AspVBSFunction contained TimeSerial TimeValue Trim TypeName UBound UCase
  82. syn keyword AspVBSFunction contained VarType Weekday WeekdayName Year
  83. " AspVBScript Methods
  84. syn keyword AspVBSMethods contained Add AddFolders BuildPath Clear Close Copy
  85. syn keyword AspVBSMethods contained CopyFile CopyFolder CreateFolder CreateTextFile
  86. syn keyword AspVBSMethods contained Delete DeleteFile DeleteFolder DriveExists
  87. syn keyword AspVBSMethods contained Exists FileExists FolderExists
  88. syn keyword AspVBSMethods contained GetAbsolutePathName GetBaseName GetDrive
  89. syn keyword AspVBSMethods contained GetDriveName GetExtensionName GetFile
  90. syn keyword AspVBSMethods contained GetFileName GetFolder GetParentFolderName
  91. syn keyword AspVBSMethods contained GetSpecialFolder GetTempName Items Keys Move
  92. syn keyword AspVBSMethods contained MoveFile MoveFolder OpenAsTextStream
  93. syn keyword AspVBSMethods contained OpenTextFile Raise Read ReadAll ReadLine Remove
  94. syn keyword AspVBSMethods contained RemoveAll Skip SkipLine Write WriteBlankLines
  95. syn keyword AspVBSMethods contained WriteLine
  96. syn match AspVBSMethods contained "Response\.\w*"
  97. " Colorize boolean constants:
  98. syn keyword AspVBSMethods contained true false
  99. " AspVBScript Number Constants
  100. " Integer number, or floating point number without a dot.
  101. syn match AspVBSNumber contained "\<\d\+\>"
  102. " Floating point number, with dot
  103. syn match AspVBSNumber contained "\<\d\+\.\d*\>"
  104. " Floating point number, starting with a dot
  105. syn match AspVBSNumber contained "\.\d\+\>"
  106. " String and Character Constants
  107. " removed (skip=+\\\\\|\\"+) because VB doesn't have backslash escaping in
  108. " strings (or does it?)
  109. syn region AspVBSString contained start=+"+ end=+"+ keepend
  110. " AspVBScript Comments
  111. syn region AspVBSComment contained start="^REM\s\|\sREM\s" end="$" contains=AspVBSTodo keepend
  112. syn region AspVBSComment contained start="^'\|\s'" end="$" contains=AspVBSTodo keepend
  113. " misc. Commenting Stuff
  114. syn keyword AspVBSTodo contained TODO FIXME
  115. " Cosmetic syntax errors commanly found in VB but not in AspVBScript
  116. " AspVBScript doesn't use line numbers
  117. syn region AspVBSError contained start="^\d" end="\s" keepend
  118. " AspVBScript also doesn't have type defining variables
  119. syn match AspVBSError contained "[a-zA-Z0-9_][\$&!#]"ms=s+1
  120. " Since 'a%' is a VB variable with a type and in AspVBScript you can have 'a%>'
  121. " I have to make a special case so 'a%>' won't show as an error.
  122. syn match AspVBSError contained "[a-zA-Z0-9_]%\($\|[^>]\)"ms=s+1
  123. " Top Cluster
  124. syn cluster AspVBScriptTop contains=AspVBSStatement,AspVBSFunction,AspVBSMethods,AspVBSNumber,AspVBSString,AspVBSComment,AspVBSError,AspVBSVariableSimple,AspVBSVariableComplex
  125. " Folding
  126. syn region AspVBSFold start="^\s*\(class\)\s\+.*$" end="^\s*end\s\+\(class\)\>.*$" fold contained transparent keepend
  127. syn region AspVBSFold start="^\s*\(private\|public\)\=\(\s\+default\)\=\s\+\(sub\|function\)\s\+.*$" end="^\s*end\s\+\(function\|sub\)\>.*$" fold contained transparent keepend
  128. " Define AspVBScript delimiters
  129. " <%= func("string_with_%>_in_it") %> This is illegal in ASP syntax.
  130. syn region AspVBScriptInsideHtmlTags keepend matchgroup=Delimiter start=+<%=\=+ end=+%>+ contains=@AspVBScriptTop, AspVBSFold
  131. syn region AspVBScriptInsideHtmlTags keepend matchgroup=Delimiter start=+<script\s\+language="\=vbscript"\=[^>]*\s\+runatserver[^>]*>+ end=+</script>+ contains=@AspVBScriptTop
  132. " Synchronization
  133. " syn sync match AspVBSSyncGroup grouphere AspVBScriptInsideHtmlTags "<%"
  134. " This is a kludge so the HTML will sync properly
  135. syn sync match htmlHighlight grouphere htmlTag "%>"
  136. " Define the default highlighting.
  137. " Only when an item doesn't have highlighting yet
  138. "hi def link AspVBScript Special
  139. hi def link AspVBSLineNumber Comment
  140. hi def link AspVBSNumber Number
  141. hi def link AspVBSError Error
  142. hi def link AspVBSStatement Statement
  143. hi def link AspVBSString String
  144. hi def link AspVBSComment Comment
  145. hi def link AspVBSTodo Todo
  146. hi def link AspVBSFunction Identifier
  147. hi def link AspVBSMethods PreProc
  148. hi def link AspVBSEvents Special
  149. hi def link AspVBSTypeSpecifier Type
  150. let b:current_syntax = "aspvbs"
  151. if main_syntax == 'aspvbs'
  152. unlet main_syntax
  153. endif
  154. " vim: ts=8:sw=2:sts=0:noet