Permalink
Browse files

Merge pull request #12 from billychan/master

Highlight for function arguments
  • Loading branch information...
2 parents 5f45ff9 + 9a9c0da commit b03f40ff6ddf605ac146634a651632d6c1e8a50b @jelera committed Aug 13, 2012
Showing with 12 additions and 6 deletions.
  1. +12 −6 syntax/javascript.vim
View
@@ -171,16 +171,18 @@ endif "DOM/HTML/CSS
"" Code blocks
-syntax cluster javaScriptAll contains=javaScriptComment,javaScriptLineComment,javaScriptDocComment,javaScriptStringD,javaScriptStringS,javaScriptRegexpString,javaScriptNumber,javaScriptFloat,javaScriptLabel,javaScriptSource,javaScriptType,javaScriptOperator,javaScriptBoolean,javaScriptNull,javaScriptFunction,javaScriptConditional,javaScriptGlobal,javaScriptRepeat,javaScriptBranch,javaScriptStatement,javaScriptGlobalObjects,javaScriptMessage,javaScriptIdentifier,javaScriptExceptions,javaScriptReserved,javaScriptDeprecated,javaScriptDomErrNo,javaScriptDomNodeConsts,javaScriptHtmlEvents,javaScriptDotNotation,javaScriptBrowserObjects,javaScriptDOMObjects,javaScriptAjaxObjects,javaScriptPropietaryObjects,javaScriptDOMMethods,javaScriptHtmlElemProperties,javaScriptDOMProperties,javaScriptEventListenerKeywords,javaScriptEventListenerMethods,javaScriptAjaxProperties,javaScriptAjaxMethods
+syntax cluster javaScriptAll contains=javaScriptComment,javaScriptLineComment,javaScriptDocComment,javaScriptStringD,javaScriptStringS,javaScriptRegexpString,javaScriptNumber,javaScriptFloat,javaScriptLabel,javaScriptSource,javaScriptType,javaScriptOperator,javaScriptBoolean,javaScriptNull,javaScriptFuncKeyword,javaScriptConditional,javaScriptGlobal,javaScriptRepeat,javaScriptBranch,javaScriptStatement,javaScriptGlobalObjects,javaScriptMessage,javaScriptIdentifier,javaScriptExceptions,javaScriptReserved,javaScriptDeprecated,javaScriptDomErrNo,javaScriptDomNodeConsts,javaScriptHtmlEvents,javaScriptDotNotation,javaScriptBrowserObjects,javaScriptDOMObjects,javaScriptAjaxObjects,javaScriptPropietaryObjects,javaScriptDOMMethods,javaScriptHtmlElemProperties,javaScriptDOMProperties,javaScriptEventListenerKeywords,javaScriptEventListenerMethods,javaScriptAjaxProperties,javaScriptAjaxMethods,javaScriptFuncArg
if main_syntax == "javascript"
syntax sync clear
syntax sync ccomment javaScriptComment minlines=200
" syntax sync match javaScriptHighlight grouphere javaScriptBlock /{/
endif
-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 keyword javaScriptFuncKeyword function contained
+syntax region javaScriptFuncDef start="function" end="\([^)]*\)" contains=javaScriptFuncKeyword,javaScriptFuncArg keepend
+syntax match javaScriptFuncArg "\(([^()]*)\)" contains=javaScriptParens,javaScriptFuncComma contained
+syntax match javaScriptFuncComma /,/ contained
" syntax region javaScriptFuncBlock contained matchgroup=javaScriptFuncBlock start="{" end="}" contains=@javaScriptAll,javaScriptParensErrA,javaScriptParensErrB,javaScriptParen,javaScriptBracket,javaScriptBlock fold
syn match javaScriptBraces "[{}\[\]]"
@@ -199,6 +201,8 @@ function! JavaScriptFold()
setl foldtext=FoldText()
endfunction
+au FileType javascript call JavaScriptFold()
+
" }}}
" Define the default highlighting.
@@ -236,7 +240,7 @@ if version >= 508 || !exists("did_javascript_syn_inits")
HiLink javaScriptIdentifier Identifier
HiLink javaScriptRepeat Repeat
HiLink javaScriptStatement Statement
- HiLink javaScriptFunction Function
+ HiLink javaScriptFuncKeyword Function
HiLink javaScriptMessage Keyword
HiLink javaScriptDeprecated Exception
HiLink javaScriptError Error
@@ -278,10 +282,12 @@ if version >= 508 || !exists("did_javascript_syn_inits")
HiLink javaScriptAjaxMethods Exception
HiLink javaScriptAjaxProperties Type
- HiLink javaScriptFuncName Title
+ HiLink javaScriptFuncDef Title
+ HiLink javaScriptFuncArg Special
+ HiLink javaScriptFuncComma Operator
HiLink javaScriptHtmlEvents Special
- HiLink javaScriptHtmlElemProperties Type
+ HiLink javaScriptHtmlElemProperties Type
HiLink javaScriptEventListenerKeywords Keyword

0 comments on commit b03f40f

Please sign in to comment.