X-Git-Url: https://git.pld-linux.org/?a=blobdiff_plain;f=javascript.vim;h=b08ed53a37f20abc6413f756cee890a357d370fe;hb=60f36bd28844b5ed393c7cd3c95e6c2b1370ba0f;hp=10cb298205c1a07e49a2261251a85958cc6655e0;hpb=e80d24ca9039832620c43aa0d394f0dbf5aaf45d;p=packages%2Fvim.git diff --git a/javascript.vim b/javascript.vim index 10cb298..b08ed53 100644 --- a/javascript.vim +++ b/javascript.vim @@ -1,10 +1,17 @@ " Vim syntax file " Language: JavaScript " Maintainer: Yi Zhao (ZHAOYI) -" Last Change: 2007 Jan. 30th -" Version: 0.7.3 -" Changes: Add the keywords for JavaScript 1.7: let, yield, -" +" Last Change: May 17, 2007 +" Version: 0.7.5 +" Changes: 1, Get the vimdiff problem fixed finally. +" Matthew Gallant reported the problem and test the fix. ;) +" 2, Follow the suggestioin from Ingo Karkat. +" The 'foldtext' and 'foldlevel' settings should only be +" changed if the file being edited is pure JavaScript, +" not if JavaScript syntax is embedded inside other syntaxes. +" 3, Remove function FT_JavaScriptDoc(). +" Since VIM do the better than me. +" " TODO: " - Add the HTML syntax inside the JSDoc @@ -18,10 +25,9 @@ if !exists("main_syntax") endif "" Drop fold if it set but VIM doesn't support it. -if version < 600 && exists("javaScript_fold") - unlet javaScript_fold -else - let javaScript_fold = 'false' +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 @@ -32,7 +38,7 @@ syntax sync maxlines=200 "" JavaScript comments syntax keyword javaScriptCommentTodo TODO FIXME XXX TBD contained -syntax region javaScriptLineComment start=+\/\/+ end=+$+ keepend contains=javaScriptCommentTodo,@Spell +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 @@ -43,11 +49,11 @@ if !exists("javascript_ignore_javaScriptdoc") "" syntax coloring for javadoc comments (HTML) "syntax include @javaHtml :p:h/html.vim - "unlet b:current_syntax - + "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\|base\|file\)\>" nextgroup=javaScriptDocParam,javaScriptDocSeeTag skipwhite - syntax match javaScriptDocTags contained "@\(deprecated\|fileoverview\|author\|license\|version\|returns\=\|constructor\|private\|final\|ignore\|addon\|exec\)\>" + 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 @@ -60,43 +66,43 @@ syntax case match 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}\(\s*[),.;$]\)\@=+ contains=javaScriptSpecial,@htmlPreproc oneline +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*\)\@/ 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 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 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 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 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 @@ -140,7 +146,7 @@ endif "DOM/HTML/CSS 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 +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 ")\|}\|\]" @@ -153,34 +159,24 @@ if main_syntax == "javascript" endif "" Fold control -if exists("javaScript_fold") - syntax match javaScriptFunction /\/ nextgroup=javaScriptFuncName skipwhite +if exists("b:javascript_fold") + syntax match javaScriptFunction /\/ nextgroup=javaScriptFuncName skipwhite + syntax match javaScriptOpAssign /=\@= 0 - break - endif - let i += 1 - endwhile - return v:folddashes . line - endfunction - + if &l:filetype=='javascript' && !&diff + " Fold setting + " Redefine the foldtext (to show a JS function outline) and foldlevel + " only if the entire buffer is JavaScript, but not if JavaScript syntax + " is embedded in another syntax (e.g. HTML). + setlocal foldmethod=syntax + setlocal foldlevel=4 + endif else syntax keyword javaScriptFunction function + setlocal foldmethod< + setlocal foldlevel< endif " Define the default highlighting.