diff --git a/syntax/javascript.vim b/syntax/javascript.vim index cc26205..213a595 100644 --- a/syntax/javascript.vim +++ b/syntax/javascript.vim @@ -28,18 +28,17 @@ setlocal iskeyword+=$ syntax sync fromstart -"" JavaScript comments +"" JavaScript comments"{{{ syn keyword javaScriptCommentTodo TODO FIXME XXX TBD contained syn match javaScriptLineComment "\/\/.*" contains=@Spell,javaScriptCommentTodo syn match javaScriptCommentSkip "^[ \t]*\*\($\|[ \t]\+\)" syn region javaScriptComment start="/\*" end="\*/" contains=@Spell,javaScriptCommentTodo - -"" JSDoc support start +"}}} +"" JSDoc support start"{{{ if !exists("javascript_ignore_javaScriptdoc") syntax case ignore - "" syntax coloring for javadoc comments (HTML) - "syntax include @javaHtml :p:h/html.vim +" syntax coloring for JSDoc comments (HTML) "unlet b:current_syntax syntax region javaScriptDocComment matchgroup=javaScriptComment start="/\*\*\s*$" end="\*/" contains=javaScriptDocTags,javaScriptCommentTodo,javaScriptCvsTag,@javaScriptHtml,@Spell fold @@ -50,10 +49,10 @@ if !exists("javascript_ignore_javaScriptdoc") syntax case match endif "" JSDoc end - +"}}} syntax case match -"" Syntax in the JavaScript code +"" Syntax in the JavaScript code"{{{ syn match javaScriptSpecial "\\\d\d\d\|\\." syn region javaScriptStringD start=+"+ skip=+\\\\\|\\"+ end=+"\|$+ contains=javaScriptSpecial,@htmlPreproc syn region javaScriptStringS start=+'+ skip=+\\\\\|\\'+ end=+'\|$+ contains=javaScriptSpecial,@htmlPreproc @@ -68,10 +67,10 @@ syn region javaScriptRegexpString start=+/[^/*]+me=e-1 skip=+\\\\\|\\/+ end " syntax match javaScriptNumber /\<-\=\d\+L\=\>\|\<0[xX]\x\+\>/ syntax match javaScriptFloat /\<-\=\%(\d\+\.\d\+\|\d\+\.\|\.\d\+\)\%([eE][+-]\=\d\+\)\=\>/ " syntax match javaScriptLabel /\(?\s*\)\@/ 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 - " HTML things + "}}} + " HTML things"{{{ 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\)\>/ syntax match javaScriptHtmlElemFuncs contained /\%(blur\|click\|focus\|scrollIntoView\|addEventListener\|dispatchEvent\|removeEventListener\|item\)\>/ nextgroup=javaScriptParen skipwhite - - " CSS Styles in JavaScript +"}}} + " CSS Styles in JavaScript"{{{ syntax keyword javaScriptCssStyles contained color font fontFamily fontSize fontSizeAdjust fontStretch fontStyle fontVariant fontWeight letterSpacing lineBreak lineHeight quotes rubyAlign rubyOverhang rubyPosition syntax keyword javaScriptCssStyles contained textAlign textAlignLast textAutospace textDecoration textIndent textJustify textJustifyTrim textKashidaSpace textOverflowW6 textShadow textTransform textUnderlinePosition syntax keyword javaScriptCssStyles contained unicodeBidi whiteSpace wordBreak wordSpacing wordWrap writingMode @@ -156,14 +156,14 @@ if exists("javascript_enable_domhtmlcss") syntax keyword javaScriptCssStyles contained clear clip clipBottom clipLeft clipRight clipTop content counterIncrement counterReset cssFloat cursor direction display filter layoutGrid layoutGridChar layoutGridLine layoutGridMode layoutGridType syntax keyword javaScriptCssStyles contained marks maxHeight maxWidth minHeight minWidth opacity MozOpacity overflow overflowX overflowY verticalAlign visibility zoom cssText syntax keyword javaScriptCssStyles contained scrollbar3dLightColor scrollbarArrowColor scrollbarBaseColor scrollbarDarkShadowColor scrollbarFaceColor scrollbarHighlightColor scrollbarShadowColor scrollbarTrackColor - - " Highlight ways +"}}} + " Highlight ways"{{{ syntax match javaScriptDotNotation "\." nextgroup=javaScriptPrototype,javaScriptDomElemAttrs,javaScriptDomElemFuncs,javaScriptHtmlElemAttrs,javaScriptHtmlElemFuncs syntax match javaScriptDotNotation "\.style\." nextgroup=javaScriptCssStyles - +"}}} endif "DOM/HTML/CSS -"" end DOM/HTML/CSS specified things +"" end DOM/HTML/CSS specified things""}}} "" Code blocks @@ -185,6 +185,20 @@ syn match javaScriptOpSymbols "=\{1,3}\|!==\|!=\|<\|>\|>=\|<=\|++\|+=\|--\|-= syn match javaScriptEndColons "[;,]$" syn match javaScriptLogicSymbols "\(&&\)\|\(||\)" +" JavaScriptFold Function {{{ + +function! JavaScriptFold() + setl foldmethod=syntax + setl foldlevelstart=1 + syn region foldBraces start=/{/ end=/}/ transparent fold keepend extend + + setl foldtext=FoldText() +endfunction + +au FileType javascript call JavaScriptFold() + +" }}} + " Define the default highlighting. " For version 5.7 and earlier: only when not done already " For version 5.8 and later: only when an item doesn't have highlighting yet