From 5572f7a4e95d0168efadfd38ce7c8453e1a9599b Mon Sep 17 00:00:00 2001 From: Buddy Sandidge Date: Wed, 19 Feb 2014 22:00:45 -0800 Subject: [PATCH] Squashed 'vim/bundle/javascript-syntax/' content from commit e24f4aa35 git-subtree-dir: vim/bundle/javascript-syntax git-subtree-split: e24f4aa35f7d8c18cef41bc4cc76f52db5327f80 --- README | 16 +++ syntax/javascript.vim | 246 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 README create mode 100644 syntax/javascript.vim diff --git a/README b/README new file mode 100644 index 0000000..578482e --- /dev/null +++ b/README @@ -0,0 +1,16 @@ +This is a mirror of http://www.vim.org/scripts/script.php?script_id=1491 + +Hi JavaScript and VIM funs, + +If you want to use VIM to edit/view the JavaScript files, you should have this one. +Replace it with the javascript syntax file included with the VIMRUNTIME. + +Why it is here: +Because I found that the originaly one which packed with the VIMRUNTIME didn't work very well for the JS files in Mozilla Browser/SeaMonkey/Firefox and Dojo. So I decided to some refine on it. + +Hope it is also useful for you~~~ + +Good Luck, + +Yi Zhao (ZHAOYI) +Blog: http://linuxyz.blogspot.com/ diff --git a/syntax/javascript.vim b/syntax/javascript.vim new file mode 100644 index 0000000..3ba7fca --- /dev/null +++ b/syntax/javascript.vim @@ -0,0 +1,246 @@ +" Vim syntax file +" Language: JavaScript +" Maintainer: Yi Zhao (ZHAOYI) +" Last Change: June 4, 2009 +" Version: 0.7.7 +" Changes: Add "undefined" as a type keyword +" +" TODO: +" - Add the HTML syntax inside the JSDoc + +if !exists("main_syntax") + if version < 600 + syntax clear + elseif exists("b:current_syntax") + finish + endif + let main_syntax = 'javascript' +endif + +"" Drop fold if it set but VIM doesn't support it. +let b:javascript_fold='true' +if version < 600 " Don't support the old version + unlet! b:javascript_fold +endif + +"" dollar sigh is permittd anywhere in an identifier +setlocal iskeyword+=$ + +syntax sync fromstart + +"" JavaScript comments +syntax keyword javaScriptCommentTodo TODO FIXME XXX TBD contained +syntax region javaScriptLineComment start=+\/\/+ end=+$+ keepend contains=javaScriptCommentTodo,@Spell +syntax region javaScriptLineComment start=+^\s*\/\/+ skip=+\n\s*\/\/+ end=+$+ keepend contains=javaScriptCommentTodo,@Spell fold +syntax region javaScriptCvsTag start="\$\cid:" end="\$" oneline contained +syntax region javaScriptComment start="/\*" end="\*/" contains=javaScriptCommentTodo,javaScriptCvsTag,@Spell fold + +"" JSDoc support start +if !exists("javascript_ignore_javaScriptdoc") + syntax case ignore + + "" syntax coloring for javadoc comments (HTML) + "syntax include @javaHtml :p:h/html.vim + "unlet b:current_syntax + + syntax region javaScriptDocComment matchgroup=javaScriptComment start="/\*\*\s*$" end="\*/" contains=javaScriptDocTags,javaScriptCommentTodo,javaScriptCvsTag,@javaScriptHtml,@Spell fold + syntax match javaScriptDocTags contained "@\(param\|argument\|requires\|exception\|throws\|type\|class\|extends\|see\|link\|member\|module\|method\|title\|namespace\|optional\|default\|base\|file\)\>" nextgroup=javaScriptDocParam,javaScriptDocSeeTag skipwhite + syntax match javaScriptDocTags contained "@\(beta\|deprecated\|description\|fileoverview\|author\|license\|version\|returns\=\|constructor\|private\|protected\|final\|ignore\|addon\|exec\)\>" + syntax match javaScriptDocParam contained "\%(#\|\w\|\.\|:\|\/\)\+" + syntax region javaScriptDocSeeTag contained matchgroup=javaScriptDocSeeTag start="{" end="}" contains=javaScriptDocTags + + syntax case match +endif "" JSDoc end + +syntax case match + +"" Syntax in the JavaScript code +syntax match javaScriptSpecial "\\\d\d\d\|\\x\x\{2\}\|\\u\x\{4\}\|\\." +syntax region javaScriptStringD start=+"+ skip=+\\\\\|\\$"+ end=+"+ contains=javaScriptSpecial,@htmlPreproc +syntax region javaScriptStringS start=+'+ skip=+\\\\\|\\$'+ end=+'+ contains=javaScriptSpecial,@htmlPreproc +syntax region javaScriptRegexpString start=+/\(\*\|/\)\@!+ skip=+\\\\\|\\/+ end=+/[gim]\{,3}+ contains=javaScriptSpecial,@htmlPreproc oneline +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 + 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 + 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 + syntax keyword javaScriptCssStyles contained bottom height left position right top width zIndex + 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 + syntax keyword javaScriptCssStyles contained margin marginBottom marginLeft marginRight marginTop outline outlineColor outlineStyle outlineWidth padding paddingBottom paddingLeft paddingRight paddingTop + syntax keyword javaScriptCssStyles contained listStyle listStyleImage listStylePosition listStyleType + syntax keyword javaScriptCssStyles contained background backgroundAttachment backgroundColor backgroundImage gackgroundPosition backgroundPositionX backgroundPositionY backgroundRepeat + 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 + 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 + + +"" Code blocks +syntax cluster javaScriptAll contains=javaScriptComment,javaScriptLineComment,javaScriptDocComment,javaScriptStringD,javaScriptStringS,javaScriptRegexpString,javaScriptNumber,javaScriptFloat,javaScriptLabel,javaScriptSource,javaScriptType,javaScriptOperator,javaScriptBoolean,javaScriptNull,javaScriptFunction,javaScriptConditional,javaScriptRepeat,javaScriptBranch,javaScriptStatement,javaScriptGlobalObjects,javaScriptExceptions,javaScriptFutureKeys,javaScriptDomErrNo,javaScriptDomNodeConsts,javaScriptHtmlEvents,javaScriptDotNotation +syntax region javaScriptBracket matchgroup=javaScriptBracket transparent start="\[" end="\]" contains=@javaScriptAll,javaScriptParensErrB,javaScriptParensErrC,javaScriptBracket,javaScriptParen,javaScriptBlock,@htmlPreproc +syntax region javaScriptParen matchgroup=javaScriptParen transparent start="(" end=")" contains=@javaScriptAll,javaScriptParensErrA,javaScriptParensErrC,javaScriptParen,javaScriptBracket,javaScriptBlock,@htmlPreproc +syntax region javaScriptBlock matchgroup=javaScriptBlock transparent start="{" end="}" contains=@javaScriptAll,javaScriptParensErrA,javaScriptParensErrB,javaScriptParen,javaScriptBracket,javaScriptBlock,@htmlPreproc + +"" catch errors caused by wrong parenthesis +syntax match javaScriptParensError ")\|}\|\]" +syntax match javaScriptParensErrA contained "\]" +syntax match javaScriptParensErrB contained ")" +syntax match javaScriptParensErrC contained "}" + +if main_syntax == "javascript" + syntax sync clear + syntax sync ccomment javaScriptComment minlines=200 + syntax sync match javaScriptHighlight grouphere javaScriptBlock /{/ +endif + +"" Fold control +if exists("b:javascript_fold") + syntax match javaScriptFunction /\/ nextgroup=javaScriptFuncName skipwhite + syntax match javaScriptOpAssign /=\@= 508 || !exists("did_javascript_syn_inits") + if version < 508 + let did_javascript_syn_inits = 1 + command -nargs=+ HiLink hi link + else + command -nargs=+ HiLink hi def link + endif + HiLink javaScriptComment Comment + HiLink javaScriptLineComment Comment + HiLink javaScriptDocComment Comment + HiLink javaScriptCommentTodo Todo + HiLink javaScriptCvsTag Function + HiLink javaScriptDocTags Special + HiLink javaScriptDocSeeTag Function + HiLink javaScriptDocParam Function + HiLink javaScriptStringS String + HiLink javaScriptStringD String + HiLink javaScriptRegexpString String + HiLink javaScriptCharacter Character + HiLink javaScriptPrototype Type + HiLink javaScriptConditional Conditional + HiLink javaScriptBranch Conditional + HiLink javaScriptRepeat Repeat + HiLink javaScriptStatement Statement + HiLink javaScriptFunction Function + HiLink javaScriptError Error + HiLink javaScriptParensError Error + HiLink javaScriptParensErrA Error + HiLink javaScriptParensErrB Error + HiLink javaScriptParensErrC Error + HiLink javaScriptOperator Operator + HiLink javaScriptType Type + HiLink javaScriptNull Type + HiLink javaScriptNumber Number + HiLink javaScriptFloat Number + HiLink javaScriptBoolean Boolean + HiLink javaScriptLabel Label + HiLink javaScriptSpecial Special + HiLink javaScriptSource Special + HiLink javaScriptGlobalObjects Special + HiLink javaScriptExceptions Special + + HiLink javaScriptDomErrNo Constant + HiLink javaScriptDomNodeConsts Constant + HiLink javaScriptDomElemAttrs Label + HiLink javaScriptDomElemFuncs PreProc + + HiLink javaScriptHtmlEvents Special + HiLink javaScriptHtmlElemAttrs Label + HiLink javaScriptHtmlElemFuncs PreProc + + HiLink javaScriptCssStyles Label + + delcommand HiLink +endif + +" Define the htmlJavaScript for HTML syntax html.vim +"syntax clear htmlJavaScript +"syntax clear javaScriptExpression +syntax cluster htmlJavaScript contains=@javaScriptAll,javaScriptBracket,javaScriptParen,javaScriptBlock,javaScriptParenError +syntax cluster javaScriptExpression contains=@javaScriptAll,javaScriptBracket,javaScriptParen,javaScriptBlock,javaScriptParenError,@htmlPreproc + +let b:current_syntax = "javascript" +if main_syntax == 'javascript' + unlet main_syntax +endif + +" vim: ts=4