diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..b1ddccb1 --- /dev/null +++ b/ISSUE_TEMPLATE.md @@ -0,0 +1,13 @@ +*Requisite minimal reproducible example, formatted as plain text :* + +
+ +#### Optional: concerning jsx. +PLEASE PLEASE PLEASE make sure you have properly +setup and are sourcing this plugin https://github.com/mxw/vim-jsx + +WE DO NOT support JSX automatically, you need another plugin to add get this +functionality. + +Make sure the bug still exists if you disable all other javascript plugins +except the one noted above, mxw/vim-jsx diff --git a/README.md b/README.md index b2e3269c..81accf8c 100644 --- a/README.md +++ b/README.md @@ -1,82 +1,127 @@ -# vim-javascript v0.9.0 +# vim-javascript -JavaScript bundle for vim, this bundle provides syntax and indent plugins. +JavaScript bundle for vim, this bundle provides syntax highlighting and +improved indentation. -## A Quick Note on Regexes -Vim 7.4 was released recently, and unfortunately broke how this plugin -handles regexes. There was no real easy way for us to fix this unless we -completely rewrote how regexes work. +## Installation + +### Install with native package manager + + git clone https://github.com/pangloss/vim-javascript.git ~/.vim/pack/vim-javascript/start/vim-javascript + +since Vim 8. + +### Install with [pathogen](https://github.com/tpope/vim-pathogen) + + git clone https://github.com/pangloss/vim-javascript.git ~/.vim/bundle/vim-javascript + +alternatively, use a package manager like [vim-plug](https://github.com/junegunn/vim-plug) -Good News: There was a recent update to Vim 7.4 that fixes this issue. -Make sure you are at least using Vim 7.4, with patches 1-7. +## Configuration Variables -If you are stuck on an older version of Vim 7.4 with no way to update, -then simply perform the following commands to fix your current buffer: +The following variables control certain syntax highlighting plugins. You can +add them to your `.vimrc` to enable their features. + +----------------- ``` -:set regexpengine=1 -:syntax enable +let g:javascript_plugin_jsdoc = 1 ``` -## Installation +Enables syntax highlighting for [JSDocs](http://usejsdoc.org/). + +Default Value: 0 + +----------------- + +``` +let g:javascript_plugin_ngdoc = 1 +``` -- Install with [Vundle](https://github.com/gmarik/vundle) +Enables some additional syntax highlighting for NGDocs. Requires JSDoc plugin +to be enabled as well. -Add to vimrc: +Default Value: 0 - Bundle "pangloss/vim-javascript" +----------------- -And install it: +``` +let g:javascript_plugin_flow = 1 +``` - :so ~/.vimrc - :BundleInstall +Enables syntax highlighting for [Flow](https://flowtype.org/). -- Install with [pathogen](https://github.com/tpope/vim-pathogen) +Default Value: 0 - cd ~/.vim/bundle - git clone https://github.com/pangloss/vim-javascript.git +----------------- -## Configuration +```vim +augroup javascript_folding + au! + au FileType javascript setlocal foldmethod=syntax +augroup END +``` -The following variables control certain syntax highlighting features. You can -add them to your `.vimrc` to enable/disable their features. +Enables code folding for javascript based on our syntax file. -#### javascript_enable_domhtmlcss +Please note this can have a dramatic effect on performance. In some terminals +this may cause hangs during pasting. If you are affected by this, using +a different foldmethod (such as indent) may provide a better experience. -Enables HTML/CSS syntax highlighting in your JavaScript file. -Default Value: 0 +## Concealing Characters -#### b:javascript_fold +You can customize concealing characters, if your font provides the glyph you want, by defining one or more of the following +variables: -Enables JavaScript code folding. + let g:javascript_conceal_function = "ƒ" + let g:javascript_conceal_null = "ø" + let g:javascript_conceal_this = "@" + let g:javascript_conceal_return = "⇚" + let g:javascript_conceal_undefined = "¿" + let g:javascript_conceal_NaN = "ℕ" + let g:javascript_conceal_prototype = "¶" + let g:javascript_conceal_static = "•" + let g:javascript_conceal_super = "Ω" + let g:javascript_conceal_arrow_function = "⇒" + let g:javascript_conceal_noarg_arrow_function = "🞅" + let g:javascript_conceal_underscore_arrow_function = "🞅" -Default Value: 1 -#### g:javascript_conceal +You can enable concealing within VIM with: -Enables concealing characters. For example, `function` is replaced with `ƒ` + set conceallevel=1 -Default Value: 0 +OR if you wish to toggle concealing you may wish to bind a command such as the following which will map `l` (leader is usually the `\` key) to toggling conceal mode: -#### javascript_ignore_javaScriptdoc + map l :exec &conceallevel ? "set conceallevel=0" : "set conceallevel=1" -Disables JSDoc syntax highlighting -Default Value: 0 +## Indentation Specific + +* `:h cino-:` +* `:h cino-=` +* `:h cino-star` +* `:h cino-(` +* `:h cino-w` +* `:h cino-W` +* `:h cino-U` +* `:h cino-m` +* `:h cino-M` +* `:h 'indentkeys'` ## Contributing -This project uses the [git -flow](http://nvie.com/posts/a-successful-git-branching-model/) model for -development. There's [a handy git module for git -flow](//github.com/nvie/gitflow). If you'd like to be added as a contributor, -the price of admission is 1 pull request. Please follow the general code style +Please follow the general code style guides (read the code) and in your pull request explain the reason for the -proposed change and how it is valuable. +proposed change and how it is valuable. All p.r.'s will be reviewed by a +maintainer(s) then, hopefully, merged. + +Thank you! + -## Bug report +## License -Report a bug on [GitHub Issues](https://github.com/pangloss/vim-javascript/issues). +Distributed under the same terms as Vim itself. See `:help license`. diff --git a/after/ftplugin/javascript.vim b/after/ftplugin/javascript.vim new file mode 100644 index 00000000..c6c42d60 --- /dev/null +++ b/after/ftplugin/javascript.vim @@ -0,0 +1,12 @@ +" Vim filetype plugin file +" Language: JavaScript +" Maintainer: vim-javascript community +" URL: https://github.com/pangloss/vim-javascript + +setlocal iskeyword+=$ suffixesadd+=.js + +if exists('b:undo_ftplugin') + let b:undo_ftplugin .= ' | setlocal iskeyword< suffixesadd<' +else + let b:undo_ftplugin = 'setlocal iskeyword< suffixesadd<' +endif diff --git a/compiler/eslint.vim b/compiler/eslint.vim new file mode 100644 index 00000000..7695a072 --- /dev/null +++ b/compiler/eslint.vim @@ -0,0 +1,16 @@ +" Vim compiler plugin +" Language: JavaScript +" Maintainer: vim-javascript community +" URL: https://github.com/pangloss/vim-javascript + +if exists("current_compiler") + finish +endif +let current_compiler = "eslint" + +if exists(":CompilerSet") != 2 + command! -nargs=* CompilerSet setlocal +endif + +CompilerSet makeprg=eslint\ -f\ compact\ % +CompilerSet errorformat=%f:\ line\ %l\\,\ col\ %c\\,\ %m diff --git a/extras/flow.vim b/extras/flow.vim new file mode 100644 index 00000000..b34d7101 --- /dev/null +++ b/extras/flow.vim @@ -0,0 +1,109 @@ +syntax region jsFlowDefinition contained start=/:/ end=/\%(\s*[,=;)\n]\)\@=/ contains=@jsFlowCluster containedin=jsParen +syntax region jsFlowArgumentDef contained start=/:/ end=/\%(\s*[,)]\|=>\@!\)\@=/ contains=@jsFlowCluster +syntax region jsFlowArray contained matchgroup=jsFlowNoise start=/\[/ end=/\]/ contains=@jsFlowCluster,jsComment fold +syntax region jsFlowObject contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=@jsFlowCluster,jsComment fold +syntax region jsFlowExactObject contained matchgroup=jsFlowNoise start=/{|/ end=/|}/ contains=@jsFlowCluster,jsComment fold +syntax region jsFlowParens contained matchgroup=jsFlowNoise start=/(/ end=/)/ contains=@jsFlowCluster nextgroup=jsFlowArrow skipwhite keepend extend fold +syntax match jsFlowNoise contained /[:;,<>]/ +syntax keyword jsFlowType contained boolean number string null void any mixed JSON array Function object array bool class +syntax keyword jsFlowTypeof contained typeof skipempty skipwhite nextgroup=jsFlowTypeCustom,jsFlowType +syntax match jsFlowTypeCustom contained /[0-9a-zA-Z_.]*/ skipwhite skipempty nextgroup=jsFlowGeneric +syntax region jsFlowGeneric matchgroup=jsFlowNoise start=/\k\@<=/ contains=@jsFlowCluster containedin=@jsExpression,jsFlowDeclareBlock +syntax region jsFlowGeneric contained matchgroup=jsFlowNoise start=/(\@=/ oneline contains=@jsFlowCluster containedin=@jsExpression,jsFlowDeclareBlock +syntax region jsFlowObjectGeneric contained matchgroup=jsFlowNoise start=/\k\@<=/ contains=@jsFlowCluster nextgroup=jsFuncArgs +syntax match jsFlowArrow contained /=>/ skipwhite skipempty nextgroup=jsFlowType,jsFlowTypeCustom,jsFlowParens +syntax match jsFlowObjectKey contained /[0-9a-zA-Z_$?]*\(\s*:\)\@=/ contains=jsFunctionKey,jsFlowMaybe skipwhite skipempty nextgroup=jsObjectValue containedin=jsObject +syntax match jsFlowOrOperator contained /|/ skipwhite skipempty nextgroup=@jsFlowCluster +syntax keyword jsFlowImportType contained type typeof skipwhite skipempty nextgroup=jsModuleAsterisk,jsModuleKeyword,jsModuleGroup +syntax match jsFlowWildcard contained /*/ + +syntax match jsFlowReturn contained /:\s*/ contains=jsFlowNoise skipwhite skipempty nextgroup=@jsFlowReturnCluster,jsFlowArrow,jsFlowReturnParens +syntax region jsFlowReturnObject contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp extend fold +syntax region jsFlowReturnArray contained matchgroup=jsFlowNoise start=/\[/ end=/\]/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp fold +syntax region jsFlowReturnParens contained matchgroup=jsFlowNoise start=/(/ end=/)/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp,jsFlowReturnArrow fold +syntax match jsFlowReturnArrow contained /=>/ skipwhite skipempty nextgroup=@jsFlowReturnCluster +syntax match jsFlowReturnKeyword contained /\k\+/ contains=jsFlowType,jsFlowTypeCustom skipwhite skipempty nextgroup=jsFlowReturnGroup,jsFuncBlock,jsFlowReturnOrOp,jsFlowReturnArray +syntax match jsFlowReturnMaybe contained /?/ skipwhite skipempty nextgroup=jsFlowReturnKeyword,jsFlowReturnObject,jsFlowReturnParens +syntax region jsFlowReturnGroup contained matchgroup=jsFlowNoise start=// contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp +syntax match jsFlowReturnOrOp contained /\s*|\s*/ skipwhite skipempty nextgroup=@jsFlowReturnCluster +syntax match jsFlowWildcardReturn contained /*/ skipwhite skipempty nextgroup=jsFuncBlock +syntax keyword jsFlowTypeofReturn contained typeof skipempty skipwhite nextgroup=@jsFlowReturnCluster + +syntax region jsFlowFunctionGroup contained matchgroup=jsFlowNoise start=// contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncArgs +syntax region jsFlowClassGroup contained matchgroup=jsFlowNoise start=// contains=@jsFlowCluster skipwhite skipempty nextgroup=jsClassBlock +syntax region jsFlowClassFunctionGroup contained matchgroup=jsFlowNoise start=// contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncArgs +syntax match jsFlowObjectFuncName contained /\<\K\k*<\@=/ skipwhite skipempty nextgroup=jsFlowObjectGeneric containedin=jsObject + +syntax region jsFlowTypeStatement start=/\(opaque\s\+\)\?type\%(\s\+\k\)\@=/ end=/=\@=/ contains=jsFlowTypeOperator oneline skipwhite skipempty nextgroup=jsFlowTypeValue keepend +syntax region jsFlowTypeValue contained matchgroup=jsFlowNoise start=/=/ end=/\%(;\|\n\%(\s*|\)\@!\)/ contains=@jsFlowCluster,jsFlowGeneric,jsFlowMaybe +syntax match jsFlowTypeOperator contained /=/ containedin=jsFlowTypeValue +syntax match jsFlowTypeOperator contained /=/ +syntax keyword jsFlowTypeKeyword contained type + +syntax keyword jsFlowDeclare declare skipwhite skipempty nextgroup=jsFlowTypeStatement,jsClassDefinition,jsStorageClass,jsFlowModule,jsFlowInterface +syntax match jsFlowClassProperty contained /\<[0-9a-zA-Z_$]*\>:\@=/ skipwhite skipempty nextgroup=jsFlowClassDef containedin=jsClassBlock +syntax region jsFlowClassDef contained start=/:/ end=/\%(\s*[,=;)\n]\)\@=/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsClassValue + +syntax region jsFlowModule contained start=/module/ end=/\%({\|:\)\@=/ skipempty skipwhite nextgroup=jsFlowDeclareBlock contains=jsString +syntax region jsFlowInterface contained start=/interface/ end=/{\@=/ skipempty skipwhite nextgroup=jsFlowInterfaceBlock contains=@jsFlowCluster +syntax region jsFlowDeclareBlock contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=jsFlowDeclare,jsFlowNoise fold + +syntax match jsFlowMaybe contained /?/ +syntax region jsFlowInterfaceBlock contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=jsObjectKey,jsObjectKeyString,jsObjectKeyComputed,jsObjectSeparator,jsObjectFuncName,jsFlowObjectFuncName,jsObjectMethodType,jsGenerator,jsComment,jsObjectStringKey,jsSpreadExpression,jsFlowNoise,jsFlowParens,jsFlowGeneric keepend fold + +syntax region jsFlowParenAnnotation contained start=/:/ end=/[,=)]\@=/ containedin=jsParen contains=@jsFlowCluster + +syntax cluster jsFlowReturnCluster contains=jsFlowNoise,jsFlowReturnObject,jsFlowReturnArray,jsFlowReturnKeyword,jsFlowReturnGroup,jsFlowReturnMaybe,jsFlowReturnOrOp,jsFlowWildcardReturn,jsFlowReturnArrow,jsFlowTypeofReturn +syntax cluster jsFlowCluster contains=jsFlowArray,jsFlowObject,jsFlowExactObject,jsFlowNoise,jsFlowTypeof,jsFlowType,jsFlowGeneric,jsFlowMaybe,jsFlowParens,jsFlowOrOperator,jsFlowWildcard + +if version >= 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 jsFlowDefinition PreProc + HiLink jsFlowClassDef jsFlowDefinition + HiLink jsFlowArgumentDef jsFlowDefinition + HiLink jsFlowType Type + HiLink jsFlowTypeCustom PreProc + HiLink jsFlowTypeof PreProc + HiLink jsFlowTypeofReturn PreProc + HiLink jsFlowArray PreProc + HiLink jsFlowObject PreProc + HiLink jsFlowExactObject PreProc + HiLink jsFlowParens PreProc + HiLink jsFlowGeneric PreProc + HiLink jsFlowObjectGeneric jsFlowGeneric + HiLink jsFlowReturn PreProc + HiLink jsFlowParenAnnotation PreProc + HiLink jsFlowReturnObject jsFlowReturn + HiLink jsFlowReturnArray jsFlowArray + HiLink jsFlowReturnParens jsFlowParens + HiLink jsFlowReturnGroup jsFlowGeneric + HiLink jsFlowFunctionGroup PreProc + HiLink jsFlowClassGroup PreProc + HiLink jsFlowClassFunctionGroup PreProc + HiLink jsFlowArrow PreProc + HiLink jsFlowReturnArrow PreProc + HiLink jsFlowTypeStatement PreProc + HiLink jsFlowTypeKeyword PreProc + HiLink jsFlowTypeOperator Operator + HiLink jsFlowMaybe PreProc + HiLink jsFlowReturnMaybe PreProc + HiLink jsFlowClassProperty jsClassProperty + HiLink jsFlowDeclare PreProc + HiLink jsFlowModule PreProc + HiLink jsFlowInterface PreProc + HiLink jsFlowNoise Noise + HiLink jsFlowObjectKey jsObjectKey + HiLink jsFlowOrOperator jsOperator + HiLink jsFlowReturnOrOp jsFlowOrOperator + HiLink jsFlowWildcard PreProc + HiLink jsFlowWildcardReturn PreProc + HiLink jsFlowImportType PreProc + HiLink jsFlowTypeValue PreProc + HiLink jsFlowObjectFuncName jsObjectFuncName + delcommand HiLink +endif diff --git a/extras/jsdoc.vim b/extras/jsdoc.vim new file mode 100644 index 00000000..a7189d1b --- /dev/null +++ b/extras/jsdoc.vim @@ -0,0 +1,40 @@ +"" syntax coloring for javadoc comments (HTML) +syntax region jsComment matchgroup=jsComment start="/\*\s*" end="\*/" contains=jsDocTags,jsCommentTodo,jsCvsTag,@jsHtml,@Spell fold + +" tags containing a param +syntax match jsDocTags contained "@\(alias\|api\|augments\|borrows\|class\|constructs\|default\|defaultvalue\|emits\|exception\|exports\|extends\|fires\|kind\|link\|listens\|member\|member[oO]f\|mixes\|module\|name\|namespace\|requires\|template\|throws\|var\|variation\|version\)\>" skipwhite nextgroup=jsDocParam +" tags containing type and param +syntax match jsDocTags contained "@\(arg\|argument\|cfg\|param\|property\|prop\|typedef\)\>" skipwhite nextgroup=jsDocType +" tags containing type but no param +syntax match jsDocTags contained "@\(callback\|define\|enum\|external\|implements\|this\|type\|return\|returns\|yields\)\>" skipwhite nextgroup=jsDocTypeNoParam +" tags containing references +syntax match jsDocTags contained "@\(lends\|see\|tutorial\)\>" skipwhite nextgroup=jsDocSeeTag +" other tags (no extra syntax) +syntax match jsDocTags contained "@\(abstract\|access\|accessor\|async\|author\|classdesc\|constant\|const\|constructor\|copyright\|deprecated\|desc\|description\|dict\|event\|example\|file\|file[oO]verview\|final\|function\|global\|ignore\|inherit[dD]oc\|inner\|instance\|interface\|license\|localdoc\|method\|mixin\|nosideeffects\|override\|overview\|preserve\|private\|protected\|public\|readonly\|since\|static\|struct\|todo\|summary\|undocumented\|virtual\)\>" + +syntax region jsDocType contained matchgroup=jsDocTypeBrackets start="{" end="}" contains=jsDocTypeRecord oneline skipwhite nextgroup=jsDocParam +syntax match jsDocType contained "\%(#\|\"\|\w\|\.\|:\|\/\)\+" skipwhite nextgroup=jsDocParam +syntax region jsDocTypeRecord contained start=/{/ end=/}/ contains=jsDocTypeRecord extend +syntax region jsDocTypeRecord contained start=/\[/ end=/\]/ contains=jsDocTypeRecord extend +syntax region jsDocTypeNoParam contained start="{" end="}" oneline +syntax match jsDocTypeNoParam contained "\%(#\|\"\|\w\|\.\|:\|\/\)\+" +syntax match jsDocParam contained "\%(#\|\$\|-\|'\|\"\|{.\{-}}\|\w\|\~\|\.\|:\|\/\|\[.\{-}]\|=\)\+" + +syntax region jsDocSeeTag contained matchgroup=jsDocSeeTag start="{" end="}" contains=jsDocTags + +if version >= 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 jsDocTags Special + HiLink jsDocSeeTag Function + HiLink jsDocType Type + HiLink jsDocTypeBrackets jsDocType + HiLink jsDocTypeRecord jsDocType + HiLink jsDocTypeNoParam Type + HiLink jsDocParam Label + delcommand HiLink +endif diff --git a/extras/ngdoc.vim b/extras/ngdoc.vim new file mode 100644 index 00000000..c513d875 --- /dev/null +++ b/extras/ngdoc.vim @@ -0,0 +1,3 @@ +syntax match jsDocTags contained /@\(link\|method[oO]f\|ngdoc\|ng[iI]nject\|restrict\)/ nextgroup=jsDocParam skipwhite +syntax match jsDocType contained "\%(#\|\$\|\w\|\"\|-\|\.\|:\|\/\)\+" nextgroup=jsDocParam skipwhite +syntax match jsDocParam contained "\%(#\|\$\|\w\|\"\|-\|\.\|:\|{\|}\|\/\|\[\|]\|=\)\+" diff --git a/ftdetect/flow.vim b/ftdetect/flow.vim new file mode 100644 index 00000000..3f1ea65b --- /dev/null +++ b/ftdetect/flow.vim @@ -0,0 +1 @@ +autocmd BufNewFile,BufRead *.flow setfiletype flow diff --git a/ftdetect/javascript.vim b/ftdetect/javascript.vim index 805e1978..00487326 100644 --- a/ftdetect/javascript.vim +++ b/ftdetect/javascript.vim @@ -1,11 +1,8 @@ -au BufNewFile,BufRead *.js setf javascript -au BufNewFile,BufRead *.jsm setf javascript -au BufNewFile,BufRead *.json setf javascript -au BufNewFile,BufRead Jakefile setf javascript - fun! s:SelectJavascript() - if getline(1) =~# '^#!.*/bin/env\s\+node\>' + if getline(1) =~# '^#!.*/bin/\%(env\s\+\)\?node\>' set ft=javascript endif endfun -au BufNewFile,BufRead * call s:SelectJavascript() + +autocmd BufNewFile,BufRead *.{js,mjs,cjs,jsm,es,es6},Jakefile setfiletype javascript +autocmd BufNewFile,BufRead * call s:SelectJavascript() diff --git a/indent/javascript.vim b/indent/javascript.vim index 29fba2ba..b754e282 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -1,439 +1,477 @@ " Vim indent file " Language: Javascript -" Acknowledgement: Based off of vim-ruby maintained by Nikolai Weibull http://vim-ruby.rubyforge.org - -" 0. Initialization {{{1 -" ================= +" Maintainer: Chris Paul ( https://github.com/bounceme ) +" URL: https://github.com/pangloss/vim-javascript +" Last Change: December 4, 2017 " Only load this indent file when no other was loaded. -if exists("b:did_indent") +if exists('b:did_indent') finish endif let b:did_indent = 1 -setlocal nosmartindent - " Now, set up our indentation expression and keys that trigger it. setlocal indentexpr=GetJavascriptIndent() -setlocal indentkeys=0{,0},0),0],0\,,!^F,o,O,e +setlocal autoindent nolisp nosmartindent +setlocal indentkeys+=0],0) +" Testable with something like: +" vim -eNs "+filetype plugin indent on" "+syntax on" "+set ft=javascript" \ +" "+norm! gg=G" '+%print' '+:q!' testfile.js \ +" | diff -uBZ testfile.js - + +let b:undo_indent = 'setlocal indentexpr< smartindent< autoindent< indentkeys< lisp<' " Only define the function once. -if exists("*GetJavascriptIndent") +if exists('*GetJavascriptIndent') finish endif let s:cpo_save = &cpo set cpo&vim -" 1. Variables {{{1 -" ============ - -let s:js_keywords = '^\s*\(break\|case\|catch\|continue\|debugger\|default\|delete\|do\|else\|finally\|for\|function\|if\|in\|instanceof\|new\|return\|switch\|this\|throw\|try\|typeof\|var\|void\|while\|with\)' +" indent correctly if inside