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