comparison vendor/vim-syntax/javascript.vim @ 634:ced2ee9efd9f

Update various syntaxes to the ones in vim repo
author nanaya <me@nanaya.pro>
date Tue, 17 Dec 2019 20:21:23 +0900
parents 035b23bb15da
children c548e83e4c57
comparison
equal deleted inserted replaced
633:f382ac2f585e 634:ced2ee9efd9f
1 " Vim syntax file 1 " Vim syntax file
2 " Language: JavaScript 2 " Language: JavaScript
3 " Maintainer: Jose Elera <https://github.com/jelera> 3 " Maintainer: Claudio Fleiner <claudio@fleiner.com>
4 " https://jelera.github.io 4 " Updaters: Scott Shattuck (ss) <ss@technicalpursuit.com>
5 " Last Modified: Thu 11 Jul 2019 11:53:28 AM CDT 5 " URL: http://www.fleiner.com/vim/syntax/javascript.vim
6 " Version: 0.8.2 6 " Changes: (ss) added keywords, reserved words, and other identifiers
7 " Credits: Zhao Yi, Claudio Fleiner, Scott Shattuck (This file is based 7 " (ss) repaired several quoting and grouping glitches
8 " on their hard work), gumnos (From the #vim IRC Channel in 8 " (ss) fixed regex parsing issue with multiple qualifiers [gi]
9 " Freenode), all the contributors at this project's github page 9 " (ss) additional factoring of keywords, globals, and members
10 " (https://github.com/jelera/vim-javascript-syntax/graphs/contributors) 10 " Last Change: 2019 Sep 27
11 " 2013 Jun 12: adjusted javaScriptRegexpString (Kevin Locke)
12 " 2018 Apr 14: adjusted javaScriptRegexpString (LongJohnCoder)
13
14 " tuning parameters:
15 " unlet javaScript_fold
11 16
12 if !exists("main_syntax") 17 if !exists("main_syntax")
13 if version < 600 18 " quit when a syntax file was already loaded
14 syntax clear 19 if exists("b:current_syntax")
15 elseif exists("b:current_syntax") 20 finish
16 finish 21 endif
17 endif 22 let main_syntax = 'javascript'
18 let main_syntax = 'javascript' 23 elseif exists("b:current_syntax") && b:current_syntax == "javascript"
24 finish
19 endif 25 endif
20 26
21 " Drop fold if it set but vim doesn't support it. 27 let s:cpo_save = &cpo
22 if version < 600 && exists("javaScript_fold") 28 set cpo&vim
23 unlet javaScript_fold 29
30
31 syn keyword javaScriptCommentTodo TODO FIXME XXX TBD contained
32 syn match javaScriptLineComment "\/\/.*" contains=@Spell,javaScriptCommentTodo
33 syn match javaScriptCommentSkip "^[ \t]*\*\($\|[ \t]\+\)"
34 syn region javaScriptComment start="/\*" end="\*/" contains=@Spell,javaScriptCommentTodo
35 syn match javaScriptSpecial "\\\d\d\d\|\\."
36 syn region javaScriptStringD start=+"+ skip=+\\\\\|\\"+ end=+"\|$+ contains=javaScriptSpecial,@htmlPreproc
37 syn region javaScriptStringS start=+'+ skip=+\\\\\|\\'+ end=+'\|$+ contains=javaScriptSpecial,@htmlPreproc
38 syn region javaScriptStringT start=+`+ skip=+\\\\\|\\`+ end=+`+ contains=javaScriptSpecial,javaScriptEmbed,@htmlPreproc
39
40 syn region javaScriptEmbed start=+${+ end=+}+ contains=@javaScriptEmbededExpr
41
42 syn match javaScriptSpecialCharacter "'\\.'"
43 syn match javaScriptNumber "-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>"
44 syn region javaScriptRegexpString start=+[,(=+]\s*/[^/*]+ms=e-1,me=e-1 skip=+\\\\\|\\/+ end=+/[gimuys]\{0,2\}\s*$+ end=+/[gimuys]\{0,2\}\s*[+;.,)\]}]+me=e-1 end=+/[gimuys]\{0,2\}\s\+\/+me=e-1 contains=@htmlPreproc,javaScriptComment oneline
45
46 syn keyword javaScriptConditional if else switch
47 syn keyword javaScriptRepeat while for do in
48 syn keyword javaScriptBranch break continue
49 syn keyword javaScriptOperator new delete instanceof typeof
50 syn keyword javaScriptType Array Boolean Date Function Number Object String RegExp
51 syn keyword javaScriptStatement return with await
52 syn keyword javaScriptBoolean true false
53 syn keyword javaScriptNull null undefined
54 syn keyword javaScriptIdentifier arguments this var let
55 syn keyword javaScriptLabel case default
56 syn keyword javaScriptException try catch finally throw
57 syn keyword javaScriptMessage alert confirm prompt status
58 syn keyword javaScriptGlobal self window top parent
59 syn keyword javaScriptMember document event location
60 syn keyword javaScriptDeprecated escape unescape
61 syn keyword javaScriptReserved abstract boolean byte char class const debugger double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile async
62
63 syn cluster javaScriptEmbededExpr contains=javaScriptBoolean,javaScriptNull,javaScriptIdentifier,javaScriptStringD,javaScriptStringS,javaScriptStringT
64
65 if exists("javaScript_fold")
66 syn match javaScriptFunction "\<function\>"
67 syn region javaScriptFunctionFold start="\<function\>.*[^};]$" end="^\z1}.*$" transparent fold keepend
68
69 syn sync match javaScriptSync grouphere javaScriptFunctionFold "\<function\>"
70 syn sync match javaScriptSync grouphere NONE "^}"
71
72 setlocal foldmethod=syntax
73 setlocal foldtext=getline(v:foldstart)
74 else
75 syn keyword javaScriptFunction function
76 syn match javaScriptBraces "[{}\[\]]"
77 syn match javaScriptParens "[()]"
24 endif 78 endif
25 79
26 "" Remove dollar sign from identifier when embedded in a PHP file 80 syn sync fromstart
27 if &filetype == 'javascript' 81 syn sync maxlines=100
28 setlocal iskeyword+=$ 82
83 if main_syntax == "javascript"
84 syn sync ccomment javaScriptComment
29 endif 85 endif
30 86
31 syntax sync fromstart 87 " Define the default highlighting.
88 " Only when an item doesn't have highlighting yet
89 hi def link javaScriptComment Comment
90 hi def link javaScriptLineComment Comment
91 hi def link javaScriptCommentTodo Todo
92 hi def link javaScriptSpecial Special
93 hi def link javaScriptStringS String
94 hi def link javaScriptStringD String
95 hi def link javaScriptStringT String
96 hi def link javaScriptCharacter Character
97 hi def link javaScriptSpecialCharacter javaScriptSpecial
98 hi def link javaScriptNumber javaScriptValue
99 hi def link javaScriptConditional Conditional
100 hi def link javaScriptRepeat Repeat
101 hi def link javaScriptBranch Conditional
102 hi def link javaScriptOperator Operator
103 hi def link javaScriptType Type
104 hi def link javaScriptStatement Statement
105 hi def link javaScriptFunction Function
106 hi def link javaScriptBraces Function
107 hi def link javaScriptError Error
108 hi def link javaScrParenError javaScriptError
109 hi def link javaScriptNull Keyword
110 hi def link javaScriptBoolean Boolean
111 hi def link javaScriptRegexpString String
32 112
33 "" syntax coloring for Node.js shebang line 113 hi def link javaScriptIdentifier Identifier
34 syntax match shebang "^#!.*" 114 hi def link javaScriptLabel Label
35 hi link shebang Comment 115 hi def link javaScriptException Exception
36 116 hi def link javaScriptMessage Keyword
37 " Statement Keywords {{{ 117 hi def link javaScriptGlobal Keyword
38 syntax keyword javaScriptSource import export from 118 hi def link javaScriptMember Keyword
39 syntax keyword javaScriptIdentifier arguments this let var void yield async await const 119 hi def link javaScriptDeprecated Exception
40 syntax keyword javaScriptOperator delete new instanceof typeof 120 hi def link javaScriptReserved Keyword
41 syntax keyword javaScriptBoolean true false 121 hi def link javaScriptDebug Debug
42 syntax keyword javaScriptNull null undefined 122 hi def link javaScriptConstant Label
43 syntax keyword javaScriptMessage alert confirm prompt status 123 hi def link javaScriptEmbed Special
44 syntax keyword javaScriptGlobal self top parent
45 syntax keyword javaScriptDeprecated escape unescape applets alinkColor bgColor fgColor linkColor vlinkColor xmlEncoding
46 syntax keyword javaScriptConditional if else switch
47 syntax keyword javaScriptRepeat do while for in of
48 syntax keyword javaScriptBranch break continue
49 syntax keyword javaScriptLabel case default
50 syntax keyword javaScriptPrototype prototype
51 syntax keyword javaScriptStatement return with
52 syntax keyword javaScriptGlobalObjects Array Boolean Date Function Math Number Object RegExp String
53 syntax keyword javaScriptExceptions try catch throw finally Error EvalError RangeError ReferenceError SyntaxError TypeError URIError
54 syntax keyword javaScriptReserved abstract all enum int short boolean export interface static byte extends long super char final native synchronized class float package throws goto private transient debugger implements protected volatile double import public
55 "}}}
56 " Comments {{{
57 syntax keyword javaScriptCommentTodo TODO FIXME XXX TBD OPTIMIZE HACK REVIEW contained
58 syntax match javaScriptLineComment "\/\/.*" contains=@Spell,javaScriptCommentTodo
59 syntax match javaScriptCommentSkip "^[ \t]*\*\($\|[ \t]\+\)"
60 syntax region javaScriptComment start="/\*" end="\*/" contains=@Spell,javaScriptCommentTodo
61 "}}}
62 " JSDoc support {{{
63 if !exists("javascript_ignore_javaScriptdoc")
64 syntax case ignore
65
66 " syntax coloring for JSDoc comments (HTML)
67 "unlet b:current_syntax
68
69 syntax region javaScriptDocComment matchgroup=javaScriptComment start="/\*\*\s*$" end="\*/" contains=javaScriptDocTags,javaScriptCommentTodo,@javaScriptHtml,jsInJsdocExample,@Spell fold
70 syntax match javaScriptDocTags contained "@\(abstract\|access\|alias\|arg\|argument\|augments\|author\|borrows\|callback\|class\|classdesc\|const\|constant\|constructor\|constructs\|copyright\|default\|defaultvalue\|deprecated\|desc\|description\|emits\|enum\|event\|example\|exception\|exports\|extends\|external\|file\|fileoverview\|fires\|func\|function\|global\|host\|ignore\|implements\|inheritdoc\|inner\|instance\|interface\|kind\|lends\|license\|link\|linkcode\|linkplain\|listens\|member\|memberof\|method\|mixes\|mixin\|module\|name\|namespace\|override\|overview\|param\|private\|prop\|property\|cfg\|protected\|public\|readonly\|requires\|return\|returns\|see\|since\|static\|summary\|this\|throws\|todo\|tutorial\|tutorial\|type\|typedef\|var\|variation\|version\|virtual\)\>" nextgroup=javaScriptDocParam,javaScriptDocSeeTag skipwhite
71 syntax match javaScriptDocParam contained "\%(#\|\w\|\.\|:\|\/\)\+"
72 syntax region javaScriptDocSeeTag contained matchgroup=javaScriptDocSeeTag start="{" end="}" contains=javaScriptDocTags
73
74 syntax case match
75 endif
76 syntax case match
77 "}}}
78 " Strings, Numbers and Regex Highlight {{{
79 syntax match javaScriptSpecial "\\\d\d\d\|\\."
80 syntax region javaScriptString start=+"+ skip=+\\\\\|\\"+ end=+"\|$+ contains=javaScriptSpecial,@htmlPreproc
81 syntax region javaScriptString start=+'+ skip=+\\\\\|\\'+ end=+'\|$+ contains=javaScriptSpecial,@htmlPreproc
82
83 syntax match javaScriptSpecialCharacter "'\\.'"
84 syntax match javaScriptNumber "-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>"
85 syntax region javaScriptRegexpString start=+/[^/*]+me=e-1 skip=+\\\\\|\\/+ end=+/[gim]\{0,2\}\s*$+ end=+/[gim]\{0,2\}\s*[;.,)\]}]+me=e-1 contains=@htmlPreproc oneline
86 syntax match javaScriptFloat /\<-\=\%(\d\+\.\d\+\|\d\+\.\|\.\d\+\)\%([eE][+-]\=\d\+\)\=\>/
87 "}}}
88 " DOM, Browser and Ajax Support {{{
89 syntax keyword javaScriptBrowserObjects window navigator screen history location console
90
91 syntax keyword javaScriptDOMObjects document event HTMLElement Anchor Area Base Body Button Form Frame Frameset Image Link Meta Option Select Style Table TableCell TableRow Textarea
92 syntax keyword javaScriptDOMMethods createTextNode createElement insertBefore replaceChild removeChild appendChild hasChildNodes cloneNode normalize isSupported hasAttributes getAttribute setAttribute removeAttribute getAttributeNode setAttributeNode removeAttributeNode getElementsByTagName hasAttribute getElementById adoptNode close compareDocumentPosition createAttribute createCDATASection createComment createDocumentFragment createElementNS createEvent createExpression createNSResolver createProcessingInstruction createRange createTreeWalker elementFromPoint evaluate getBoxObjectFor getElementsByClassName getSelection getUserData hasFocus importNode
93 syntax keyword javaScriptDOMProperties nodeName nodeValue nodeType parentNode childNodes firstChild lastChild previousSibling nextSibling attributes ownerDocument namespaceURI prefix localName tagName
94 124
95 125
96 syntax keyword javaScriptLocalStorageObjects localStorage
97 syntax keyword javaScriptLocalStorageMethods setItem getItem removeItem
98
99 syntax keyword javaScriptAjaxObjects XMLHttpRequest
100 syntax keyword javaScriptAjaxProperties readyState responseText responseXML statusText
101 syntax keyword javaScriptAjaxMethods onreadystatechange abort getAllResponseHeaders getResponseHeader open send setRequestHeader
102
103 syntax keyword javaScriptFetchAPIObjects Response Promise
104 syntax keyword javaScriptFetchAPIMethods fetch then response clone redirect arrayBuffer blob formData allSettled race reject resolve
105 syntax keyword javaScriptFetchAPIProperties headers ok redirected url useFinalURL bodyUsed
106
107 syntax keyword javaScriptJSONObject JSON
108 syntax keyword javaScriptJSONMethods json stringify parse
109
110 syntax keyword javaScriptPropietaryObjects ActiveXObject
111 syntax keyword javaScriptPropietaryMethods attachEvent detachEvent cancelBubble returnValue
112
113 syntax keyword javaScriptHtmlElemProperties className clientHeight clientLeft clientTop clientWidth dir href id innerHTML lang length offsetHeight offsetLeft offsetParent offsetTop offsetWidth scrollHeight scrollLeft scrollTop scrollWidth style tabIndex target title
114
115 syntax keyword javaScriptEventListenerKeywords blur click focus mouseover mouseout load item
116
117 syntax keyword javaScriptEventListenerMethods scrollIntoView addEventListener dispatchEvent removeEventListener preventDefault stopPropagation
118 " }}}
119 " DOM/HTML5/CSS specified things {{{
120 " Web API Interfaces (very long list of keywords) {{{
121 syntax keyword javaScriptWebAPI AbstractWorker AnalyserNode AnimationEvent App Apps ArrayBuffer ArrayBufferView Attr AudioBuffer AudioBufferSourceNode AudioContext AudioDestinationNode AudioListener AudioNode AudioParam AudioProcessingEvent BatteryManager BiquadFilterNode Blob BlobBuilder BlobEvent CallEvent CameraCapabilities CameraControl CameraManager CanvasGradient CanvasImageSource CanvasPattern CanvasPixelArray CanvasRenderingContext2D CaretPosition CDATASection ChannelMergerNode ChannelSplitterNode CharacterData ChildNode ChromeWorker ClipboardEvent CloseEvent Comment CompositionEvent Connection Console ContactManager ConvolverNode Coordinates CSS CSSConditionRule CSSGroupingRule CSSKeyframeRule CSSKeyframesRule CSSMediaRule CSSNamespaceRule CSSPageRule CSSRule CSSRuleList CSSStyleDeclaration CSSStyleRule CSSStyleSheet CSSSupportsRule CustomEvent
122 syntax keyword javaScriptWebAPI DataTransfer DataView DedicatedWorkerGlobalScope DelayNode DeviceAcceleration DeviceLightEvent DeviceMotionEvent DeviceOrientationEvent DeviceProximityEvent DeviceRotationRate DeviceStorage DeviceStorageChangeEvent DirectoryEntry DirectoryEntrySync DirectoryReader DirectoryReaderSync Document DocumentFragment DocumentTouch DocumentType DOMConfiguration DOMCursor DOMError DOMErrorHandler DOMException DOMHighResTimeStamp DOMImplementation DOMImplementationList DOMImplementationSource DOMLocator DOMObject DOMParser DOMRequest DOMString DOMStringList DOMStringMap DOMTimeStamp DOMTokenList DOMUserData DynamicsCompressorNode
123 syntax keyword javaScriptWebAPI Element ElementTraversal Entity EntityReference Entry EntrySync ErrorEvent Event EventListener EventSource EventTarget Extensions File FileEntry FileEntrySync FileError FileException FileList FileReader FileSystem FileSystemSync Float32Array Float64Array FMRadio FocusEvent FormData GainNode Geolocation History
124 syntax keyword javaScriptWebAPI HTMLAnchorElement HTMLAreaElement HTMLAudioElement HTMLBaseElement HTMLBaseFontElement HTMLBodyElement HTMLBRElement HTMLButtonElement HTMLCanvasElement HTMLCollection HTMLDataElement HTMLDataListElement HTMLDivElement HTMLDListElement HTMLDocument HTMLElement HTMLEmbedElement HTMLFieldSetElement HTMLFormControlsCollection HTMLFormElement HTMLHeadElement HTMLHeadingElement HTMLHRElement HTMLHtmlElement HTMLIFrameElement HTMLImageElement HTMLInputElement HTMLIsIndexElement HTMLKeygenElement HTMLLabelElement HTMLLegendElement HTMLLIElement HTMLLinkElement HTMLMapElement HTMLMediaElement HTMLMetaElement HTMLMeterElement HTMLModElement HTMLObjectElement HTMLOListElement HTMLOptGroupElement HTMLOptionElement HTMLOptionsCollection HTMLOutputElement HTMLParagraphElement HTMLParamElement HTMLPreElement HTMLProgressElement HTMLQuoteElement HTMLScriptElement HTMLSelectElement HTMLSourceElement HTMLSpanElement HTMLStyleElement HTMLTableCaptionElement HTMLTableCellElement HTMLTableColElement HTMLTableElement HTMLTableRowElement HTMLTableSectionElement HTMLTextAreaElement HTMLTimeElement HTMLTitleElement HTMLTrackElement HTMLUListElement HTMLUnknownElement HTMLVideoElement
125 syntax keyword javaScriptWebAPI IDBCursor IDBCursorWithValue IDBDatabase IDBDatabaseException IDBEnvironment IDBFactory IDBIndex IDBKeyRange IDBObjectStore IDBOpenDBRequest IDBRequest IDBTransaction IDBVersionChangeEvent ImageData Int16Array Int32Array Int8Array KeyboardEvent LinkStyle LocalFileSystem LocalFileSystemSync Location MediaQueryList MediaQueryListListener MediaSource MediaStream MediaStreamTrack MessageEvent MouseEvent MouseScrollEvent MouseWheelEvent MozActivity MozActivityOptions MozActivityRequestHandler MozAlarmsManager MozContact MozContactChangeEvent MozIccManager MozMmsEvent MozMmsMessage MozMobileCellInfo MozMobileCFInfo MozMobileConnection MozMobileConnectionInfo MozMobileICCInfo MozMobileMessageManager MozMobileMessageThread MozMobileNetworkInfo MozNetworkStats MozNetworkStatsData MozNetworkStatsManager MozSettingsEvent MozSmsEvent MozSmsFilter MozSmsManager MozSmsMessage MozSmsSegmentInfo MozTimeManager MozWifiConnectionInfoEvent MutationObserver
126 syntax keyword javaScriptWebAPI NamedNodeMap NameList Navigator NavigatorGeolocation NavigatorID NavigatorLanguage NavigatorOnLine NavigatorPlugins NetworkInformation Node NodeFilter NodeIterator NodeList Notation Notification NotifyAudioAvailableEvent OfflineAudioCompletionEvent OfflineAudioContext PannerNode ParentNode Performance PerformanceNavigation PerformanceTiming Plugin PluginArray Position PositionError PositionOptions PowerManager ProcessingInstruction ProgressEvent PromiseResolver PushManager
127 syntax keyword javaScriptWebAPI Range ScriptProcessorNode Selection SettingsLock SettingsManager SharedWorker StyleSheet StyleSheetList SVGAElement SVGAngle SVGAnimateColorElement SVGAnimatedAngle SVGAnimatedBoolean SVGAnimatedEnumeration SVGAnimatedInteger SVGAnimatedLengthList SVGAnimatedNumber SVGAnimatedNumberList SVGAnimatedPoints SVGAnimatedPreserveAspectRatio SVGAnimatedRect SVGAnimatedString SVGAnimatedTransformList SVGAnimateElement SVGAnimateMotionElement SVGAnimateTransformElement SVGAnimationElement SVGCircleElement SVGClipPathElement SVGCursorElement SVGDefsElement SVGDescElement SVGElement SVGEllipseElement SVGFilterElement SVGFontElement SVGFontFaceElement SVGFontFaceFormatElement SVGFontFaceNameElement SVGFontFaceSrcElement SVGFontFaceUriElement
128 syntax keyword javaScriptWebAPI SVGForeignObjectElement SVGGElement SVGGlyphElement SVGGradientElement SVGHKernElement SVGImageElement SVGLength SVGLengthList SVGLinearGradientElement SVGLineElement SVGMaskElement SVGMatrix SVGMissingGlyphElement SVGMPathElement SVGNumber SVGNumberList SVGPathElement SVGPatternElement SVGPolygonElement SVGPolylineElement SVGPreserveAspectRatio SVGRadialGradientElement SVGRect SVGRectElement SVGScriptElement SVGSetElement SVGStopElement SVGStringList SVGStylable SVGStyleElement SVGSVGElement SVGSwitchElement SVGSymbolElement SVGTests SVGTextElement SVGTextPositioningElement SVGTitleElement SVGTransform SVGTransformable SVGTransformList SVGTRefElement SVGTSpanElement SVGUseElement SVGViewElement SVGVKernElement TCPSocket Telephony TelephonyCall Text TextDecoder TextEncoder TextMetrics TimeRanges Touch TouchEvent TouchList Transferable TransitionEvent TreeWalker TypeInfo UIEvent Uint16Array Uint32Array Uint8Array Uint8ClampedArray URL URLUtils URLUtilsReadOnly
129 " }}}
130 " DOM2 CONSTANT {{{
131 syntax keyword javaScriptDomErrNo INDEX_SIZE_ERR DOMSTRING_SIZE_ERR HIERARCHY_REQUEST_ERR WRONG_DOCUMENT_ERR INVALID_CHARACTER_ERR NO_DATA_ALLOWED_ERR NO_MODIFICATION_ALLOWED_ERR NOT_FOUND_ERR NOT_SUPPORTED_ERR INUSE_ATTRIBUTE_ERR INVALID_STATE_ERR SYNTAX_ERR INVALID_MODIFICATION_ERR NAMESPACE_ERR INVALID_ACCESS_ERR
132 syntax keyword javaScriptDomNodeConsts ELEMENT_NODE ATTRIBUTE_NODE TEXT_NODE CDATA_SECTION_NODE ENTITY_REFERENCE_NODE ENTITY_NODE PROCESSING_INSTRUCTION_NODE COMMENT_NODE DOCUMENT_NODE DOCUMENT_TYPE_NODE DOCUMENT_FRAGMENT_NODE NOTATION_NODE
133 "}}}
134 " HTML events and internal variables"{{{
135 syntax case ignore
136 syntax keyword javaScriptHtmlEvents onblur onclick oncontextmenu ondblclick onfocus onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup onresize onload onsubmit
137 syntax case match
138 "}}}
139
140 " Follow stuff should be highligh within a special context
141 " While it can't be handled with context depended with Regex based highlight
142 " So, turn it off by default
143 if exists("javascript_enable_domhtmlcss")
144 " DOM2 things {{{
145 syntax match javaScriptDomElemAttrs contained /\%(nodeName\|nodeValue\|nodeType\|parentNode\|childNodes\|firstChild\|lastChild\|previousSibling\|nextSibling\|attributes\|ownerDocument\|namespaceURI\|prefix\|localName\|tagName\)\>/
146 syntax match javaScriptDomElemFuncs contained /\%(insertBefore\|replaceChild\|removeChild\|appendChild\|hasChildNodes\|cloneNode\|normalize\|isSupported\|hasAttributes\|getAttribute\|setAttribute\|removeAttribute\|getAttributeNode\|setAttributeNode\|removeAttributeNode\|getElementsByTagName\|getAttributeNS\|setAttributeNS\|removeAttributeNS\|getAttributeNodeNS\|setAttributeNodeNS\|getElementsByTagNameNS\|hasAttribute\|hasAttributeNS\)\>/ nextgroup=javaScriptParen skipwhite
147 "}}}
148 " HTML things {{{
149 syntax match javaScriptHtmlElemAttrs contained /\%(className\|clientHeight\|clientLeft\|clientTop\|clientWidth\|dir\|id\|innerHTML\|lang\|length\|offsetHeight\|offsetLeft\|offsetParent\|offsetTop\|offsetWidth\|scrollHeight\|scrollLeft\|scrollTop\|scrollWidth\|style\|tabIndex\|title\)\>/
150 syntax match javaScriptHtmlElemFuncs contained /\%(blur\|click\|focus\|scrollIntoView\|addEventListener\|dispatchEvent\|removeEventListener\|item\)\>/ nextgroup=javaScriptParen skipwhite
151 "}}}
152 " CSS Styles in JavaScript {{{
153 syntax keyword javaScriptCssStyles contained color font fontFamily fontSize fontSizeAdjust fontStretch fontStyle fontVariant fontWeight letterSpacing lineBreak lineHeight quotes rubyAlign rubyOverhang rubyPosition
154 syntax keyword javaScriptCssStyles contained textAlign textAlignLast textAutospace textDecoration textIndent textJustify textJustifyTrim textKashidaSpace textOverflowW6 textShadow textTransform textUnderlinePosition
155 syntax keyword javaScriptCssStyles contained unicodeBidi whiteSpace wordBreak wordSpacing wordWrap writingMode
156 syntax keyword javaScriptCssStyles contained bottom height left position right top width zIndex
157 syntax keyword javaScriptCssStyles contained border borderBottom borderLeft borderRight borderTop borderBottomColor borderLeftColor borderTopColor borderBottomStyle borderLeftStyle borderRightStyle borderTopStyle borderBottomWidth borderLeftWidth borderRightWidth borderTopWidth borderColor borderStyle borderWidth borderCollapse borderSpacing captionSide emptyCells tableLayout
158 syntax keyword javaScriptCssStyles contained margin marginBottom marginLeft marginRight marginTop outline outlineColor outlineStyle outlineWidth padding paddingBottom paddingLeft paddingRight paddingTop
159 syntax keyword javaScriptCssStyles contained listStyle listStyleImage listStylePosition listStyleType
160 syntax keyword javaScriptCssStyles contained background backgroundAttachment backgroundColor backgroundImage gackgroundPosition backgroundPositionX backgroundPositionY backgroundRepeat
161 syntax keyword javaScriptCssStyles contained clear clip clipBottom clipLeft clipRight clipTop content counterIncrement counterReset cssFloat cursor direction display filter layoutGrid layoutGridChar layoutGridLine layoutGridMode layoutGridType
162 syntax keyword javaScriptCssStyles contained marks maxHeight maxWidth minHeight minWidth opacity MozOpacity overflow overflowX overflowY verticalAlign visibility zoom cssText
163 syntax keyword javaScriptCssStyles contained scrollbar3dLightColor scrollbarArrowColor scrollbarBaseColor scrollbarDarkShadowColor scrollbarFaceColor scrollbarHighlightColor scrollbarShadowColor scrollbarTrackColor
164 "}}}
165 " Highlight ways {{{
166 syntax match javaScriptDotNotation "\." nextgroup=javaScriptPrototype,javaScriptDomElemAttrs,javaScriptDomElemFuncs,javaScriptHtmlElemAttrs,javaScriptHtmlElemFuncs
167 syntax match javaScriptDotNotation "\.style\." nextgroup=javaScriptCssStyles
168 "}}}
169 endif
170 " end DOM/HTML/CSS specified things }}}
171 " Code blocks"{{{
172 syntax cluster javaScriptAll contains=javaScriptComment,javaScriptLineComment,javaScriptDocComment,javaScriptString,javaScriptRegexpString,javaScriptNumber,javaScriptFloat,javaScriptLabel,javaScriptSource,javaScriptWebAPI,javaScriptOperator,javaScriptBoolean,javaScriptNull,javaScriptFuncKeyword,javaScriptConditional,javaScriptGlobal,javaScriptRepeat,javaScriptBranch,javaScriptStatement,javaScriptGlobalObjects,javaScriptMessage,javaScriptIdentifier,javaScriptExceptions,javaScriptReserved,javaScriptDeprecated,javaScriptDomErrNo,javaScriptDomNodeConsts,javaScriptHtmlEvents,javaScriptDotNotation,javaScriptBrowserObjects,javaScriptDOMObjects,javaScriptAjaxObjects,javaScriptPropietaryObjects,javaScriptDOMMethods,javaScriptHtmlElemProperties,javaScriptDOMProperties,javaScriptEventListenerKeywords,javaScriptEventListenerMethods,javaScriptAjaxProperties,javaScriptAjaxMethods,javaScriptFuncArg
173
174 if main_syntax == "javascript"
175 syntax sync clear
176 syntax sync ccomment javaScriptComment minlines=200
177 " syntax sync match javaScriptHighlight grouphere javaScriptBlock /{/
178 endif
179 "}}}
180 " Function and arguments highlighting {{{
181 syntax keyword javaScriptFuncKeyword function contained
182 syntax region javaScriptFuncExp start=/\w\+\s\==\s\=function\>/ end="\([^)]*\)" contains=javaScriptFuncEq,javaScriptFuncKeyword,javaScriptFuncArg keepend
183 syntax match javaScriptFuncArg "\(([^()]*)\)" contains=javaScriptParens,javaScriptFuncComma,javaScriptComment contained
184 syntax match javaScriptFuncComma /,/ contained
185 syntax match javaScriptFuncEq /=/ contained
186 syntax region javaScriptFuncDef start="\<function\>" end="\([^)]*\)" contains=javaScriptFuncKeyword,javaScriptFuncArg keepend
187 syntax match javaScriptObjectKey /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>\(\s*:\)\@=/ contains=javaScriptFunctionKey
188 syntax match javaScriptFunctionKey /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>\(\s*:\s*function\s*\)\@=/ contained
189 "}}}
190 " Braces, Parens, symbols, colons {{{
191 syntax match javaScriptBraces "[{}\[\]]"
192 syntax match javaScriptParens "[()]"
193 syntax match javaScriptOpSymbols "=\{1,3}\|!==\|!=\|<\|>\|>=\|<=\|++\|+=\|--\|-="
194 syntax match javaScriptEndColons "[;,]"
195 syntax match javaScriptLogicSymbols "\(&&\)\|\(||\)"
196 "}}}
197 " ES6 String Interpolation {{{
198 syntax match javaScriptTemplateDelim "\${\|}" contained
199 syntax region javaScriptTemplateVar start=+${+ end=+}+ contains=javaScriptTemplateDelim keepend
200 syntax region javaScriptTemplateString start=+`+ skip=+\\\(`\|$\)+ end=+`+ contains=javaScriptTemplateVar,javaScriptSpecial keepend
201 "}}}
202 " JavaScriptFold Function {{{
203
204 function! JavaScriptFold()
205 setl foldmethod=syntax
206 setl foldlevelstart=1
207 syntax region foldBraces start=/{/ end=/}/ transparent fold keepend extend
208 endfunction
209
210 " }}}
211 " Highlight links {{{
212 " Define the default highlighting.
213 " For version 5.7 and earlier: only when not done already
214 " For version 5.8 and later: only when an item doesn't have highlighting yet
215 if version >= 508 || !exists("did_javascript_syn_inits")
216 if version < 508
217 let did_javascript_syn_inits = 1
218 command -nargs=+ HiLink hi link <args>
219 else
220 command -nargs=+ HiLink hi def link <args>
221 endif
222 HiLink javaScriptEndColons Operator
223 HiLink javaScriptOpSymbols Operator
224 HiLink javaScriptLogicSymbols Boolean
225 HiLink javaScriptBraces Function
226 HiLink javaScriptParens Operator
227 HiLink javaScriptTemplateDelim Operator
228
229 HiLink javaScriptComment Comment
230 HiLink javaScriptLineComment Comment
231 HiLink javaScriptDocComment Comment
232 HiLink javaScriptCommentTodo Todo
233
234 HiLink javaScriptDocTags Special
235 HiLink javaScriptDocSeeTag Function
236 HiLink javaScriptDocParam Function
237
238 HiLink javaScriptString String
239 HiLink javaScriptRegexpString String
240 HiLink javaScriptTemplateString String
241
242 HiLink javaScriptNumber Number
243 HiLink javaScriptFloat Number
244
245 HiLink javaScriptGlobal Constant
246 HiLink javaScriptCharacter Character
247 HiLink javaScriptPrototype Type
248 HiLink javaScriptConditional Conditional
249 HiLink javaScriptBranch Conditional
250 HiLink javaScriptIdentifier Identifier
251 HiLink javaScriptRepeat Repeat
252 HiLink javaScriptStatement Statement
253 HiLink javaScriptMessage Keyword
254 HiLink javaScriptReserved Keyword
255 HiLink javaScriptOperator Operator
256 HiLink javaScriptNull Type
257 HiLink javaScriptBoolean Boolean
258 HiLink javaScriptLabel Label
259 HiLink javaScriptSpecial Special
260 HiLink javaScriptSource Special
261 HiLink javaScriptGlobalObjects Special
262 HiLink javaScriptExceptions Special
263
264 HiLink javaScriptDeprecated Exception
265 HiLink javaScriptError Error
266 HiLink javaScriptParensError Error
267 HiLink javaScriptParensErrA Error
268 HiLink javaScriptParensErrB Error
269 HiLink javaScriptParensErrC Error
270 HiLink javaScriptDomErrNo Error
271
272 HiLink javaScriptDomNodeConsts Constant
273 HiLink javaScriptDomElemAttrs Label
274 HiLink javaScriptDomElemFuncs Type
275
276 HiLink javaScriptWebAPI Type
277
278 HiLink javaScriptHtmlElemAttrs Label
279 HiLink javaScriptHtmlElemFuncs Type
280
281 HiLink javaScriptCssStyles Type
282
283 HiLink javaScriptBrowserObjects Constant
284
285 HiLink javaScriptLocalStorageObjects Constant
286 HiLink javaScriptLocalStorageMethods Type
287
288 HiLink javaScriptFetchAPIObjects Constant
289 HiLink javaScriptFetchAPIMethods Type
290 HiLink javaScriptFetchAPIProperties Label
291
292 HiLink javaScriptJSONObject Constant
293 HiLink javaScriptJSONMethods Type
294
295 HiLink javaScriptDOMObjects Constant
296 HiLink javaScriptDOMMethods Type
297 HiLink javaScriptDOMProperties Label
298
299 HiLink javaScriptAjaxObjects Constant
300 HiLink javaScriptAjaxMethods Type
301 HiLink javaScriptAjaxProperties Label
302
303 HiLink javaScriptFuncKeyword Function
304 HiLink javaScriptFuncDef PreProc
305 HiLink javaScriptFuncExp Title
306 HiLink javaScriptFuncArg Special
307 HiLink javaScriptFuncComma Operator
308 HiLink javaScriptFuncEq Operator
309
310 HiLink javaScriptHtmlEvents Constant
311 HiLink javaScriptHtmlElemProperties Label
312
313 HiLink javaScriptEventListenerKeywords Type
314
315 HiLink javaScriptPropietaryObjects Constant
316
317 delcommand HiLink
318 endif
319 " end Highlight links }}}
320
321 " Define the htmlJavaScript for HTML syntax html.vim
322 "syntax clear htmlJavaScript
323 "syntax clear javaScriptExpression
324 syntax cluster htmlJavaScript contains=@javaScriptAll,javaScriptBracket,javaScriptParen,javaScriptBlock,javaScriptParenError
325 syntax cluster javaScriptExpression contains=@javaScriptAll,javaScriptBracket,javaScriptParen,javaScriptBlock,javaScriptParenError,@htmlPreproc
326 126
327 let b:current_syntax = "javascript" 127 let b:current_syntax = "javascript"
328 if main_syntax == 'javascript' 128 if main_syntax == 'javascript'
329 unlet main_syntax 129 unlet main_syntax
330 endif 130 endif
331 syntax region jsInJsdocExample matchgroup=Snip start="^\s*\* @example" end="\(^\s*\* [^[:space:]]\)\@=" containedin=@javaScriptComment contains=@javaScriptAll 131 let &cpo = s:cpo_save
332 hi link Snip SpecialComment 132 unlet s:cpo_save
133
134 " vim: ts=8