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