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