Author: adamg Date: Sun May 13 08:19:45 2007 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- updated to 0.7.3
---- Files affected:
SOURCES:
javascript.vim (1.2 -> 1.3)
---- Diffs:
================================================================
Index: SOURCES/javascript.vim
diff -u SOURCES/javascript.vim:1.2 SOURCES/javascript.vim:1.3
--- SOURCES/javascript.vim:1.2 Tue Apr 25 12:21:32 2006
+++ SOURCES/javascript.vim Sun May 13 10:19:40 2007
@@ -1,14 +1,12 @@
" Vim syntax file
" Language: JavaScript
-" Maintainer: Yi Zhao <zzlinux AT hotmail DOT com>
-" Last Change: 2006 March 20
-" Version: 0.5
-" Based On: javascript.vim from Claudio Fleiner <[EMAIL PROTECTED]>
-" Changes: export @htmlJavaScript to html.vim
-"
-" TODO
-" - internal function hightlight
-"
+" Maintainer: Yi Zhao (ZHAOYI) <zzlinux AT hotmail DOT com>
+" Last Change: 2007 Jan. 30th
+" Version: 0.7.3
+" Changes: Add the keywords for JavaScript 1.7: let, yield,
+"
+" TODO:
+" - Add the HTML syntax inside the JSDoc
if !exists("main_syntax")
if version < 600
@@ -19,71 +17,170 @@
let main_syntax = 'javascript'
endif
-" Drop fold if it set but vim doesn't support it.
+"" Drop fold if it set but VIM doesn't support it.
if version < 600 && exists("javaScript_fold")
unlet javaScript_fold
-"else
-" let javaScript_fold = 'true'
+else
+ let javaScript_fold = 'false'
endif
-syntax case match
+"" dollar sigh is permittd anywhere in an identifier
+setlocal iskeyword+=$
-syntax match jsSpecial
"\\\d\d\d\|\\x[0-9a-fA-F]\{2\}\|\\u[0-9a-fA-F]\{4\}\|\\."
-syntax region jsStringD start=+"+ skip=+\\\\\|\\$"+ end=+"+
contains=jsSpecial,@htmlPreproc
-syntax region jsStringS start=+'+ skip=+\\\\\|\\$'+ end=+'+
contains=jsSpecial,@htmlPreproc
-syntax region jsRegexpString start=+/\(\*\|/\)[EMAIL PROTECTED]
skip=+\\\\\|\\/+ end=+/[gim]*\(\s*[),.;$]\)[EMAIL PROTECTED]
contains=jsSpecial,@htmlPreproc oneline
-syntax match jsNumber "-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>"
-
-syntax keyword jsCommentTodo TODO FIXME XXX TBD contained
-syntax region jsLineComment start=+\/\/+ end=/$/ contains=jsCommentTodo
oneline
-syntax region jsComment start="/\*" end="\*/"
contains=jsCommentTodo,jsLineComment fold
+syntax sync fromstart
+syntax sync maxlines=200
-syntax match jsLabel /\(?\s*\)\@<!\<\w\+\(\s*:\)[EMAIL PROTECTED]/
+"" 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 <sfile>: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\|base\|file\)\>"
nextgroup=javaScriptDocParam,javaScriptDocSeeTag skipwhite
+ syntax match javaScriptDocTags contained
"@\(deprecated\|fileoverview\|author\|license\|version\|returns\=\|constructor\|private\|final\|ignore\|addon\|exec\)\>"
+ syntax match javaScriptDocParam contained "\%(#\|\w\|\.\|:\|\/\)\+"
+ syntax region javaScriptDocSeeTag contained
matchgroup=javaScriptDocSeeTag start="{" end="}" contains=javaScriptDocTags
-"" Programm Keywords
-syntax keyword jsSource import export
-syntax keyword jsType this var const void
-syntax keyword jsOperator delete new in instanceof typeof
-syntax keyword jsBoolean true false
-syntax keyword jsNull null
+ syntax case match
+endif "" JSDoc end
-"" Statement Keywords
-syntax keyword jsConditional if else
-syntax keyword jsRepeat do while for
-syntax keyword jsBranch break continue switch case default return
-syntax keyword jsStatement try catch throw with
+syntax case match
-syntax keyword jsGlobalObjects Array Boolean Date Error Function java
JavaArray JavaClass JavaObject JavaPackage Math netscape Number Object Packages
RegExp String sun
+"" 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=+/\(\*\|/\)[EMAIL PROTECTED]
skip=+\\\\\|\\/+ end=+/[gim]\{-,3}\(\s*[),.;$]\)[EMAIL PROTECTED]
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*\)\@<!\<\w\+\(\s*:\)[EMAIL
PROTECTED]/
-syntax sync fromstart
-syntax sync maxlines=100
+"" JavaScript Prototype
+syntax keyword javaScriptPrototype prototype
-" Code blocks
-syntax cluster jsAll
contains=jsComment,jsLineComment,jsSpecial,jsStringD,jsStringS,jsNumber,jsRegexpString,jsBoolean,jsFunction,jsConditional,jsRepeat,jsBranch,jsOperator,jsType,jsStatement,jsBoolean,jsGlobalObjects
-syntax region jsBracket matchgroup=jsBracket transparent start="\["
end="\]" [EMAIL PROTECTED],jsBracket,jsParen,jsBlock
-syntax region jsParen matchgroup=jsParen transparent start="(" end=")"
[EMAIL PROTECTED],jsParen,jsBracket,jsBlock
-syntax region jsBlock matchgroup=jsBlcok transparent start="{" end="}"
contains=ALL
+"" Programm Keywords
+syntax keyword javaScriptSource import export
+syntax keyword javaScriptType const this var void yield
+syntax keyword javaScriptOperator delete new in instanceof let typeof
+syntax keyword javaScriptBoolean true false
+syntax keyword javaScriptNull null
-" catch errors caused by wrong parenthesis
-syntax match jsParenError ")\|}\|\]"
+"" Statement Keywords
+syntax keyword javaScriptConditional if else
+syntax keyword javaScriptRepeat do while for
+syntax keyword javaScriptBranch break continue switch case default
return
+syntax keyword javaScriptStatement try catch throw with finally
+
+syntax keyword javaScriptGlobalObjects Array Boolean Date Function Infinity
JavaArray JavaClass JavaObject JavaPackage Math Number NaN Object Packages
RegExp String Undefined java netscape sun
+
+syntax keyword javaScriptExceptions Error EvalError RangeError
ReferenceError SyntaxError TypeError URIError
+
+syntax keyword javaScriptFutureKeys 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
+
+"" DOM/HTML/CSS specified things
+
+ " DOM2 Objects
+ syntax keyword javaScriptGlobalObjects DOMImplementation DocumentFragment
Document Node NodeList NamedNodeMap CharacterData Attr Element Text Comment
CDATASection DocumentType Notation Entity EntityReference ProcessingInstruction
+ syntax keyword javaScriptExceptions DOMException
+
+ " DOM2 CONSTANT
+ 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
+ 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
+
+ " HTML events and internal variables
+ syntax case ignore
+ syntax keyword javaScriptHtmlEvents onblur onclick oncontextmenu
ondblclick onfocus onkeydown onkeypress onkeyup onmousedown onmousemove
onmouseout onmouseover onmouseup onresize
+ syntax case match
+
+" Follow stuff should be highligh within a special context
+" While it can't be handled with context depended with Regex based highlight
+" So, turn it off by default
+if exists("javascript_enable_domhtmlcss")
+
+ " DOM2 things
+ syntax match javaScriptDomElemAttrs contained
/\%(nodeName\|nodeValue\|nodeType\|parentNode\|childNodes\|firstChild\|lastChild\|previousSibling\|nextSibling\|attributes\|ownerDocument\|namespaceURI\|prefix\|localName\|tagName\)\>/
+ 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="\]" [EMAIL
PROTECTED],javaScriptParensErrB,javaScriptParensErrC,javaScriptBracket,javaScriptParen,javaScriptBlock,@htmlPreproc
+syntax region javaScriptParen matchgroup=javaScriptParen transparent
start="(" end=")" [EMAIL
PROTECTED],javaScriptParensErrA,javaScriptParensErrC,javaScriptParen,javaScriptBracket,javaScriptBlock,@htmlPreproc
+syntax region javaScriptBlock matchgroup=javaScriptBlock transparent
start="{" end="}" [EMAIL
PROTECTED],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 ccomment jsComment
+ syntax sync ccomment javaScriptComment
endif
+"" Fold control
if exists("javaScript_fold")
- syntax match jsFunction /\<function\>/
- syntax match jsFuncFoldStart
/\([=:^]\s*\)\@<=\<function\>\(\s*\w*\s*\)[EMAIL PROTECTED]/
nextgroup=jsFuncFoldParen skipwhite fold
- syntax region jsFuncFoldParen start="(" end=")" contained
nextgroup=jsFuncBlock skipwhite [EMAIL PROTECTED],jsParen fold
- syntax region jsFuncFoldBlock start="{" end="}\([\s;]*$\)[EMAIL
PROTECTED]" skipwhite contains=ALL contained fold
-
- syntax sync match jsSync grouphere jsFuncFoldBlock "\<function\>"
- syntax sync match jsSync grouphere NONE "^}"
+ syntax match javaScriptFunction /\<function\>/
nextgroup=javaScriptFuncName skipwhite
+ syntax region javaScriptFuncName contained
matchgroup=javaScriptFuncName start=/\%(\$\|\w\)*\s*(/ end=/)/
contains=javaScriptLineComment,javaScriptComment nextgroup=javaScriptFuncBlock
skipwhite skipempty
+ syntax region javaScriptFuncBlock contained
matchgroup=javaScriptFuncBlock start="{" end="}" [EMAIL
PROTECTED],javaScriptParensErrA,javaScriptParensErrB,javaScriptParen,javaScriptBracket,javaScriptBlock
fold
+ "" Fold setting
+ setlocal foldlevel=6
setlocal foldmethod=syntax
- setlocal foldtext=getline(v:foldstart)
+
+ setlocal foldtext=FT_JavaScriptDoc()
+
+ "" Default fold text for JavaScript JSDoc and Function
+ function! FT_JavaScriptDoc()
+ let i = 0
+ while i < 3
+ let line = getline(v:foldstart + i)
+ "let line = substitute(line, '^\s\+', '', '')
+ let line = substitute(line, '\s\+$', '', '')
+ if match(line, '\w\+') >= 0
+ break
+ endif
+ let i += 1
+ endwhile
+ return v:folddashes . line
+ endfunction
+
else
- syntax keyword jsFunction function
+ syntax keyword javaScriptFunction function
endif
" Define the default highlighting.
@@ -96,37 +193,60 @@
else
command -nargs=+ HiLink hi def link <args>
endif
- HiLink jsComment Comment
- HiLink jsLineComment Comment
- HiLink jsCommentTodo Todo
- HiLink jsStringS String
- HiLink jsStringD String
- HiLink jsRegexpString String
- HiLink jsCharacter Character
- HiLink jsConditional Conditional
- HiLink jsBranch Conditional
- HiLink jsRepeat Repeat
- HiLink jsStatement Statement
- HiLink jsFunction Function
- HiLink jsBlock Function
- HiLink jsError Error
- HiLink jsParenError Error
- HiLink jsOperator Operator
- HiLink jsType Type
- HiLink jsNull Type
- HiLink jsNumber Number
- HiLink jsBoolean Boolean
- HiLink jsLabel Label
- HiLink jsSpecial Special
- HiLink jsSource Special
- HiLink jsGlobalObjects Special
+ 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 cluster htmlJavaScript [EMAIL
PROTECTED],jsBracket,jsParen,jsBlock,jsParenError
-" Removing javaScriptExpression, while it didn't work because we are loaded
first.
+"syntax clear htmlJavaScript
"syntax clear javaScriptExpression
+syntax cluster htmlJavaScript [EMAIL
PROTECTED],javaScriptBracket,javaScriptParen,javaScriptBlock,javaScriptParenError
+syntax cluster javaScriptExpression [EMAIL
PROTECTED],javaScriptBracket,javaScriptParen,javaScriptBlock,javaScriptParenError,@htmlPreproc
let b:current_syntax = "javascript"
if main_syntax == 'javascript'
================================================================
---- CVS-web:
http://cvs.pld-linux.org/SOURCES/javascript.vim?r1=1.2&r2=1.3&f=u
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit