3 " Maintainer: Claudio Fleiner <claudio@fleiner.com>
4 " URL: http://www.fleiner.com/vim/syntax/javascript.vim
5 " Last Change: 2001 Apr 26
7 " For version 5.x: Clear all syntax items
8 " For version 6.x: Quit when a syntax file was already loaded
9 if !exists("main_syntax")
12 elseif exists("b:current_syntax")
15 let main_syntax = 'javascript'
21 syn match javaScriptLineComment "\/\/.*$"
22 syn match javaScriptCommentSkip "^[ \t]*\*\($\|[ \t]\+\)"
23 syn region javaScriptCommentString start=+"+ skip=+\\\\\|\\"+ end=+"+ end=+\*/+me=s-1,he=s-1 contains=javaScriptSpecial,javaScriptCommentSkip,@htmlPreproc
24 syn region javaScriptComment2String start=+"+ skip=+\\\\\|\\"+ end=+$\|"+ contains=javaScriptSpecial,@htmlPreproc
25 syn region javaScriptComment start="/\*" end="\*/" contains=javaScriptCommentString,javaScriptCharacter,javaScriptNumber
26 syn match javaScriptSpecial "\\\d\d\d\|\\."
27 syn region javaScriptStringD start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=javaScriptSpecial,@htmlPreproc
28 syn region javaScriptStringS start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=javaScriptSpecial,@htmlPreproc
29 syn match javaScriptSpecialCharacter "'\\.'"
30 syn match javaScriptNumber "-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>"
31 syn keyword javaScriptConditional if else
32 syn keyword javaScriptRepeat while for
33 syn keyword javaScriptBranch break continue
34 syn keyword javaScriptOperator new in
35 syn keyword javaScriptType this var
36 syn keyword javaScriptStatement return with
37 syn keyword javaScriptFunction function
38 syn keyword javaScriptBoolean true false
39 syn match javaScriptBraces "[{}]"
41 " catch errors caused by wrong parenthesis
42 syn match javaScriptInParen contained "[{}]"
43 syn region javaScriptParen transparent start="(" end=")" contains=javaScriptParen,javaScript.*
44 syn match javaScrParenError ")"
46 if main_syntax == "javascript"
47 syn sync ccomment javaScriptComment
50 " Define the default highlighting.
51 " For version 5.7 and earlier: only when not done already
52 " For version 5.8 and later: only when an item doesn't have highlighting yet
53 if version >= 508 || !exists("did_javascript_syn_inits")
55 let did_javascript_syn_inits = 1
56 command -nargs=+ HiLink hi link <args>
58 command -nargs=+ HiLink hi def link <args>
60 HiLink javaScriptComment Comment
61 HiLink javaScriptLineComment Comment
62 HiLink javaScriptSpecial Special
63 HiLink javaScriptStringS String
64 HiLink javaScriptStringD String
65 HiLink javaScriptCharacter Character
66 HiLink javaScriptSpecialCharacter javaScriptSpecial
67 HiLink javaScriptNumber javaScriptValue
68 HiLink javaScriptConditional Conditional
69 HiLink javaScriptRepeat Repeat
70 HiLink javaScriptBranch Conditional
71 HiLink javaScriptOperator Operator
72 HiLink javaScriptType Type
73 HiLink javaScriptStatement Statement
74 HiLink javaScriptFunction Function
75 HiLink javaScriptBraces Function
76 HiLink javaScriptError Error
77 HiLink javaScrParenError javaScriptError
78 HiLink javaScriptInParen javaScriptError
79 HiLink javaScriptBoolean Boolean
83 let b:current_syntax = "javascript"
84 if main_syntax == 'javascript'