@@ -28,18 +28,17 @@ setlocal iskeyword+=$
28
28
29
29
syntax sync fromstart
30
30
31
- " " JavaScript comments
31
+ " " JavaScript comments"{{{
32
32
syn keyword javaScriptCommentTodo TODO FIXME XXX TBD contained
33
33
syn match javaScriptLineComment " \/\/ .*" contains =@Spell,javaScriptCommentTodo
34
34
syn match javaScriptCommentSkip " ^[ \t ]*\*\( $\| [ \t ]\+\) "
35
35
syn region javaScriptComment start =" /\* " end =" \* /" contains =@Spell,javaScriptCommentTodo
36
-
37
- " " JSDoc support start
36
+ " }}}
37
+ " " JSDoc support start"{{{
38
38
if ! exists (" javascript_ignore_javaScriptdoc" )
39
39
syntax case ignore
40
40
41
- " " syntax coloring for javadoc comments (HTML)
42
- " syntax include @javaHtml <sfile>:p:h/html.vim
41
+ " syntax coloring for JSDoc comments (HTML)
43
42
" unlet b:current_syntax
44
43
45
44
syntax region javaScriptDocComment matchgroup =javaScriptComment start =" /\*\*\s *$" end =" \* /" contains =javaScriptDocTags,javaScriptCommentTodo,javaScriptCvsTag,@javaScriptHtml,@Spell fold
@@ -50,10 +49,10 @@ if !exists("javascript_ignore_javaScriptdoc")
50
49
51
50
syntax case match
52
51
endif " " JSDoc end
53
-
52
+ " }}}
54
53
syntax case match
55
54
56
- " " Syntax in the JavaScript code
55
+ " " Syntax in the JavaScript code"{{{
57
56
syn match javaScriptSpecial " \\\d\d\d\|\\ ."
58
57
syn region javaScriptStringD start =+ "+ skip =+ \\\\\|\\ "+ end =+ "\| $+ contains =javaScriptSpecial,@htmlPreproc
59
58
syn region javaScriptStringS start =+ '+ skip =+ \\\\\|\\ '+ end =+ '\| $+ contains =javaScriptSpecial,@htmlPreproc
@@ -68,10 +67,10 @@ syn region javaScriptRegexpString start=+/[^/*]+me=e-1 skip=+\\\\\|\\/+ end
68
67
" syntax match javaScriptNumber /\<-\=\d\+L\=\>\|\<0[xX]\x\+\>/
69
68
syntax match javaScriptFloat / \< -\=\% (\d\+\.\d\+\|\d\+\.\|\.\d\+\)\% ([eE][+-]\=\d\+\)\=\> /
70
69
" syntax match javaScriptLabel /\(?\s*\)\@<!\<\w\+\(\s*:\)\@=/
71
-
72
- " " JavaScript Prototype
70
+ " }}}
71
+ " " JavaScript Prototype"{{{
73
72
syntax keyword javaScriptPrototype prototype
74
-
73
+ " }}}
75
74
" DOM, Browser and Ajax Support {{{
76
75
" """""""""""""""""""""""
77
76
syntax keyword javaScriptBrowserObjects window navigator screen history location
@@ -93,8 +92,7 @@ syntax keyword javaScriptEventListenerKeywords blur click focus mouseover mou
93
92
94
93
syntax keyword javaScriptEventListenerMethods scrollIntoView addEventListener dispatchEvent removeEventListener preventDefault stopPropagation
95
94
" }}}
96
-
97
- " " Programm Keywords
95
+ " " Programm Keywords"{{{
98
96
syntax keyword javaScriptSource import export
99
97
syntax keyword javaScriptIdentifier arguments this let var void yield
100
98
syntax keyword javaScriptOperator delete new instanceof typeof
@@ -103,8 +101,8 @@ syntax keyword javaScriptNull null undefined
103
101
syntax keyword javaScriptMessage alert confirm prompt status
104
102
syntax keyword javaScriptGlobal self top parent
105
103
syntax keyword javaScriptDeprecated escape unescape all applets alinkColor bgColor fgColor linkColor vlinkColor xmlEncoding
106
-
107
- " " Statement Keywords
104
+ " }}}
105
+ " " Statement Keywords"{{{
108
106
syntax keyword javaScriptConditional if else switch
109
107
syntax keyword javaScriptRepeat do while for in
110
108
syntax keyword javaScriptBranch break continue
@@ -116,35 +114,37 @@ syntax keyword javaScriptGlobalObjects Array Boolean Date Function Infinity Mat
116
114
syntax keyword javaScriptExceptions try catch throw finally Error EvalError RangeError ReferenceError SyntaxError TypeError URIError
117
115
118
116
syntax keyword javaScriptReserved abstract enum int short boolean export interface static byte extends long super char final native synchronized class float package throws const goto private transient debugger implements protected volatile double import public
117
+ " }}}
118
+ " " DOM/HTML/CSS specified things"{{{
119
119
120
- " " DOM/HTML/CSS specified things
121
-
122
- " DOM2 Objects
120
+ " DOM2 Objects"{{{
123
121
syntax keyword javaScriptType DOMImplementation DocumentFragment Node NodeList NamedNodeMap CharacterData Attr Element Text Comment CDATASection DocumentType Notation Entity EntityReference ProcessingInstruction
124
122
syntax keyword javaScriptExceptions DOMException
125
-
126
- " DOM2 CONSTANT
123
+ " }}}
124
+ " DOM2 CONSTANT"{{{
127
125
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
128
126
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
129
-
130
- " HTML events and internal variables
127
+ " }}}
128
+ " HTML events and internal variables"{{{
131
129
syntax case ignore
132
130
syntax keyword javaScriptHtmlEvents onblur onclick oncontextmenu ondblclick onfocus onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup onresize onload onsubmit
133
131
syntax case match
132
+ " }}}
134
133
135
134
" Follow stuff should be highligh within a special context
136
135
" While it can't be handled with context depended with Regex based highlight
137
136
" So, turn it off by default
138
137
if exists (" javascript_enable_domhtmlcss" )
139
138
140
- " DOM2 things
139
+ " DOM2 things"{{{
141
140
syntax match javaScriptDomElemAttrs contained / \% (nodeName\| nodeValue\| nodeType\| parentNode\| childNodes\| firstChild\| lastChild\| previousSibling\| nextSibling\| attributes\| ownerDocument\| namespaceURI\| prefix\| localName\| tagName\)\> /
142
141
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
143
- " HTML things
142
+ " }}}
143
+ " HTML things"{{{
144
144
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\)\> /
145
145
syntax match javaScriptHtmlElemFuncs contained / \% (blur\| click\| focus\| scrollIntoView\| addEventListener\| dispatchEvent\| removeEventListener\| item\)\> / nextgroup =javaScriptParen skipwhite
146
-
147
- " CSS Styles in JavaScript
146
+ " }}}
147
+ " CSS Styles in JavaScript"{{{
148
148
syntax keyword javaScriptCssStyles contained color font fontFamily fontSize fontSizeAdjust fontStretch fontStyle fontVariant fontWeight letterSpacing lineBreak lineHeight quotes rubyAlign rubyOverhang rubyPosition
149
149
syntax keyword javaScriptCssStyles contained textAlign textAlignLast textAutospace textDecoration textIndent textJustify textJustifyTrim textKashidaSpace textOverflowW6 textShadow textTransform textUnderlinePosition
150
150
syntax keyword javaScriptCssStyles contained unicodeBidi whiteSpace wordBreak wordSpacing wordWrap writingMode
@@ -156,14 +156,14 @@ if exists("javascript_enable_domhtmlcss")
156
156
syntax keyword javaScriptCssStyles contained clear clip clipBottom clipLeft clipRight clipTop content counterIncrement counterReset cssFloat cursor direction display filter layoutGrid layoutGridChar layoutGridLine layoutGridMode layoutGridType
157
157
syntax keyword javaScriptCssStyles contained marks maxHeight maxWidth minHeight minWidth opacity MozOpacity overflow overflowX overflowY verticalAlign visibility zoom cssText
158
158
syntax keyword javaScriptCssStyles contained scrollbar3dLightColor scrollbarArrowColor scrollbarBaseColor scrollbarDarkShadowColor scrollbarFaceColor scrollbarHighlightColor scrollbarShadowColor scrollbarTrackColor
159
-
160
- " Highlight ways
159
+ " }}}
160
+ " Highlight ways"{{{
161
161
syntax match javaScriptDotNotation " \. " nextgroup =javaScriptPrototype,javaScriptDomElemAttrs,javaScriptDomElemFuncs,javaScriptHtmlElemAttrs,javaScriptHtmlElemFuncs
162
162
syntax match javaScriptDotNotation " \. style\. " nextgroup =javaScriptCssStyles
163
-
163
+ " }}}
164
164
endif " DOM/HTML/CSS
165
165
166
- " " end DOM/HTML/CSS specified things
166
+ " " end DOM/HTML/CSS specified things""}}}
167
167
168
168
169
169
" " Code blocks
@@ -185,6 +185,20 @@ syn match javaScriptOpSymbols "=\{1,3}\|!==\|!=\|<\|>\|>=\|<=\|++\|+=\|--\|-=
185
185
syn match javaScriptEndColons " [;,]$"
186
186
syn match javaScriptLogicSymbols " \( &&\)\|\( ||\) "
187
187
188
+ " JavaScriptFold Function {{{
189
+
190
+ function ! JavaScriptFold ()
191
+ setl foldmethod = syntax
192
+ setl foldlevelstart = 1
193
+ syn region foldBraces start =/ {/ end =/ }/ transparent fold keepend extend
194
+
195
+ setl foldtext = FoldText ()
196
+ endfunction
197
+
198
+ au FileType javascript call JavaScriptFold ()
199
+
200
+ " }}}
201
+
188
202
" Define the default highlighting.
189
203
" For version 5.7 and earlier: only when not done already
190
204
" For version 5.8 and later: only when an item doesn't have highlighting yet
0 commit comments