Squashed 'vim/bundle/javascript/' changes from e9a59c877..d2ccd306f

d2ccd306f use generic equivalent
3ea6ed6ac Trim optimize (#1024)
c03aee798 add 'mjs' extension (#1023)
c5e5e2012 refactor, mergeable (#1018)
dcb4e4762 cleaning, small optimization? (#1015)
7097cdad8 Small Flow return fix
739562910 more simplify of PCL (#1013)
8ea46f3e6 neater/faster iterating
6ccc1a713 Fix certain flow annotations within classes
fc80419fd trivial indent fixes / updates (#1007)
09d7c7051 faster/smaller cache access, SynId function (#1005)
7175ba5e6 missed a condition last time
ff851de60 improve conditionals all over (#1002)
37a68c3c7 Add fold to various flow regions
dd1f74fb8 Another quick flow patch
bc5b02484 A few more fixes
008e98985 Trying out some flow tweaks
e4870b4f5 More fixes for flow
0353342bc Fix for jsFlowOperator
243932e58 A ton of flow fixes
ff5e284f4 exponentiator, operator things (#1001)
f0ce7ffa9 cino-W (#1000)
cc84aa380 Merge pull request #999 from wavded/patch-2
ef74079e9 Add @async tag support.
603ec7156 cleaning, indent (#997)
be46c1c4d document and improve class cases (#996)
9b2a032c3 fix list size error with setpos()
7684f3cfc magic
1bd80e092 edge case fix: prevcodeline() and c style comments (#994)
72f4a95b2 fix for `[*` failing
43097941a let [] =[], minor formatting (#990)
aba8630e2 Making jsModuleGroup foldable
517d37c97 Merge pull request #992 from pangloss/async-fix
97203f192 async/await should be an @jsExpression
ebc6fd267 fix expr_col case
14cf98883 remove semicolon flag; flow (#989)
e0472fc50 indent file cleaning (#988)
4eac815fa cleaner searcpair workaround
e6f514324 IsCont trivial refactor (#986)
efd4f1f5e Small fix for Flow class annotations
8d6fbfb41 lex type import (#984)
f20659188 small logic reversal
438990878 date, cleaning
271f73123 clean up Syn
e14cfb6a0 flowtype requiring (#982)
2b0889fa8 naturalize (#981)
0b44edb6f Pcodeline (#980)
868c15b1c non-interrupting limit info in debugging
42c9451ab more lookbehind needed... classes
1cb44af82 make var naming consistent (#977)
6f880fe81 fix for non-inheriting (#976)
4e3c3c0d6 small logic fix
e5cdee7b2 assure switch isn't method (#974)
931dbd5b6 cino-M (#971)
a5a9a17d4 add possible ident shorthand (#970)
7ba092739 cleaner generator shorthand fix (#969)
2dfe7cded star shorthand workaround
9ea6e5df1 date
388c9cbc4 Nat is unary
147e50669 remove script-global, range reversal, max (#965)
18cd99029 cino-star behavior; remove s:W references
e092e7fce star comment find, as loop (#963)
eb5f00f67 Small fix for jsTaggedTemplate
beba61e8e trivial reading stuff and date
1d28953b1 clearer -1 check
28281d25a simplify isBlock and doWhile (#962)
4242a4b5f remove function setup
2e24d89cc fix wording
f5f32a9f4 Update README.md
bb2c6857d cino-= and misc style changes: indent.vim (#959)
89c3d920e variable of current token in functions (#958)
21a8a7ed8 misc:refactor (#957)
dc0bb4748 cleaning: indent.vim (#956)
d3068263e date
d9820f993 remove comment hack
5f0163963 no eval or confusing viml workarounds (#954)
e73b32207 deduplication (#953)
809b6beb4 move state out of try block
82b142242 test fix (#952)
9ce4ea852 misc: go back to l:pos only when needed; (#947)
d12dc6156 just use dict value
18c2c847e Merge pull request #925 from pangloss/issue-template
d33561172 Improve issue template
7d8a2b117 Adding an ISSUE_TEMPLATE.md
a898a9780 Merge pull request #942 from pangloss/bounceme-patch-1
c8aa5ed52 fix wrong func call
244985f10 don't use cursor() in conditional
573879c9d Reuse pos restorer, misc cleaning (#943)
0c26c4808 fix #940: ternary expression returning arrow
81166acad cache synID calls (#938)
a1f36ff79 move s: vars
5b2f56d75 Fix buffer variables inited only once (#941)
65dbdfc45 Fix variable typo (#939)
f7ffea095 Misc: indent (#937)
896bb54d2 configurable syntax skipping (#936)
53b043924 misc: indent.vim (#935)
259f5282f (silent) exception same as within searchpair (#934)
1e59f8488 break at html too
fcdacf6f7 break search at col:1 (#933)
ac71ceca3 another str2nr()
45d092f65 str2nr() to prevent octal
e573aa0b6 unneeded var declare (#932)
317125e18 &cino non-regex (#931)
2bca9c6f6 misc fixes, non-critical stuff (#929)
10492a89d cino-U (#928)
145fdc76d script-tag var access (#927)
3c2923e43 dont depend on loop error handling
2c8733ed7 vim script minify (#924)
021a5ff80 simpler, float less, cino parse (#926)
5511721b1 compiler header
23f5d0ed1 update comments
0d7ad9320 better do -> while "switch"
1a7a8fc8d no pos movement, exit correctly in prevline()
d8729f221 string detecting for prevline()
a327247d1 add note
ceae62037 Merge pull request #921 from pangloss/fix-prototype
ff9918c7c Fix prototype matching
431aa0ed1 Merge pull request #920 from pangloss/add-await-js-expression
5e85c21d0 Adding await to @jsExpression
665501ba2 various indent cleanups (#917)
55651ba6d add "es" extension (#916)
b6c00a194 move flow detect to ft detect file (#913)
f786167f9 Merge pull request #912 from sebcode/master
0cc170159 Allow flowtype annotation for arrow func return val
c87bb4345 auto load flow file with comment header (#911)
8fb55c5be minor change to limit
9cbe46c4a limit expr_col
b954ab478 ternary assignment
4e64bcff9 cleaner limiting in html
bea0e2096 change buffer variable for html
3ca2f636d fix, keep cache valid in tag
10f71931a don't move to scriptTag
87ecc8742 fix html without pangloss repo syntax file (#909)
ac4efdca0 indenting for first line after script tag (#908)
1e4ec0aaf also disregard flow bracket as operator
8e51618ba fix embedded js (#907)
63355ea70 fix: add jsImport and jsExport to htmlJavaScript (#906)
3530116b5 builtin optimization, fail condition (#904)
d2bc31992 more pattern simplifications (#903)
fac43e7d2 explicit match of cino parse (#902)
a24f345f4 dot isblock
90cf82a9f Remove a call to trim() in Onescope (#900)
afe6b8bf2 do while; experiment (#899)
0034e332b strpart instead of substrings,date (#898)
d87476f30 simplify balance optimization (#897)
289eca381 use search() 'e' flag to simplify regex
015004855 case
4a442bade virtual (#894)
669262388 replace tabs shell comment
e79107b49 add small note about testing in shell (#890)
2ad6da791 small code style fixes
1f9e29243 Onescope() refining (#889)
688d34b2e fix type as identifier (#887)
a2259d32b flow type ob (#886)
5ff6d5071 more prevcodeline improving (#884)
6c2007980 small fix
6007c680e refactor Prevcodeline (#883)
d8ffdf71e remove extra func call
867f50038 remove eval in continues() (#881)
95405f8e3 shiftwidth() compat (#879)
d79de5b4f expr_col switch? (#878)
a35306e0a save_pos instead of try/finally , date (#877)
40c437fd1 reimplement Trim() (#876)
6be84aa6b alternating balanced() (#874)
f92f5814e use float support rather than reimplement it (#873)
44b70ce73 remove pointless format flag (#872)
1ad5378d6 cleaning (#870)
c3892c40a reverse logic,skipfunc (#869)
57c837045 regex in token (#868)
b99793534 optimization in alternatepair() (#867)
0f36d47e8 make search magic
6fad4c536 document cino-w
73a8a137d cino-w (#864)
eb0465274 more c-parse fixes
ab5f29eee safe list value
6968e93e3 cino-parsing helper (#862)
5824735cd cino-b (#861)
c07c72700 unneeded condition
d1b6d908d safer check for paren/cino
4b219f6c9 doc
6c0bd6505 cino=( (#860)
53c547bbb extends, isBlock
4dc80ee25 regex explicit case
203126dae remove quote inaccuracy
05e17e4d4 if ptoken fails, restore cursor (#858)
23e5fa204 fix jsx detection (#857)
f70263dc6 clean up continues() (#856)
51e0cc54f more likely condition first (#855)
3344f1388 more keywords/operators (#854)
7072eb54a new operator
97a8ab46e cino option
220ce28ee reduce if nesting, isBlock consistency (#853)
6e8811c32 Enabling spell checking on template strings (#834)
e3a0e1f55 ternary algorithm simplified
c63905600 regex case fixes (#850)
3bb778ee7 faster tern col regex (#849)
9cf48ee3d string group name
18bc58a02 refactor isBlock (#846)
38c2b557b full syntax check if inside jsx (#844)
742f55bf1 syn related indent fixes (#843)
545ab1a90 Merge pull request #842 from pangloss/misc-bugfixes
5c526adcb Fixes to some comment chaining
1f1d5ebf3 unicode regex flag (#840)
d993dda7d Merge pull request #838 from pangloss/bugfix/js-func-call
994b78bf7 Fix for jsFuncCall
871ab2959 prevent octal conversion (#835)
9ada8ab92 switch_offset min value (#832)
8d0d45349 template inner code (#830)
b7677c924 float-less cino parsing (#828)
307eb850d better zero char solution
bf2f6a8e4 do inc/dec/arrow detection in function (#827)
2195ce010 safer GetPair condition (#824)
432d01b2d Merge pull request #823 from pangloss/ret
c354c479e Merge pull request #822 from qstrahl/fix-js-class-value-arrow-function
1ec994774 shorten final return
8b55755e9 Remove keepend from jsClassValue region
4e1ec95dc fix
9d24edb47 accurate Trim and prev_token funcs (#817)
8526ce56e Merge pull request #814 from pangloss/feature/js-object-prop
019e523aa combine ind logic (#816)
67b90c737 First pass at `jsObjectProp`
3cf8f3d0b Merge pull request #801 from pangloss/feature/new-bind-syntax
22c7e7b3e jsBlockLabels are not allowed if ::
7c95ee824 First pas at :: support
9f3ecf459 Merge pull request #815 from pangloss/jstemplateexpression
88c85d9ea Renaming jsTemplateVar -> jsTemplateExpression
690f23ea8 fix for inc/dec operators and blocks (#811)
18cbb4bde cleaning (#810)
0367cb5d5 add compiler plugin (#808)
f54c861a8 remove search call (#809)
96a5b5ec6 remove z flag
53dea7aff cleaning,search flags (#807)
56f6fbbe4 improve regex at skip_func (#806)
f8e9c1a7f check for lines which contain at least 2 `/` (#804)
cfaa6e4ef Merge pull request #789 from wavded/patch-1
7050c3ad9 Merge pull request #802 from pangloss/bugfix/template-var-keepend
cb7d5aeae Attempted fix for jsTemplateVar
ce415c397 Merge pull request #778 from pangloss/feature/block-support
9148cd38d Add extend to jsTernaryIf
659cbf3de Fix switch cases from being detected as labels
f11f948c0 Adding support for block statement labels
4839870f2 Fix jsTernaryIf and jsObjects
fe92d4991 First pass at Block support
9e9e2c4f3 remove added s:Trim arg
bd9b70af0 remove html comment
faa1a4bf4 cleaning (#799)
685219245 Fix Function capitalization in Flow annotations
b3a1e8a87 add await
d817bd4f1 re-add throw
bba35b25c change a keyword
58fdba82d cleaning
3ee5de406 fix keywords
043bb4aa0 fix destruct
dce5a10a0 remove check of keyword
2f182a1f4 generic search function (#795)
0b9c46e46 remove flow cases
006f889b4 exact object indent (#793)
2c44678d3 Merge pull request #791 from pangloss/fix-empty-arrow-args
d8a6fef99 Bugfix for jsArrowFuncArgs
aa3a16993 various fixes (#790)
17bbd02c1 ternary function (#788)
ff1fc56de Improve @typedef syntax for namepath.
ad3261e92 magic portability (#786)
a584a283b Merge pull request #787 from pangloss/add-comments-to-destructuring-blocks
364309983 Adding jsComment to destructuring blocks
8e3ae21c3 fix case block logic
36ebd9f8a rename,refactor, jump label support for isblock() (#775)
c2f65cd3f Merge pull request #782 from pangloss/fix-async
1a7632e6c Fixing how async is used
2f8d1fe2e Merge pull request #781 from pangloss/misc-flow-tweaks
7cb3abf71 Misc flow fixes
799274716 Merge pull request #780 from pangloss/flow-fix
ddefa30d1 Adding Flow wildcard support
3ef7bfd18 Merge pull request #779 from pangloss/misc-bugfixes
431e22926 Fix require in jsGlobalNodeObjects
c347e2da1 Adds __dirname & __filename to jsGlobalNodeObjects
f60eb29ea Merge pull request #777 from pangloss/bugfix/add-spread-to-jsblock
6f01baa66 Adding jsSpreadExpression to jsBlock
28732ef1a Merge pull request #776 from pangloss/bugfix/js-class-value
c12ae7609 An attempted fix for jsClassValue region end
521f4eda7 jump label support (#772)
a6176945c add other comments
8043c4bc0 detect string, prevline (#771)
ccc9f3017 improvements to prevcodeline() (#769)
da1eee445 odd comments, shebang (#768)
ce0f529bb refactor s:OneScope() (#766)
1cb6f1094 cleaner loop (#765)
f33b9ed81 cleaning, edge case with keyword (#764)
117c72721 more edge case accuracy,refactoring (#761)
294563c61 &cino format
63daab731 better &cino parsing (#759)
8e17e2330 Detect .es6 files as JavaScript (#199)
25cff858e don't move cursor at default label
3583822da reflow comment
4149f1d30 cleaning continued braceless statement (#758)
9db487d00 add option in s:prev_token() (#757)
1a17ce8c6 Merge pull request #756 from pangloss/array-destructuring-default-value-support
0dd9ad3b4 Fix array destructuring as func arg definitions
0bf390d9c optimize indent with basic syntax file (#753)
afecff2b5 v:lnum cleaning
3cc3ef7c1 cleaning (#751)
e80725868 Revert "match isk in token regex" (#750)
82f064a12 match isk in token regex (#749)
039c611e1 refactor v:lnum cleaning (#748)
d81b076b5 make regex for token() more intuitive (#746)
a210f3916 fix code comment
554ae9b24 package-manager info (#744)
d377f45bd regex simplified in trim() (#745)
d2bc5d49e remove conditional
9e0aa00b6 clarify readme
ba9501bfc markdown fixes
41a3bceb4 more readme fixes
df14847ad fix readme
9f4772175 Added conceal for no-argument arrow functions - either `()=>` or `_=>` (#735)
6d81ec817 only Trim() if in a block (#743)
66b25d97c Indent: use previous Trim, with new interface (#741)
14919946c date, code documenting
7ceb23304 misc indent changes (#739)
982f699de small optimization (#738)
1bc948137 date, minor regex
c1d4b3b07 keywords used as props (#737)
25ceb5578 cleaning, Rework prevcodeline() (#736)
edf962fb5 Merge pull request #734 from pangloss/fix-flow-import-type
3dd27d631 Adding support for Flow type imports
18ff935c9 optimization: no continuation at block start (#733)
8265877f7 indentkeys (#732)
1801887f2 operator cleaning (#729)
5e024dc2e Merge pull request #731 from pangloss/refactor-import-export
66f120cb0 Improve default handling
3873adbff Completely refactored how import/export work
894e26d85 Merge pull request #727 from pangloss/fix-import-region
91b0a0da0 Fix end pattern for import region
c92a0cad8 paren start line as baseline in blocks (#725)
a87c94438 unneeded token call (#722)
209b57f9d remove dead code, rename function, date (#721)
ae9324a61 improve ptoken (#719)
bac863e62 Merge pull request #718 from pangloss/fix-spread-in-brackets
3efcf3111 Adds jsSpreadExpression to jsBracket
7b9c64f15 Merge pull request #717 from pangloss/improve-class-definition
b18c6b88a Basic improvement to jsClassDefinition
f4245c4f7 more correct comment match (#714)
737c23845 faster prevline (#713)
b8c62023d add operators, regex experiment (#711)
540d3a572 improve regex for s:Trim (#710)
b3b85e34b trim from start of comment sequence (#709)
f177220eb regex prettify
bbabf9d67 syntax aware previous token (#705)
c938b83e2 Update README.md (#702)
22b9f0f8e consider regex when matching '/' (#703)

git-subtree-dir: vim/bundle/javascript
git-subtree-split: d2ccd306f2c11f061c5284ff5d315c7cf257e32a
main
Buddy Sandidge 8 years ago
parent b9da30d927
commit c52a22597f

@ -1,18 +0,0 @@
## 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
guides (read the code) and in your pull request explain the reason for the
proposed change and how it is valuable.
## Pull Requests
Please make your pull requests against the `develop` branch; we stage changes
for testing there to avoid unexpected breakages for our users. :)
## Bug report
Report a bug on [GitHub Issues](https://github.com/pangloss/vim-javascript/issues).

@ -0,0 +1,12 @@
If you are reporting an issue that involves any JSX (e.g.
<div>{`${example}`}</div>), 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.
If applicable, include a snippet of code that we can easily copy and paste that
replicates your bug.
Make sure the bug still exists if you disable all other javascript plugins
except the one noted above, mxw/vim-jsx

@ -6,32 +6,12 @@ improved indentation.
## Installation
### Install with [Vundle](https://github.com/gmarik/vundle)
Add to vimrc:
Plugin 'pangloss/vim-javascript'
And install it:
:so ~/.vimrc
:PluginInstall
### Install with [vim-plug](https://github.com/junegunn/vim-plug)
Add to vimrc:
Plug 'pangloss/vim-javascript'
And install it:
:so ~/.vimrc
:PlugInstall
### 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)
## Configuration Variables
@ -83,38 +63,53 @@ global vim option, we do not set it ourselves.
## Concealing Characters
You can customize concealing characters by defining one or more of the following
You can customize concealing characters, if your font provides the glyph you want, by defining one or more of the following
variables:
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_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 = "🞅"
You can enable concealing within VIM with:
set conceallevel=1
OR if you wish to toggle concealing you may wish to bind a command such as the following which will map `<LEADER>l` (leader is usually the `\` key) to toggling conceal mode:
map <leader>l :exec &conceallevel ? "set conceallevel=0" : "set conceallevel=1"<CR>
## 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.
## Bug Reports
proposed change and how it is valuable. All p.r.'s will be reviewed by a
maintainer(s) then, hopefully, merged.
Report a bug on [GitHub Issues](https://github.com/pangloss/vim-javascript/issues).
Thank you!
## License

@ -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 <args>
endif
CompilerSet makeprg=eslint\ -f\ compact\ %
CompilerSet errorformat=%f:\ line\ %l\\,\ col\ %c\\,\ %m

@ -1,33 +1,38 @@
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
syntax region jsFlowObject contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=@jsFlowCluster
syntax region jsFlowParens contained matchgroup=jsFlowNoise start=/(/ end=/)/ 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 keepend 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 jsFlowType contained boolean number string null void any mixed JSON array Function object array bool class
syntax keyword jsFlowTypeof contained typeof skipempty skipempty nextgroup=jsFlowTypeCustom,jsFlowType
syntax match jsFlowTypeCustom contained /[0-9a-zA-Z_.]*/ skipwhite skipempty nextgroup=jsFlowGroup
syntax region jsFlowGroup contained matchgroup=jsFlowNoise start=/</ end=/>/ contains=@jsFlowCluster
syntax region jsFlowArrowArguments contained matchgroup=jsFlowNoise start=/(/ end=/)\%(\s*=>\)\@=/ oneline skipwhite skipempty nextgroup=jsFlowArrow contains=@jsFlowCluster
syntax match jsFlowArrow contained /=>/ skipwhite skipempty nextgroup=jsFlowType,jsFlowTypeCustom,jsFlowParens
syntax match jsFlowMaybe contained /?/ skipwhite skipempty nextgroup=jsFlowType,jsFlowTypeCustom,jsFlowParens,jsFlowArrowArguments
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 skipwhite skipempty nextgroup=jsModuleAsterisk,jsModuleKeyword,jsModuleGroup
syntax match jsFlowWildcard contained /*/
syntax match jsFlowReturn contained /:\s*/ contains=jsFlowNoise skipwhite skipempty nextgroup=@jsFlowReturnCluster
syntax region jsFlowReturnObject contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp
syntax region jsFlowReturnArray contained matchgroup=jsFlowNoise start=/\[/ end=/\]/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp
syntax region jsFlowReturnParens contained matchgroup=jsFlowNoise start=/(/ end=/)/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturnOrOp
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 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
syntax match jsFlowReturnMaybe contained /?/ skipwhite skipempty nextgroup=jsFlowReturnKeyword
syntax match jsFlowReturnMaybe contained /?/ skipwhite skipempty nextgroup=jsFlowReturnKeyword,jsFlowReturnObject
syntax region jsFlowReturnGroup contained matchgroup=jsFlowNoise start=/</ end=/>/ 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 region jsFlowFunctionGroup contained matchgroup=jsFlowNoise start=/</ end=/>/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsFuncArgs
syntax region jsFlowClassGroup contained matchgroup=jsFlowNoise start=/</ end=/>/ contains=@jsFlowCluster skipwhite skipempty nextgroup=jsClassBlock
syntax region jsFlowTypeStatement start=/type/ end=/=\@=/ contains=jsFlowTypeOperator oneline skipwhite skipempty nextgroup=jsFlowTypeValue keepend
syntax region jsFlowTypeValue contained start=/=/ end=/[;\n]/ contains=@jsExpression,jsFlowGroup,jsFlowMaybe
syntax region jsFlowTypeStatement start=/type\%(\s\+\k\)\@=/ end=/=\@=/ contains=jsFlowTypeOperator oneline skipwhite skipempty nextgroup=jsFlowTypeValue keepend
syntax region jsFlowTypeValue contained matchgroup=jsFlowNoise start=/=/ end=/[\n;]/ contains=@jsFlowCluster,jsFlowGroup,jsFlowMaybe
syntax match jsFlowTypeOperator contained /=/ containedin=jsFlowTypeValue
syntax match jsFlowTypeOperator contained /=/
syntax keyword jsFlowTypeKeyword contained type
@ -37,12 +42,18 @@ syntax region jsFlowClassDef contained start=/:/ end=/\%(\s*[,=;)\n]\)
syntax region jsFlowModule contained start=/module/ end=/{\@=/ skipempty skipempty nextgroup=jsFlowDeclareBlock contains=jsString
syntax region jsFlowInterface contained start=/interface/ end=/{\@=/ skipempty skipempty nextgroup=jsFlowInterfaceBlock contains=@jsFlowCluster
syntax region jsFlowDeclareBlock contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=jsFlowDeclare,jsFlowNoise
syntax region jsFlowDeclareBlock contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=jsFlowDeclare,jsFlowNoise fold
syntax region jsFlowInterfaceBlock contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=jsObjectKey,jsObjectKeyString,jsObjectKeyComputed,jsObjectSeparator,jsObjectFuncName,jsObjectMethodType,jsGenerator,jsComment,jsObjectStringKey,jsSpreadExpression,jsFlowNoise keepend
" NOTE: It appears the nextgroup was causing a ton of breakages... testing it
" witout a nextgroup, but keeping this arround for reference incase something breaks
" syntax match jsFlowMaybe contained /?/ nextgroup=jsFlowType,jsFlowTypeCustom,jsFlowParens,jsFlowArrowArguments,jsFlowObject,jsFlowReturnObject extend keepend
syntax match jsFlowMaybe contained /?/
syntax region jsFlowInterfaceBlock contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=jsObjectKey,jsObjectKeyString,jsObjectKeyComputed,jsObjectSeparator,jsObjectFuncName,jsObjectMethodType,jsGenerator,jsComment,jsObjectStringKey,jsSpreadExpression,jsFlowNoise keepend fold
syntax cluster jsFlowReturnCluster contains=jsFlowNoise,jsFlowReturnObject,jsFlowReturnArray,jsFlowReturnKeyword,jsFlowReturnGroup,jsFlowReturnMaybe,jsFlowReturnOrOp
syntax cluster jsFlowCluster contains=jsFlowArray,jsFlowObject,jsFlowNoise,jsFlowTypeof,jsFlowType,jsFlowGroup,jsFlowArrowArguments,jsFlowMaybe,jsFlowParens,jsFlowOrOperator
syntax region jsFlowParenAnnotation contained start=/:/ end=/[,=)]\@=/ containedin=jsParen contains=@jsFlowCluster
syntax cluster jsFlowReturnCluster contains=jsFlowNoise,jsFlowReturnObject,jsFlowReturnArray,jsFlowReturnKeyword,jsFlowReturnGroup,jsFlowReturnMaybe,jsFlowReturnOrOp,jsFlowWildcardReturn,jsFlowReturnArrow
syntax cluster jsFlowCluster contains=jsFlowArray,jsFlowObject,jsFlowExactObject,jsFlowNoise,jsFlowTypeof,jsFlowType,jsFlowGroup,jsFlowArrowArguments,jsFlowMaybe,jsFlowParens,jsFlowOrOperator,jsFlowWildcard
if version >= 508 || !exists("did_javascript_syn_inits")
if version < 508
@ -59,9 +70,11 @@ if version >= 508 || !exists("did_javascript_syn_inits")
HiLink jsFlowTypeof PreProc
HiLink jsFlowArray PreProc
HiLink jsFlowObject PreProc
HiLink jsFlowExactObject PreProc
HiLink jsFlowParens PreProc
HiLink jsFlowGroup PreProc
HiLink jsFlowReturn PreProc
HiLink jsFlowParenAnnotation PreProc
HiLink jsFlowReturnObject jsFlowReturn
HiLink jsFlowReturnArray jsFlowArray
HiLink jsFlowReturnParens jsFlowParens
@ -70,9 +83,10 @@ if version >= 508 || !exists("did_javascript_syn_inits")
HiLink jsFlowClassGroup PreProc
HiLink jsFlowArrowArguments PreProc
HiLink jsFlowArrow PreProc
HiLink jsFlowReturnArrow PreProc
HiLink jsFlowTypeStatement PreProc
HiLink jsFlowTypeKeyword PreProc
HiLink jsFlowTypeOperator PreProc
HiLink jsFlowTypeOperator Operator
HiLink jsFlowMaybe PreProc
HiLink jsFlowReturnMaybe PreProc
HiLink jsFlowClassProperty jsClassProperty
@ -81,7 +95,11 @@ if version >= 508 || !exists("did_javascript_syn_inits")
HiLink jsFlowInterface PreProc
HiLink jsFlowNoise Noise
HiLink jsFlowObjectKey jsObjectKey
HiLink jsFlowOrOperator PreProc
HiLink jsFlowOrOperator jsOperator
HiLink jsFlowReturnOrOp jsFlowOrOperator
HiLink jsFlowWildcard PreProc
HiLink jsFlowWildcardReturn PreProc
HiLink jsFlowImportType PreProc
HiLink jsFlowTypeValue PreProc
delcommand HiLink
endif

@ -4,13 +4,13 @@ syntax region jsComment matchgroup=jsComment start="/\*\s*" end="\*/" contai
" 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\)\>" skipwhite nextgroup=jsDocType
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\|typedef\|return\|returns\)\>" skipwhite nextgroup=jsDocTypeNoParam
syntax match jsDocTags contained "@\(callback\|define\|enum\|external\|implements\|this\|type\|return\|returns\)\>" 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\|author\|classdesc\|constant\|const\|constructor\|copyright\|deprecated\|desc\|description\|dict\|event\|example\|file\|file[oO]verview\|final\|function\|global\|ignore\|inheritDoc\|inner\|instance\|interface\|license\|localdoc\|method\|mixin\|nosideeffects\|override\|overview\|preserve\|private\|protected\|public\|readonly\|since\|static\|struct\|todo\|summary\|undocumented\|virtual\)\>"
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\|inheritDoc\|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

@ -1,6 +1,13 @@
au BufNewFile,BufRead *.js setf javascript
au BufNewFile,BufRead *.jsm setf javascript
au BufNewFile,BufRead Jakefile setf javascript
au BufNewFile,BufRead *.{js,mjs,jsm,es,es6},Jakefile setf javascript
fun! s:SourceFlowSyntax()
if !exists('javascript_plugin_flow') && !exists('b:flow_active') &&
\ search('\v\C%^\_s*%(//\s*|/\*[ \t\n*]*)\@flow>','nw')
runtime extras/flow.vim
let b:flow_active = 1
endif
endfun
au FileType javascript au BufRead,BufWritePost <buffer> call s:SourceFlowSyntax()
fun! s:SelectJavascript()
if getline(1) =~# '^#!.*/bin/\%(env\s\+\)\?node\>'

@ -2,7 +2,7 @@
" Language: Javascript
" Maintainer: Chris Paul ( https://github.com/bounceme )
" URL: https://github.com/pangloss/vim-javascript
" Last Change: November 6, 2016
" Last Change: August 12, 2017
" Only load this indent file when no other was loaded.
if exists('b:did_indent')
@ -10,13 +10,27 @@ if exists('b:did_indent')
endif
let b:did_indent = 1
" indent correctly if inside <script>
" vim/vim@690afe1 for the switch from cindent
let b:html_indent_script1 = 'inc'
" Now, set up our indentation expression and keys that trigger it.
setlocal indentexpr=GetJavascriptIndent()
setlocal autoindent nolisp nosmartindent
setlocal indentkeys=0{,0},0),0],:,!^F,o,O,e
setlocal cinoptions+=j1,J1
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<'
let b:undo_indent = 'setlocal indentexpr< smartindent< autoindent< indentkeys< cinoptions<'
" Regex of syntax group names that are or delimit string or are comments.
let b:syng_strcom = get(b:,'syng_strcom','string\|comment\|regex\|special\|doc\|template\%(braces\)\@!')
let b:syng_str = get(b:,'syng_str','string\|template\|special')
" template strings may want to be excluded when editing graphql:
" au! Filetype javascript let b:syng_str = '^\%(.*template\)\@!.*string\|special'
" au! Filetype javascript let b:syng_strcom = '^\%(.*template\)\@!.*string\|comment\|regex\|special\|doc'
" Only define the function once.
if exists('*GetJavascriptIndent')
@ -33,165 +47,343 @@ if exists('*shiftwidth')
endfunction
else
function s:sw()
return &sw
return &l:shiftwidth ? &l:shiftwidth : &l:tabstop
endfunction
endif
let s:case_stmt = '\<\%(case\>\s*[^ \t:].*\|default\s*\):\C'
" Performance for forwards search(): start search at pos rather than masking
" matches before pos.
let s:z = has('patch-7.4.984') ? 'z' : ''
" Regex of syntax group names that are or delimit string or are comments.
let s:syng_strcom = 'string\|comment\|regex\|special\|doc\|template'
let s:syng_com = 'comment\|doc'
" Expression used to check whether we should skip a match with searchpair().
let s:skip_expr = "synIDattr(synID(line('.'),col('.'),0),'name') =~? '".s:syng_strcom."'"
function s:skip_func(lnum)
if !s:free || search('`\|\*\/','nW',a:lnum)
let s:free = !eval(s:skip_expr . " . '\\|html'")
let s:looksyn = s:free ? line('.') : s:looksyn
return !s:free
endif
let s:looksyn = line('.')
return (search('\/','nbW',s:looksyn) || search('[''"\\]','nW',s:looksyn)) && eval(s:skip_expr . " . '\\|html'")
endfunction
let s:skip_expr = "s:SynAt(line('.'),col('.')) =~? b:syng_strcom"
" searchpair() wrapper
if has('reltime')
function s:GetPair(start,end,flags,skip,time,...)
return searchpair(a:start,'',a:end,a:flags,a:skip,max([prevnonblank(v:lnum) - 2000,0] + a:000),a:time)
return searchpair('\m'.(a:start == '[' ? '\[' : a:start),'','\m'.a:end,
\ a:flags,a:skip,max([prevnonblank(v:lnum) - 2000,0] + a:000),a:time)
endfunction
else
function s:GetPair(start,end,flags,skip,...)
return searchpair(a:start,'',a:end,a:flags,a:skip,max([prevnonblank(v:lnum) - 1000,get(a:000,1)]))
return searchpair('\m'.(a:start == '[' ? '\[' : a:start),'','\m'.a:end,
\ a:flags,a:skip,max([prevnonblank(v:lnum) - 1000,0,get(a:000,1)]))
endfunction
endif
function s:current_char()
return getline('.')[col('.')-1]
function s:SynAt(l,c)
let byte = line2byte(a:l) + a:c - 1
let pos = index(s:synid_cache[0], byte)
if pos == -1
let s:synid_cache[:] += [[byte], [synIDattr(synID(a:l, a:c, 0), 'name')]]
endif
return s:synid_cache[1][pos]
endfunction
function s:token()
return s:current_char() =~ '\k' ? expand('<cword>') : s:current_char()
function s:ParseCino(f)
let [cin, divider, n] = [strridx(&cino,a:f), 0, '']
if cin == -1
return
endif
let [sign, cstr] = &cino[cin+1] == '-' ? [-1, &cino[cin+2:]] : [1, &cino[cin+1:]]
for c in split(cstr,'\zs')
if c == '.' && !divider
let divider = 1
elseif c ==# 's'
if n is ''
let n = s:sw()
else
let n = str2nr(n) * s:sw()
endif
break
elseif c =~ '\d'
let [n, divider] .= [c, 0]
else
break
endif
endfor
return sign * str2nr(n) / max([str2nr(divider),1])
endfunction
" NOTE: moves the cursor
function s:previous_token()
return search('\<\|[][`^!"%-/:-?{-~]','bW') ? s:token() : ''
" Optimized {skip} expr, only callable from the search loop which
" GetJavascriptIndent does to find the containing [[{(] (relies on s:vars)
function s:SkipFunc()
if s:top_col == 1
throw 'out of bounds'
endif
let s:top_col = 0
if s:check_in
if eval(s:skip_expr)
return 1
endif
let s:check_in = 0
elseif getline('.') =~ '\%<'.col('.').'c\/.\{-}\/\|\%>'.col('.').'c[''"]\|\\$'
if eval(s:skip_expr)
let s:looksyn = line('.')
return 1
endif
elseif search('\m`\|\${\|\*\/','nW'.s:z,s:looksyn) && eval(s:skip_expr)
let s:check_in = 1
return 1
endif
let [s:looksyn, s:top_col] = getpos('.')[1:2]
endfunction
function s:Trim(ln)
let pline = substitute(getline(a:ln),'\s*$','','')
let l:max = max([strridx(pline,'//'),strridx(pline,'/*'),0])
while l:max && synIDattr(synID(a:ln, strlen(pline), 0), 'name') =~? 'comment\|doc'
let pline = substitute(strpart(pline, 0, l:max),'\s*$','','')
let l:max = max([strridx(pline,'//'),strridx(pline,'/*'),0])
function s:AlternatePair()
let [pat, l:for] = ['[][(){};]', 2]
while s:SearchLoop('\m'.pat,'bW',s:script_tag,'s:SkipFunc()')
if s:LookingAt() == ';'
if !l:for
if s:GetPair('{','}','bW','s:SkipFunc()',2000,s:script_tag)
return
endif
break
else
let [pat, l:for] = ['[{}();]', l:for - 1]
endif
else
let idx = stridx('])}',s:LookingAt())
if idx == -1
return
elseif !s:GetPair('[({'[idx],'])}'[idx],'bW','s:SkipFunc()',2000,s:script_tag)
break
endif
endif
endwhile
return pline
throw 'out of bounds'
endfunction
" configurable regexes that define continuation lines, not including (, {, or [.
let s:opfirst = '^' . get(g:,'javascript_opfirst',
\ '\%([<>,?^%|*/&]\|\([-.:+]\)\1\@!\|=>\@!\|in\%(stanceof\)\=\>\)')
let s:continuation = get(g:,'javascript_continuation',
\ '\%([<=,.?/*^%|&:]\|+\@<!+\|-\@<!-\|=\@<!>\|\<in\%(stanceof\)\=\)') . '$'
function s:OneScope(lnum,text)
if cursor(a:lnum, match(' ' . a:text, ')$')) + 1 &&
\ s:GetPair('(', ')', 'bW', s:skip_expr, 100) > 0
let token = s:previous_token()
if index(split('await each'),token) + 1
return s:previous_token() ==# 'for'
function s:Nat(int)
return a:int * (a:int > 0)
endfunction
function s:LookingAt()
return getline('.')[col('.')-1]
endfunction
function s:Token()
return s:LookingAt() =~ '\k' ? expand('<cword>') : s:LookingAt()
endfunction
function s:PreviousToken()
let l:pos = getpos('.')
if search('\m\k\{1,}\|\S','ebW')
if (strpart(getline('.'),col('.')-2,2) == '*/' || line('.') != l:pos[1] &&
\ getline('.')[:col('.')-1] =~ '\/\/') && s:SynAt(line('.'),col('.')) =~? s:syng_com
if s:SearchLoop('\m\S\ze\_s*\/[/*]','bW',"s:SynAt(line('.'),col('.')) =~? s:syng_com")
return s:Token()
endif
call setpos('.',l:pos)
else
return s:Token()
endif
return index(split('for if let while with'),token) + 1
endif
return cursor(a:lnum, match(' ' . a:text, '\%(\<else\|\<do\|=>\)$\C')) + 1
return ''
endfunction
function s:Pure(f,...)
let l:pos = getpos('.')
let ret = call(a:f,a:000)
call setpos('.',l:pos)
return ret
endfunction
function s:SearchLoop(...)
let l:pos = getpos('.')
while call('search',a:000[:-2]) " search flags [^nc]
if !eval(a:000[-1])
return line('.')
endif
endwhile
call setpos('.',l:pos)
endfunction
function s:iscontOne(i,num,cont)
let [l:i, l:cont, l:num] = [a:i, a:cont, a:num + !a:num]
let pind = a:num ? indent(l:num) + s:W : 0
let ind = indent(l:i) + (a:cont ? 0 : s:W)
let bL = 0
while l:i >= l:num && (!l:cont || ind > pind)
if indent(l:i) < ind " first line always true for !a:cont, false for !!a:cont
if s:OneScope(l:i,s:Trim(l:i))
let bL += s:W
let [l:cont, l:i] = [0, line('.')]
elseif !l:cont
function s:ExprCol()
if getline('.')[col('.')-2] == ':'
return 1
endif
let [bal, l:pos] = [0, getpos('.')]
while s:SearchLoop('\m[{}?:]','bW',s:script_tag,s:skip_expr)
if s:LookingAt() == ':'
let bal -= strpart(getline('.'),col('.')-2,3) !~ '::'
elseif s:LookingAt() == '?'
let bal += 1
if bal == 1
break
endif
elseif !a:cont
elseif s:LookingAt() == '{'
let bal = !s:IsBlock()
break
elseif !s:GetPair('{','}','bW',s:skip_expr,200)
break
endif
let ind = min([ind, indent(l:i)])
let l:i = s:PrevCodeLine(l:i - 1)
endwhile
return bL
call setpos('.',l:pos)
return s:Nat(bal)
endfunction
" https://github.com/sweet-js/sweet.js/wiki/design#give-lookbehind-to-the-reader
function s:IsBlock(...)
let l:ln = get(a:000,0,line('.'))
let char = s:previous_token()
let syn = char =~ '[{>/]' || l:ln != line('.') ? synIDattr(synID(line('.'),col('.')-(char == '{'),0),'name') : ''
if char is ''
return 1
elseif syn =~? 'xml\|jsx'
return char != '{'
elseif syn =~? 'comment'
return search('\/[/*]','bW') && s:IsBlock(l:ln)
elseif char == '>'
return getline('.')[col('.')-2] == '=' || syn =~? '^jsflow'
elseif char == ':'
return cursor(0,match(' ' . strpart(getline('.'),0,col('.')),'.*\zs' . s:case_stmt . '$')) + 1 &&
\ (expand('<cword>') !=# 'default' || s:previous_token() !~ '[,{]')
" configurable regexes that define continuation lines, not including (, {, or [.
let s:opfirst = '^' . get(g:,'javascript_opfirst',
\ '\C\%([<>=,.?^%|/&]\|\([-:+]\)\1\@!\|\*\+\|!=\|in\%(stanceof\)\=\>\)')
let s:continuation = get(g:,'javascript_continuation',
\ '\C\%([<=,.~!?/*^%|&:]\|+\@<!+\|-\@<!-\|=\@<!>\|\<\%(typeof\|new\|delete\|void\|in\|instanceof\|await\)\)') . '$'
function s:Continues(ln,con)
let tok = matchstr(a:con[-15:],s:continuation)
if tok =~ '[a-z:]'
call cursor(a:ln, len(a:con))
return tok == ':' ? s:ExprCol() : s:PreviousToken() != '.'
elseif tok !~ '[/>]'
return tok isnot ''
endif
return index(split('return const let import export yield default delete var void typeof throw new in instanceof'
\ . ' - = ~ ! < * + , / ? ^ % | & ( ['), char) < (0 + (line('.') != l:ln))
return s:SynAt(a:ln, len(a:con)) !~? (tok == '>' ? 'jsflow\|^html' : 'regex')
endfunction
" Find line above 'lnum' that isn't empty, in a comment, or in a string.
function s:Trim(ln)
let divi = split(getline(a:ln),'\s\+$\|\S\zs\ze\s*\/[/*]')
while len(divi) > 1 && s:SynAt(a:ln, len(join(divi,''))) =~? s:syng_com
call remove(divi,-1)
endwhile
return join(divi,'')
endfunction
" Find line above 'lnum' that isn't empty or in a comment
function s:PrevCodeLine(lnum)
let l:lnum = prevnonblank(a:lnum)
while l:lnum
let syn = synIDattr(synID(l:lnum,matchend(getline(l:lnum), '^\s*[^''"`]'),0),'name')
if syn =~? 'html'
return
elseif syn !~? s:syng_strcom
return l:lnum
let [l:multi, l:n, l:pos] = [0, prevnonblank(a:lnum), getpos('.')]
while l:n
if getline(l:n) =~ '^\s*\/[/*]' && (getline(l:n) !~ '`' &&
\ getline(l:n-1)[-1:] != '\' || s:SynAt(l:n,1) !~? b:syng_str)
let l:n = prevnonblank(l:n-1)
continue
elseif l:multi || getline(l:n) =~ '\*\/'
call cursor(l:n,1)
if search('\m\/\*\|\(\*\/\)','bWp') == 1 && s:SynAt(l:n,1) =~? s:syng_com
let [l:multi, l:n] = [1, line('.')]
continue
endif
endif
let l:lnum = prevnonblank(l:lnum - 1)
break
endwhile
call setpos('.',l:pos)
return l:n
endfunction
" Check if line 'lnum' has a balanced amount of parentheses.
function s:Balanced(lnum)
let l:open = 0
let l:line = getline(a:lnum)
let pos = match(l:line, '[][(){}]', 0)
let [l:open, l:line] = [0, getline(a:lnum)]
let pos = match(l:line, '[][(){}]')
while pos != -1
if synIDattr(synID(a:lnum,pos + 1,0),'name') !~? s:syng_strcom
if s:SynAt(a:lnum,pos + 1) !~? b:syng_strcom
let l:open += match(' ' . l:line[pos],'[[({]')
if l:open < 0
return
endif
endif
let pos = match(l:line, '[][(){}]', pos + 1)
let pos = match(l:line, l:open ?
\ matchstr(['[][]','[()]','[{}]'],l:line[pos]) :
\ '[][(){}]', pos + 1)
endwhile
return !l:open
endfunction
function s:OneScope(lnum)
call cursor(a:lnum, len(s:Trim(a:lnum)))
if s:LookingAt() == ')' && s:GetPair('(', ')', 'bW', s:skip_expr, 100)
let tok = s:PreviousToken()
return (tok =~# '^\%(for\|if\|let\|while\|with\)$' ||
\ tok =~# '^await$\|^each$' && s:PreviousToken() ==# 'for') &&
\ s:Pure('s:PreviousToken') != '.' && !(tok == 'while' && s:DoWhile())
elseif s:Token() =~# '^else$\|^do$'
return s:Pure('s:PreviousToken') != '.'
endif
return strpart(getline('.'),col('.')-2,2) == '=>'
endfunction
function s:DoWhile()
let cpos = searchpos('\m\<','cbW')
if s:SearchLoop('\m\C[{}]\|\<\%(do\|while\)\>','bW',s:skip_expr)
if s:{s:LookingAt() == '}' && s:GetPair('{','}','bW',s:skip_expr,200) ?
\ 'Previous' : ''}Token() ==# 'do' && s:IsBlock()
return 1
endif
call call('cursor',cpos)
endif
endfunction
" returns braceless levels started by 'i' and above lines * &sw. 'num' is the
" lineNr which encloses the entire context, 'cont' if whether line 'i' + 1 is
" a continued expression, which could have started in a braceless context
function s:IsContOne(i,num,cont)
let [l:i, l:num, b_l] = [a:i, a:num + !a:num, 0]
let pind = a:num ? indent(a:num) + s:sw() : 0
let ind = indent(a:i) + (a:cont ? 0 : s:sw())
while l:i > l:num && ind > pind || l:i == l:num
if indent(l:i) < ind && s:OneScope(l:i)
let b_l += 1
let l:i = line('.')
elseif !a:cont || b_l || ind < indent(a:i)
break
endif
let ind = min([ind, indent(l:i)])
let l:i = s:PrevCodeLine(l:i - 1)
endwhile
return b_l
endfunction
function s:IsSwitch()
return s:PreviousToken() !~ '[.*]' &&
\ (!s:GetPair('{','}','cbW',s:skip_expr,100) || s:IsBlock() &&
\ (s:Token() !~ '^\K\k*$' || expand('<cword>') !=# 'class' &&
\ s:PreviousToken() !~# '^class$\|^extends$' || s:PreviousToken() == '.'))
endfunction
" https://github.com/sweet-js/sweet.js/wiki/design#give-lookbehind-to-the-reader
function s:IsBlock()
let l:n = line('.')
let tok = s:PreviousToken()
if match(s:stack,'\cxml\|jsx') != -1 && s:SynAt(line('.'),col('.')-1) =~? 'xml\|jsx'
return tok != '{'
elseif tok =~ '\k'
if tok ==# 'type'
return s:Pure('eval',"s:PreviousToken() !~# '^\\%(im\\|ex\\)port$' || s:PreviousToken() == '.'")
endif
return index(split('return const let import export extends yield default delete var await void typeof throw case new of in instanceof')
\ ,tok) < (line('.') != l:n) || s:Pure('s:PreviousToken') == '.'
elseif tok == '>'
return getline('.')[col('.')-2] == '=' || s:SynAt(line('.'),col('.')) =~? 'jsflow\|^html'
elseif tok == '*'
return s:Pure('s:PreviousToken') == ':'
elseif tok == ':'
return !s:ExprCol()
elseif tok == '/'
return s:SynAt(line('.'),col('.')) =~? 'regex'
elseif tok !~ '[=~!<,.?^%|&([]'
return tok !~ '[-+]' || l:n != line('.') && getline('.')[col('.')-2] == tok
endif
endfunction
function GetJavascriptIndent()
let b:js_cache = get(b:,'js_cache',[0,0,0])
" Get the current line.
let l:line = getline(v:lnum)
let syns = synIDattr(synID(v:lnum, 1, 0), 'name')
let [b:js_cache, s:synid_cache, l:line, s:stack] = [
\ get(b:,'js_cache',[0,0,0]),
\ [[],[]],
\ getline(v:lnum),
\ map(synstack(v:lnum,1),"synIDattr(v:val,'name')"),
\ ]
" use synstack as it validates syn state and works in an empty line
let syns = get(s:stack,-1,'')
" start with strings,comments,etc.
if syns =~? 'comment\|doc'
if syns =~? s:syng_com
if l:line =~ '^\s*\*'
return cindent(v:lnum)
elseif l:line !~ '^\s*\/'
elseif l:line !~ '^\s*\/[/*]'
return -1
endif
elseif syns =~? 'string\|template' && l:line !~ '^[''"]'
elseif syns =~? b:syng_str
if b:js_cache[0] == v:lnum - 1 && s:Balanced(v:lnum-1)
let b:js_cache[0] = v:lnum
endif
return -1
endif
let l:lnum = s:PrevCodeLine(v:lnum - 1)
@ -199,63 +391,97 @@ function GetJavascriptIndent()
return
endif
let l:line = substitute(substitute(l:line,'^\s*\%(\/\*.\{-}\*\/\s*\)*','',''),'^\/[/*].*','','')
" the containing paren, bracket, curly. Many hacks for performance
call cursor(v:lnum,1)
let idx = strlen(l:line) ? stridx('])}',l:line[0]) : -1
if indent(l:lnum)
let [s:looksyn,s:free] = [v:lnum - 1,1]
if b:js_cache[0] >= l:lnum && b:js_cache[0] < v:lnum &&
\ (b:js_cache[0] > l:lnum || s:Balanced(l:lnum))
call call('cursor',b:js_cache[1:])
elseif idx + 1
call s:GetPair(['\[','(','{'][idx], '])}'[idx],'bW','s:skip_func(s:looksyn)',2000)
elseif indent(v:lnum) && syns =~? 'block'
call s:GetPair('{','}','bW','s:skip_func(s:looksyn)',2000)
else
call s:GetPair('[({[]','[])}]','bW','s:skip_func(s:looksyn)',2000)
endif
else
call s:GetPair('[({[]','[])}]','bW',s:skip_expr,200,l:lnum)
let l:line = substitute(l:line,'^\s*','','')
let l:line_raw = l:line
if l:line[:1] == '/*'
let l:line = substitute(l:line,'^\%(\/\*.\{-}\*\/\s*\)*','','')
endif
if l:line =~ '^\/[/*]'
let l:line = ''
endif
if idx + 1
if idx == 2 && search('\S','bW',line('.')) && s:current_char() == ')'
call s:GetPair('(',')','bW',s:skip_expr,200)
endif
return indent(line('.'))
" the containing paren, bracket, or curly. Many hacks for performance
let [ s:script_tag, idx ] = [ get(get(b:,'hi_indent',{}),'blocklnr'),
\ index([']',')','}'],l:line[0]) ]
if b:js_cache[0] > l:lnum && b:js_cache[0] < v:lnum ||
\ b:js_cache[0] == l:lnum && s:Balanced(l:lnum)
call call('cursor',b:js_cache[2] ? b:js_cache[1:] : [v:lnum,1])
else
call cursor(v:lnum,1)
let [s:looksyn, s:check_in, s:top_col] = [v:lnum - 1, 0, 0]
try
if idx != -1
call s:GetPair('[({'[idx],'])}'[idx],'bW','s:SkipFunc()',2000,s:script_tag)
elseif getline(v:lnum) !~ '^\S' && syns =~? 'block'
call s:GetPair('{','}','bW','s:SkipFunc()',2000,s:script_tag)
else
call s:AlternatePair()
endif
catch
call cursor(v:lnum,1)
endtry
endif
let b:js_cache = [v:lnum] + (line('.') == v:lnum ? [0,0] : [line('.'),col('.')])
let b:js_cache = [v:lnum] + (line('.') == v:lnum ? [s:script_tag,0] : getpos('.')[1:2])
let num = b:js_cache[1]
let [s:W, pline, isOp, stmt, bL, switch_offset] = [s:sw(), s:Trim(l:lnum),0,0,0,0]
if num && s:current_char() == '{' && s:IsBlock()
let stmt = 1
if s:current_char() == ')' && s:GetPair('(', ')', 'bW', s:skip_expr, 100) > 0 && s:previous_token() ==# 'switch'
let switch_offset = &cino !~ ':' || !has('float') ? s:W :
\ float2nr(str2float(matchstr(&cino,'.*:\zs[-0-9.]*')) * (&cino =~# '\%(.*:\)\@>[^,]*s' ? s:W : 1))
if l:line =~# '^' . s:case_stmt
return indent(num) + switch_offset
let [num_ind, is_op, b_l, l:switch_offset] = [s:Nat(indent(num)),0,0,0]
if !b:js_cache[2] || s:LookingAt() == '{' && s:IsBlock()
let [ilnum, pline] = [line('.'), s:Trim(l:lnum)]
if b:js_cache[2] && s:LookingAt() == ')' && s:GetPair('(',')','bW',s:skip_expr,100)
if ilnum == num
let [num, num_ind] = [line('.'), indent('.')]
endif
if idx == -1 && s:PreviousToken() ==# 'switch' && s:IsSwitch()
let l:switch_offset = &cino !~ ':' ? s:sw() : s:ParseCino(':')
if pline[-1:] != '.' && l:line =~# '^\%(default\|case\)\>'
return s:Nat(num_ind + l:switch_offset)
elseif &cino =~ '='
let l:case_offset = s:ParseCino('=')
endif
endif
let stmt = pline !~# s:case_stmt . '$'
endif
endif
if stmt || !num
let isOp = l:line =~# s:opfirst || pline =~# s:continuation
let bL = s:iscontOne(l:lnum,num,isOp)
let bL -= (bL && l:line[0] == '{') * s:W
if idx == -1 && pline[-1:] !~ '[{;]'
let sol = matchstr(l:line,s:opfirst)
if sol =~# '^\%(in\%(stanceof\)\=\|\*\)$'
call cursor(l:lnum, len(pline))
if pline[-1:] == '}' && s:GetPair('{','}','bW',s:skip_expr,200) && s:IsBlock()
return num_ind + s:sw()
endif
let is_op = s:sw()
elseif sol isnot '' || s:Continues(l:lnum,pline)
let is_op = s:sw()
endif
let b_l = s:Nat(s:IsContOne(l:lnum,b:js_cache[1],is_op) -
\ (!is_op && l:line =~ '^{')) * s:sw()
endif
elseif idx == -1 && getline(b:js_cache[1])[b:js_cache[2]-1] == '(' && &cino =~ '(' &&
\ (search('\m\S','nbW',num) || s:ParseCino('U'))
let pval = s:ParseCino('(')
if !pval
let [Wval, vcol] = [s:ParseCino('W'), virtcol('.')]
if search('\m\S','W',num)
return s:ParseCino('w') ? vcol : virtcol('.')-1
endif
return Wval ? s:Nat(num_ind + Wval) : vcol
endif
return s:Nat(num_ind + pval + s:GetPair('(',')','nbrmW',s:skip_expr,100,num) * s:sw())
endif
" main return
if isOp
return (num ? indent(num) : -s:W) + (s:W * 2) + switch_offset + bL
if l:line =~ '^[])}]\|^|}'
if l:line_raw[0] == ')' && getline(b:js_cache[1])[b:js_cache[2]-1] == '('
if s:ParseCino('M')
return indent(l:lnum)
elseif &cino =~# 'm' && !s:ParseCino('m')
return virtcol('.') - 1
endif
endif
return num_ind
elseif num
return indent(num) + s:W + switch_offset + bL
return s:Nat(num_ind + get(l:,'case_offset',s:sw()) + l:switch_offset + b_l + is_op)
endif
return bL
return b_l + is_op
endfunction
let &cpo = s:cpo_save

@ -24,53 +24,55 @@ syntax sync fromstart
" syntax case ignore
syntax case match
syntax match jsNoise /[:,\;\.]\{1}/
syntax match jsNoise /[:,\;]\{1}/
syntax match jsNoise /[\.]\{1}/ skipwhite skipempty nextgroup=jsObjectProp,jsFuncCall,jsPrototype,jsTaggedTemplate
syntax match jsObjectProp contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>/
syntax match jsFuncCall /\k\+\%(\s*(\)\@=/
syntax match jsParensError /[)}\]]/
" Program Keywords
syntax keyword jsStorageClass const var let skipwhite skipempty nextgroup=jsDestructuringBlock,jsDestructuringArray,jsVariableDef
syntax match jsVariableDef contained /\k\+/ nextgroup=jsFlowDefinition
syntax keyword jsOperator delete instanceof typeof void new in of
syntax match jsOperator /[\!\|\&\+\-\<\>\=\%\/\*\~\^]\{1}/
syntax match jsVariableDef contained /\k\+/ skipwhite skipempty nextgroup=jsFlowDefinition
syntax keyword jsOperator delete instanceof typeof void new in of skipwhite skipempty nextgroup=@jsExpression
syntax match jsOperator /[\!\|\&\+\-\<\>\=\%\/\*\~\^]\{1}/ skipwhite skipempty nextgroup=@jsExpression
syntax match jsOperator /::/ skipwhite skipempty nextgroup=@jsExpression
syntax keyword jsBooleanTrue true
syntax keyword jsBooleanFalse false
" Modules
syntax keyword jsModuleKeywords contained import
syntax keyword jsModuleKeywords contained export skipwhite skipempty nextgroup=jsExportBlock,jsModuleDefault
syntax keyword jsModuleOperators contained from
syntax keyword jsModuleOperators contained as
syntax region jsModuleGroup contained matchgroup=jsModuleBraces start=/{/ end=/}/ contains=jsModuleOperators,jsNoise,jsComment
syntax match jsModuleAsterisk contained /*/
syntax keyword jsModuleDefault contained default skipwhite skipempty nextgroup=@jsExpression
syntax region jsImportContainer start=/\<import\> / end="\%(;\|$\)" contains=jsModuleKeywords,jsModuleOperators,jsComment,jsString,jsTemplateString,jsNoise,jsModuleGroup,jsModuleAsterisk
syntax region jsExportContainer start=/\<export\> / end="\%(;\|$\)" contains=jsModuleKeywords,jsModuleOperators,jsStorageClass,jsModuleDefault,@jsExpression
syntax region jsExportBlock contained matchgroup=jsExportBraces start=/{/ end=/}/ contains=jsModuleOperators,jsNoise,jsComment
syntax keyword jsImport import skipwhite skipempty nextgroup=jsModuleAsterisk,jsModuleKeyword,jsModuleGroup,jsFlowImportType
syntax keyword jsExport export skipwhite skipempty nextgroup=@jsAll,jsModuleGroup,jsExportDefault,jsModuleAsterisk,jsModuleKeyword,jsFlowTypeStatement
syntax match jsModuleKeyword contained /\k\+/ skipwhite skipempty nextgroup=jsModuleAs,jsFrom,jsModuleComma
syntax keyword jsExportDefault contained default skipwhite skipempty nextgroup=@jsExpression
syntax keyword jsExportDefaultGroup contained default skipwhite skipempty nextgroup=jsModuleAs,jsFrom,jsModuleComma
syntax match jsModuleAsterisk contained /\*/ skipwhite skipempty nextgroup=jsModuleKeyword,jsModuleAs,jsFrom
syntax keyword jsModuleAs contained as skipwhite skipempty nextgroup=jsModuleKeyword,jsExportDefaultGroup
syntax keyword jsFrom contained from skipwhite skipempty nextgroup=jsString
syntax match jsModuleComma contained /,/ skipwhite skipempty nextgroup=jsModuleKeyword,jsModuleAsterisk,jsModuleGroup,jsFlowTypeKeyword
" Strings, Templates, Numbers
syntax region jsString start=+"+ skip=+\\\("\|$\)+ end=+"\|$+ contains=jsSpecial,@Spell extend
syntax region jsString start=+'+ skip=+\\\('\|$\)+ end=+'\|$+ contains=jsSpecial,@Spell extend
syntax region jsTemplateString start=+`+ skip=+\\\(`\|$\)+ end=+`+ contains=jsTemplateVar,jsSpecial extend
syntax region jsTemplateString start=+`+ skip=+\\\(`\|$\)+ end=+`+ contains=jsTemplateExpression,jsSpecial,@Spell extend
syntax match jsTaggedTemplate /\k\+\%(`\)\@=/ nextgroup=jsTemplateString
syntax match jsNumber /\<\d\+\%([eE][+-]\=\d\+\)\=\>\|\<0[bB][01]\+\>\|\<0[oO]\o\+\>\|\<0[xX]\x\+\>/
syntax keyword jsNumber Infinity
syntax match jsFloat /\<\%(\d\+\.\d\+\|\d\+\.\|\.\d\+\)\%([eE][+-]\=\d\+\)\=\>/
" Regular Expressions
syntax match jsSpecial contained "\v\\%(0|\\x\x\{2\}\|\\u\x\{4\}\|\c[A-Z]|.)"
syntax region jsTemplateVar contained matchgroup=jsTemplateBraces start=+${+ end=+}+ contains=@jsExpression
syntax region jsRegexpCharClass contained start=+\[+ skip=+\\.+ end=+\]+
syntax match jsRegexpBoundary contained "\v%(\<@![\^$]|\\[bB])"
syntax match jsRegexpBackRef contained "\v\\[1-9][0-9]*"
syntax match jsRegexpQuantifier contained "\v\\@<!%([?*+]|\{\d+%(,|,\d+)?})\??"
syntax match jsRegexpOr contained "\v\<@!\|"
syntax match jsRegexpMod contained "\v\(@<=\?[:=!>]"
syntax region jsRegexpGroup contained start="\\\@<!(" skip="\\.\|\[\(\\.\|[^]]\)*\]" end="\\\@<!)" contains=jsRegexpCharClass,@jsRegexpSpecial keepend
syntax match jsSpecial contained "\v\\%(0|\\x\x\{2\}\|\\u\x\{4\}\|\c[A-Z]|.)"
syntax region jsTemplateExpression contained matchgroup=jsTemplateBraces start=+${+ end=+}+ contains=@jsExpression keepend
syntax region jsRegexpCharClass contained start=+\[+ skip=+\\.+ end=+\]+
syntax match jsRegexpBoundary contained "\v%(\<@![\^$]|\\[bB])"
syntax match jsRegexpBackRef contained "\v\\[1-9][0-9]*"
syntax match jsRegexpQuantifier contained "\v\\@<!%([?*+]|\{\d+%(,|,\d+)?})\??"
syntax match jsRegexpOr contained "\v\<@!\|"
syntax match jsRegexpMod contained "\v\(@<=\?[:=!>]"
syntax region jsRegexpGroup contained start="\\\@<!(" skip="\\.\|\[\(\\.\|[^]]\)*\]" end="\\\@<!)" contains=jsRegexpCharClass,@jsRegexpSpecial keepend
if v:version > 703 || v:version == 603 && has("patch1088")
syntax region jsRegexpString start=+\%(\%(\%(return\|case\)\s\+\)\@50<=\|\%(\%([)\]"']\|\d\|\w\)\s*\)\@50<!\)/\(\*\|/\)\@!+ skip=+\\.\|\[\%(\\.\|[^]]\)*\]+ end=+/[gimy]\{,4}+ contains=jsRegexpCharClass,jsRegexpGroup,@jsRegexpSpecial oneline keepend extend
syntax region jsRegexpString start=+\%(\%(\%(return\|case\)\s\+\)\@50<=\|\%(\%([)\]"']\|\d\|\w\)\s*\)\@50<!\)/\(\*\|/\)\@!+ skip=+\\.\|\[\%(\\.\|[^]]\)*\]+ end=+/[gimyu]\{,5}+ contains=jsRegexpCharClass,jsRegexpGroup,@jsRegexpSpecial oneline keepend extend
else
syntax region jsRegexpString start=+\%(\%(\%(return\|case\)\s\+\)\@<=\|\%(\%([)\]"']\|\d\|\w\)\s*\)\@<!\)/\(\*\|/\)\@!+ skip=+\\.\|\[\%(\\.\|[^]]\)*\]+ end=+/[gimy]\{,4}+ contains=jsRegexpCharClass,jsRegexpGroup,@jsRegexpSpecial oneline keepend extend
syntax region jsRegexpString start=+\%(\%(\%(return\|case\)\s\+\)\@<=\|\%(\%([)\]"']\|\d\|\w\)\s*\)\@<!\)/\(\*\|/\)\@!+ skip=+\\.\|\[\%(\\.\|[^]]\)*\]+ end=+/[gimyu]\{,5}+ contains=jsRegexpCharClass,jsRegexpGroup,@jsRegexpSpecial oneline keepend extend
endif
syntax cluster jsRegexpSpecial contains=jsSpecial,jsRegexpBoundary,jsRegexpBackRef,jsRegexpQuantifier,jsRegexpOr,jsRegexpMod
@ -81,15 +83,15 @@ syntax region jsObjectKeyString contained start=+"+ skip=+\\\("\|$\)+ end=+
syntax region jsObjectKeyString contained start=+'+ skip=+\\\('\|$\)+ end=+'\|$+ contains=jsSpecial,@Spell skipwhite skipempty nextgroup=jsObjectValue
syntax region jsObjectKeyComputed contained matchgroup=jsBrackets start=/\[/ end=/]/ contains=@jsExpression skipwhite skipempty nextgroup=jsObjectValue,jsFuncArgs extend
syntax match jsObjectSeparator contained /,/
syntax region jsObjectValue contained start=/:/ end=/\%(,\|}\)\@=/ contains=jsObjectColon,@jsExpression extend
syntax region jsObjectValue contained matchgroup=jsNoise start=/:/ end=/\%(,\|}\)\@=/ contains=@jsExpression extend
syntax match jsObjectFuncName contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>[\r\n\t ]*(\@=/ skipwhite skipempty nextgroup=jsFuncArgs
syntax match jsFunctionKey contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>\(\s*:\s*function\s*\)\@=/
syntax match jsObjectMethodType contained /\%(get\|set\|static\|async\)\%( \k\+\)\@=/ skipwhite skipempty nextgroup=jsObjectFuncName
syntax match jsObjectMethodType contained /\%(get\|set\)\%( \k\+\)\@=/ skipwhite skipempty nextgroup=jsObjectFuncName
syntax region jsObjectStringKey contained start=+"+ skip=+\\\("\|$\)+ end=+"\|$+ contains=jsSpecial,@Spell extend skipwhite skipempty nextgroup=jsFuncArgs,jsObjectValue
syntax region jsObjectStringKey contained start=+'+ skip=+\\\('\|$\)+ end=+'\|$+ contains=jsSpecial,@Spell extend skipwhite skipempty nextgroup=jsFuncArgs,jsObjectValue
exe 'syntax keyword jsNull null '.(exists('g:javascript_conceal_null') ? 'conceal cchar='.g:javascript_conceal_null : '')
exe 'syntax keyword jsReturn return contained '.(exists('g:javascript_conceal_return') ? 'conceal cchar='.g:javascript_conceal_return : '')
exe 'syntax keyword jsReturn return contained '.(exists('g:javascript_conceal_return') ? 'conceal cchar='.g:javascript_conceal_return : '').' skipwhite skipempty nextgroup=@jsExpression'
exe 'syntax keyword jsUndefined undefined '.(exists('g:javascript_conceal_undefined') ? 'conceal cchar='.g:javascript_conceal_undefined : '')
exe 'syntax keyword jsNan NaN '.(exists('g:javascript_conceal_NaN') ? 'conceal cchar='.g:javascript_conceal_NaN : '')
exe 'syntax keyword jsPrototype prototype '.(exists('g:javascript_conceal_prototype') ? 'conceal cchar='.g:javascript_conceal_prototype : '')
@ -97,24 +99,27 @@ exe 'syntax keyword jsThis this '.(exists('g:javascript_conceal
exe 'syntax keyword jsSuper super contained '.(exists('g:javascript_conceal_super') ? 'conceal cchar='.g:javascript_conceal_super : '')
" Statement Keywords
syntax keyword jsStatement contained break continue with yield debugger
syntax keyword jsConditional if skipwhite skipempty nextgroup=jsParenIfElse
syntax keyword jsConditional else skipwhite skipempty nextgroup=jsCommentMisc,jsIfElseBlock
syntax keyword jsConditional switch skipwhite skipempty nextgroup=jsParenSwitch
syntax keyword jsRepeat while for skipwhite skipempty nextgroup=jsParenRepeat,jsForAwait
syntax keyword jsDo do skipwhite skipempty nextgroup=jsRepeatBlock
syntax keyword jsLabel contained case default
syntax keyword jsTry try skipwhite skipempty nextgroup=jsTryCatchBlock
syntax keyword jsFinally contained finally skipwhite skipempty nextgroup=jsFinallyBlock
syntax keyword jsCatch contained catch skipwhite skipempty nextgroup=jsParenCatch
syntax match jsBlockLabel /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>\s*::\@!/ contains=jsNoise skipwhite skipempty nextgroup=jsBlock
syntax match jsBlockLabelKey contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>\%(\s*\%(;\|\n\)\)\@=/
syntax keyword jsStatement contained with yield debugger
syntax keyword jsStatement contained break continue skipwhite skipempty nextgroup=jsBlockLabelKey
syntax keyword jsConditional if skipwhite skipempty nextgroup=jsParenIfElse
syntax keyword jsConditional else skipwhite skipempty nextgroup=jsCommentIfElse,jsIfElseBlock
syntax keyword jsConditional switch skipwhite skipempty nextgroup=jsParenSwitch
syntax keyword jsRepeat while for skipwhite skipempty nextgroup=jsParenRepeat,jsForAwait
syntax keyword jsDo do skipwhite skipempty nextgroup=jsRepeatBlock
syntax region jsSwitchCase contained matchgroup=jsLabel start=/\<\%(case\|default\)\>/ end=/:\@=/ contains=@jsExpression,jsLabel skipwhite skipempty nextgroup=jsSwitchColon keepend
syntax keyword jsTry try skipwhite skipempty nextgroup=jsTryCatchBlock
syntax keyword jsFinally contained finally skipwhite skipempty nextgroup=jsFinallyBlock
syntax keyword jsCatch contained catch skipwhite skipempty nextgroup=jsParenCatch
syntax keyword jsException throw
syntax keyword jsAsyncKeyword async await
syntax match jsSwitchColon contained /:/ skipwhite skipempty nextgroup=jsSwitchBlock
syntax match jsSwitchColon contained /::\@!/ skipwhite skipempty nextgroup=jsSwitchBlock
" Keywords
syntax keyword jsGlobalObjects Array Boolean Date Function Iterator Number Object Symbol Map WeakMap Set RegExp String Proxy Promise Buffer ParallelArray ArrayBuffer DataView Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray JSON Math console document window Intl Collator DateTimeFormat NumberFormat fetch
syntax keyword jsGlobalNodeObjects module exports global process
syntax match jsGlobalNodeObjects /require/ containedin=jsFuncCall
syntax keyword jsGlobalNodeObjects module exports global process __dirname __filename
syntax match jsGlobalNodeObjects /\<require\>/ containedin=jsFuncCall
syntax keyword jsExceptions Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError
syntax keyword jsBuiltins decodeURI decodeURIComponent encodeURI encodeURIComponent eval isFinite isNaN parseFloat parseInt uneval
" DISCUSS: How imporant is this, really? Perhaps it should be linked to an error because I assume the keywords are reserved?
@ -135,29 +140,29 @@ syntax keyword jsDomNodeConsts ELEMENT_NODE ATTRIBUTE_NODE TEXT_NODE CDATA_SECT
syntax keyword jsHtmlEvents onblur onclick oncontextmenu ondblclick onfocus onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup onresize
" Code blocks
syntax region jsBracket matchgroup=jsBrackets start=/\[/ end=/\]/ contains=@jsExpression extend fold
syntax region jsParen matchgroup=jsParens start=/(/ end=/)/ contains=@jsAll extend fold
syntax region jsParenDecorator contained matchgroup=jsParensDecorator start=/(/ end=/)/ contains=@jsAll skipwhite skipempty nextgroup=jsCommentMisc extend fold
syntax region jsParenIfElse contained matchgroup=jsParensIfElse start=/(/ end=/)/ contains=@jsAll skipwhite skipempty nextgroup=jsCommentMisc,jsIfElseBlock extend fold
syntax region jsParenRepeat contained matchgroup=jsParensRepeat start=/(/ end=/)/ contains=@jsAll skipwhite skipempty nextgroup=jsCommentMisc,jsRepeatBlock extend fold
syntax region jsBracket matchgroup=jsBrackets start=/\[/ end=/\]/ contains=@jsExpression,jsSpreadExpression extend fold
syntax region jsParen matchgroup=jsParens start=/(/ end=/)/ contains=@jsExpression extend fold nextgroup=jsFlowDefinition
syntax region jsParenDecorator contained matchgroup=jsParensDecorator start=/(/ end=/)/ contains=@jsAll extend fold
syntax region jsParenIfElse contained matchgroup=jsParensIfElse start=/(/ end=/)/ contains=@jsAll skipwhite skipempty nextgroup=jsCommentIfElse,jsIfElseBlock extend fold
syntax region jsParenRepeat contained matchgroup=jsParensRepeat start=/(/ end=/)/ contains=@jsAll skipwhite skipempty nextgroup=jsCommentRepeat,jsRepeatBlock extend fold
syntax region jsParenSwitch contained matchgroup=jsParensSwitch start=/(/ end=/)/ contains=@jsAll skipwhite skipempty nextgroup=jsSwitchBlock extend fold
syntax region jsParenCatch contained matchgroup=jsParensCatch start=/(/ end=/)/ skipwhite skipempty nextgroup=jsTryCatchBlock extend fold
syntax region jsFuncArgs contained matchgroup=jsFuncParens start=/(/ end=/)/ contains=jsFuncArgCommas,jsComment,jsFuncArgExpression,jsDestructuringBlock,jsRestExpression,jsFlowArgumentDef skipwhite skipempty nextgroup=jsCommentFunction,jsFuncBlock,jsFlowReturn extend fold
syntax region jsClassBlock contained matchgroup=jsClassBraces start=/{/ end=/}/ contains=jsClassFuncName,jsClassMethodType,jsArrowFunction,jsArrowFuncArgs,jsComment,jsGenerator,jsDecorator,jsClassProperty,jsClassPropertyComputed,jsClassStringKey,jsNoise extend fold
syntax region jsFuncBlock contained matchgroup=jsFuncBraces start=/{/ end=/}/ contains=@jsAll extend fold
syntax region jsIfElseBlock contained matchgroup=jsIfElseBraces start=/{/ end=/}/ contains=@jsAll extend fold
syntax region jsBlock contained matchgroup=jsBraces start=/{/ end=/}/ contains=@jsAll extend fold
syntax region jsTryCatchBlock contained matchgroup=jsTryCatchBraces start=/{/ end=/}/ contains=@jsAll skipwhite skipempty nextgroup=jsCatch,jsFinally extend fold
syntax region jsFinallyBlock contained matchgroup=jsFinallyBraces start=/{/ end=/}/ contains=@jsAll extend fold
syntax region jsSwitchBlock contained matchgroup=jsSwitchBraces start=/{/ end=/}/ contains=@jsAll,jsLabel,jsSwitchColon extend fold
syntax region jsRepeatBlock contained matchgroup=jsRepeatBraces start=/{/ end=/}/ contains=@jsAll extend fold
syntax region jsDestructuringBlock contained matchgroup=jsDestructuringBraces start=/{/ end=/}/ contains=jsDestructuringProperty,jsDestructuringAssignment,jsDestructuringNoise,jsDestructuringPropertyComputed,jsSpreadExpression extend fold
syntax region jsDestructuringArray contained matchgroup=jsDestructuringBraces start=/\[/ end=/\]/ contains=jsDestructuringPropertyValue,jsNoise,jsDestructuringProperty,jsSpreadExpression extend fold
syntax region jsObject matchgroup=jsObjectBraces start=/{/ end=/}/ contains=jsObjectKey,jsObjectKeyString,jsObjectKeyComputed,jsObjectSeparator,jsObjectFuncName,jsObjectMethodType,jsGenerator,jsComment,jsObjectStringKey,jsSpreadExpression,jsDecorator extend fold
syntax region jsTernaryIf matchgroup=jsTernaryIfOperator start=/?/ end=/\%(:\|[\}]\@=\)/ contains=@jsExpression
syntax region jsFuncArgs contained matchgroup=jsFuncParens start=/(/ end=/)/ contains=jsFuncArgCommas,jsComment,jsFuncArgExpression,jsDestructuringBlock,jsDestructuringArray,jsRestExpression,jsFlowArgumentDef skipwhite skipempty nextgroup=jsCommentFunction,jsFuncBlock,jsFlowReturn extend fold
syntax region jsClassBlock contained matchgroup=jsClassBraces start=/{/ end=/}/ contains=jsClassFuncName,jsClassMethodType,jsArrowFunction,jsArrowFuncArgs,jsComment,jsGenerator,jsDecorator,jsClassProperty,jsClassPropertyComputed,jsClassStringKey,jsAsyncKeyword,jsNoise extend fold
syntax region jsFuncBlock contained matchgroup=jsFuncBraces start=/{/ end=/}/ contains=@jsAll,jsBlock extend fold
syntax region jsIfElseBlock contained matchgroup=jsIfElseBraces start=/{/ end=/}/ contains=@jsAll,jsBlock extend fold
syntax region jsTryCatchBlock contained matchgroup=jsTryCatchBraces start=/{/ end=/}/ contains=@jsAll,jsBlock skipwhite skipempty nextgroup=jsCatch,jsFinally extend fold
syntax region jsFinallyBlock contained matchgroup=jsFinallyBraces start=/{/ end=/}/ contains=@jsAll,jsBlock extend fold
syntax region jsSwitchBlock contained matchgroup=jsSwitchBraces start=/{/ end=/}/ contains=@jsAll,jsBlock,jsSwitchCase extend fold
syntax region jsRepeatBlock contained matchgroup=jsRepeatBraces start=/{/ end=/}/ contains=@jsAll,jsBlock extend fold
syntax region jsDestructuringBlock contained matchgroup=jsDestructuringBraces start=/{/ end=/}/ contains=jsDestructuringProperty,jsDestructuringAssignment,jsDestructuringNoise,jsDestructuringPropertyComputed,jsSpreadExpression,jsComment extend fold
syntax region jsDestructuringArray contained matchgroup=jsDestructuringBraces start=/\[/ end=/\]/ contains=jsDestructuringPropertyValue,jsNoise,jsDestructuringProperty,jsSpreadExpression,jsComment extend fold
syntax region jsObject contained matchgroup=jsObjectBraces start=/{/ end=/}/ contains=jsObjectKey,jsObjectKeyString,jsObjectKeyComputed,jsObjectSeparator,jsObjectFuncName,jsObjectMethodType,jsGenerator,jsComment,jsObjectStringKey,jsSpreadExpression,jsDecorator,jsAsyncKeyword extend fold
syntax region jsBlock matchgroup=jsBraces start=/{/ end=/}/ contains=@jsAll,jsSpreadExpression extend fold
syntax region jsModuleGroup contained matchgroup=jsModuleBraces start=/{/ end=/}/ contains=jsModuleKeyword,jsModuleComma,jsModuleAs,jsComment,jsFlowTypeKeyword skipwhite skipempty nextgroup=jsFrom fold
syntax region jsSpreadExpression contained matchgroup=jsSpreadOperator start=/\.\.\./ end=/[,}\]]\@=/ contains=@jsExpression
syntax region jsRestExpression contained matchgroup=jsRestOperator start=/\.\.\./ end=/[,)]\@=/
syntax region jsTernaryIf matchgroup=jsTernaryIfOperator start=/?/ end=/\%(:\|[\}]\@=\)/ contains=@jsExpression
syntax region jsTernaryIf matchgroup=jsTernaryIfOperator start=/?/ end=/\%(:\|[\}]\@=\)/ contains=@jsExpression extend skipwhite skipempty nextgroup=@jsExpression
syntax match jsGenerator contained /\*/ skipwhite skipempty nextgroup=jsFuncName,jsFuncArgs
syntax match jsFuncName contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>/ skipwhite skipempty nextgroup=jsFuncArgs,jsFlowFunctionGroup
@ -173,13 +178,16 @@ syntax match jsArrowFuncArgs /([^()]*)\s*\(=>\)\@=/ contains=jsFuncArgs skipe
exe 'syntax match jsFunction /\<function\>/ skipwhite skipempty nextgroup=jsGenerator,jsFuncName,jsFuncArgs skipwhite '.(exists('g:javascript_conceal_function') ? 'conceal cchar='.g:javascript_conceal_function : '')
exe 'syntax match jsArrowFunction /=>/ skipwhite skipempty nextgroup=jsFuncBlock,jsCommentFunction '.(exists('g:javascript_conceal_arrow_function') ? 'conceal cchar='.g:javascript_conceal_arrow_function : '')
exe 'syntax match jsArrowFunction /()\s*\(=>\)\@=/ skipwhite skipempty nextgroup=jsArrowFunction '.(exists('g:javascript_conceal_noarg_arrow_function') ? 'conceal cchar='.g:javascript_conceal_noarg_arrow_function : '').(' contains=jsArrowFuncArgs')
exe 'syntax match jsArrowFunction /_\s*\(=>\)\@=/ skipwhite skipempty nextgroup=jsArrowFunction '.(exists('g:javascript_conceal_underscore_arrow_function') ? 'conceal cchar='.g:javascript_conceal_underscore_arrow_function : '')
" Classes
syntax keyword jsClassKeywords contained extends class
syntax keyword jsClassKeyword contained class
syntax keyword jsExtendsKeyword contained extends skipwhite skipempty nextgroup=@jsExpression
syntax match jsClassNoise contained /\./
syntax match jsClassMethodType contained /\%(get\|set\|static\|async\)\%( \k\+\)\@=/ skipwhite skipempty nextgroup=jsFuncName,jsClassProperty
syntax match jsClassDefinition /\<class\>\%( [a-zA-Z_$][0-9a-zA-Z_$ \n.]*\)*/ contains=jsClassKeywords,jsClassNoise skipwhite skipempty nextgroup=jsCommentClass,jsClassBlock,jsFlowClassGroup
syntax match jsClassProperty contained /\<[0-9a-zA-Z_$]*\>\(\s*=\)\@=/ skipwhite skipempty nextgroup=jsClassValue
syntax match jsClassMethodType contained /\%(get\|set\|static\)\%( \k\+\)\@=/ skipwhite skipempty nextgroup=jsAsyncKeyword,jsFuncName,jsClassProperty
syntax region jsClassDefinition start=/\<class\>/ end=/\(\<extends\>\s\+\)\@<!{\@=/ contains=jsClassKeyword,jsExtendsKeyword,jsClassNoise,@jsExpression,jsFlowClassGroup skipwhite skipempty nextgroup=jsCommentClass,jsClassBlock,jsFlowClassGroup
syntax match jsClassProperty contained /\<[0-9a-zA-Z_$]*\>\(\s*[=:]\)\@=/ skipwhite skipempty nextgroup=jsClassValue,jsFlowClassDef
syntax region jsClassValue contained start=/=/ end=/\%(;\|}\|\n\)\@=/ contains=@jsExpression
syntax region jsClassPropertyComputed contained matchgroup=jsBrackets start=/\[/ end=/]/ contains=@jsExpression skipwhite skipempty nextgroup=jsFuncArgs,jsClassValue extend
syntax match jsClassFuncName contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>\%(\s*(\)\@=/ skipwhite skipempty nextgroup=jsFuncArgs
@ -208,8 +216,10 @@ syntax region jsCommentFunction contained start=/\/\// end=/$/ contains=j
syntax region jsCommentFunction contained start=/\/\*/ end=/\*\// contains=jsCommentTodo,@Spell skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturn fold extend keepend
syntax region jsCommentClass contained start=/\/\// end=/$/ contains=jsCommentTodo,@Spell skipwhite skipempty nextgroup=jsClassBlock,jsFlowClassGroup extend keepend
syntax region jsCommentClass contained start=/\/\*/ end=/\*\// contains=jsCommentTodo,@Spell skipwhite skipempty nextgroup=jsClassBlock,jsFlowClassGroup fold extend keepend
syntax region jsCommentMisc contained start=/\/\// end=/$/ contains=jsCommentTodo,@Spell skipwhite skipempty nextgroup=jsBlock extend keepend
syntax region jsCommentMisc contained start=/\/\*/ end=/\*\// contains=jsCommentTodo,@Spell skipwhite skipempty nextgroup=jsBlock fold extend keepend
syntax region jsCommentIfElse contained start=/\/\// end=/$/ contains=jsCommentTodo,@Spell skipwhite skipempty nextgroup=jsIfElseBlock extend keepend
syntax region jsCommentIfElse contained start=/\/\*/ end=/\*\// contains=jsCommentTodo,@Spell skipwhite skipempty nextgroup=jsIfElseBlock fold extend keepend
syntax region jsCommentRepeat contained start=/\/\// end=/$/ contains=jsCommentTodo,@Spell skipwhite skipempty nextgroup=jsRepeatBlock extend keepend
syntax region jsCommentRepeat contained start=/\/\*/ end=/\*\// contains=jsCommentTodo,@Spell skipwhite skipempty nextgroup=jsRepeatBlock fold extend keepend
" Decorators
syntax match jsDecorator /^\s*@/ nextgroup=jsDecoratorFunction
@ -227,8 +237,8 @@ if exists("javascript_plugin_flow")
runtime extras/flow.vim
endif
syntax cluster jsExpression contains=jsBracket,jsParen,jsObject,jsBlock,jsTernaryIf,jsTaggedTemplate,jsTemplateString,jsString,jsRegexpString,jsNumber,jsFloat,jsOperator,jsBooleanTrue,jsBooleanFalse,jsNull,jsFunction,jsArrowFunction,jsGlobalObjects,jsExceptions,jsFutureKeys,jsDomErrNo,jsDomNodeConsts,jsHtmlEvents,jsFuncCall,jsUndefined,jsNan,jsPrototype,jsBuiltins,jsNoise,jsClassDefinition,jsArrowFunction,jsArrowFuncArgs,jsParensError,jsComment,jsArguments,jsThis,jsSuper,jsDo
syntax cluster jsAll contains=@jsExpression,jsExportContainer,jsImportContainer,jsStorageClass,jsConditional,jsRepeat,jsReturn,jsStatement,jsException,jsTry,jsAsyncKeyword
syntax cluster jsExpression contains=jsBracket,jsParen,jsObject,jsTernaryIf,jsTaggedTemplate,jsTemplateString,jsString,jsRegexpString,jsNumber,jsFloat,jsOperator,jsBooleanTrue,jsBooleanFalse,jsNull,jsFunction,jsArrowFunction,jsGlobalObjects,jsExceptions,jsFutureKeys,jsDomErrNo,jsDomNodeConsts,jsHtmlEvents,jsFuncCall,jsUndefined,jsNan,jsPrototype,jsBuiltins,jsNoise,jsClassDefinition,jsArrowFunction,jsArrowFuncArgs,jsParensError,jsComment,jsArguments,jsThis,jsSuper,jsDo,jsForAwait,jsAsyncKeyword
syntax cluster jsAll contains=@jsExpression,jsStorageClass,jsConditional,jsRepeat,jsReturn,jsStatement,jsException,jsTry,jsNoise,jsBlockLabel
" Define the default highlighting.
" For version 5.7 and earlier: only when not done already
@ -290,7 +300,8 @@ if version >= 508 || !exists("did_javascript_syn_inits")
HiLink jsOperator Operator
HiLink jsOf Operator
HiLink jsStorageClass StorageClass
HiLink jsClassKeywords Keyword
HiLink jsClassKeyword Keyword
HiLink jsExtendsKeyword Keyword
HiLink jsThis Special
HiLink jsSuper Constant
HiLink jsNan Number
@ -309,30 +320,32 @@ if version >= 508 || !exists("did_javascript_syn_inits")
HiLink jsFuncParens Noise
HiLink jsClassBraces Noise
HiLink jsClassNoise Noise
HiLink jsIfElseBraces jsBraces
HiLink jsTryCatchBraces jsBraces
HiLink jsModuleBraces jsBraces
HiLink jsIfElseBraces Noise
HiLink jsTryCatchBraces Noise
HiLink jsModuleBraces Noise
HiLink jsObjectBraces Noise
HiLink jsObjectSeparator Noise
HiLink jsFinallyBraces jsBraces
HiLink jsRepeatBraces jsBraces
HiLink jsSwitchBraces jsBraces
HiLink jsExportBraces jsBraces
HiLink jsFinallyBraces Noise
HiLink jsRepeatBraces Noise
HiLink jsSwitchBraces Noise
HiLink jsSpecial Special
HiLink jsTemplateVar Special
HiLink jsTemplateBraces jsBraces
HiLink jsTemplateBraces Noise
HiLink jsGlobalObjects Constant
HiLink jsGlobalNodeObjects Constant
HiLink jsExceptions Constant
HiLink jsBuiltins Constant
HiLink jsModuleKeywords Include
HiLink jsModuleOperators Include
HiLink jsModuleDefault Include
HiLink jsImport Include
HiLink jsExport Include
HiLink jsExportDefault StorageClass
HiLink jsExportDefaultGroup jsExportDefault
HiLink jsModuleAs Include
HiLink jsModuleComma jsNoise
HiLink jsModuleAsterisk Noise
HiLink jsFrom Include
HiLink jsDecorator Special
HiLink jsDecoratorFunction Function
HiLink jsParensDecorator jsParens
HiLink jsFuncArgOperator jsFuncArgs
HiLink jsModuleAsterisk Noise
HiLink jsClassProperty jsObjectKey
HiLink jsSpreadOperator Operator
HiLink jsRestOperator Operator
@ -341,6 +354,8 @@ if version >= 508 || !exists("did_javascript_syn_inits")
HiLink jsClassMethodType Type
HiLink jsObjectMethodType Type
HiLink jsClassDefinition jsFuncName
HiLink jsBlockLabel Identifier
HiLink jsBlockLabelKey jsBlockLabel
HiLink jsDestructuringBraces Noise
HiLink jsDestructuringProperty jsFuncArgs
@ -349,7 +364,8 @@ if version >= 508 || !exists("did_javascript_syn_inits")
HiLink jsCommentFunction jsComment
HiLink jsCommentClass jsComment
HiLink jsCommentMisc jsComment
HiLink jsCommentIfElse jsComment
HiLink jsCommentRepeat jsComment
HiLink jsDomErrNo Constant
HiLink jsDomNodeConsts Constant
@ -366,7 +382,7 @@ if version >= 508 || !exists("did_javascript_syn_inits")
endif
" Define the htmlJavaScript for HTML syntax html.vim
syntax cluster htmlJavaScript contains=@jsAll
syntax cluster htmlJavaScript contains=@jsAll,jsImport,jsExport
syntax cluster javaScriptExpression contains=@jsAll
" Vim's default html.vim highlights all javascript as 'Special'

Loading…
Cancel
Save