Squashed 'vim/bundle/javascript/' changes from 3093f26be..e9a59c877

e9a59c877 hotfix: Improve switch
3abb9aeb1 Merge pull request #696 from pangloss/develop
419f0d6a8 accurate collection (#699)
b0f562956 de-noising
d47868cad remove magic try
74f6d46f7 remove es6 semi-less do-while handling (#698)
8ac7badb3 Remove all extra grouping (#697)
bedb8cb2e cleaning
6f3e6e974 keep string type
8a40889ba skip any html
15905f208 refactor,cleaning isblock
eac13000f another return
d23050e30 return redundancies
817215be5 more code cleaning
2ef9a9ca3 refactoring block conditions (#695)
01f780426 keyword atom
7835f3dc6 Refactoring (#693)
396829c38 comment handling
4d6021610 prevline = 0 at html
b5a21109b code minify
12a6f46c4 alpha short circuiting
65e68f563 revert char check
01193be9e date, str char
cdb44a869 last index string
918202964 clearer char checking
1e52ed9bc remove var
dcf820b2a adjust precedence of comment/jsx
f8fc08c8d small comment fix
187b1d6a0 recursion in isBlock: comment skip (#692)
afb03f5eb cleaning,skip_func
8996ec593 date, cleaning
579997a82 isBlock cleaning
67b9f3d60 Merge pull request #691 from mixedCase/develop
b4517ac35 Add fetch keyword to list of globals
2d33a9e11 code cleaning
bf2a1b42f last case statement
460598f32 fix 'default' property identifier (#689)
4456229dd non whitespace non : after case statement
997c2b12f Merge pull request #679 from pangloss/develop
23bb9c3e1 last cleaning
88b068088 cleaning
672c379b1 Update javascript.vim
2676ca045 Prevent giant loop, refactor
4b435ebb4 small fix
ead360d5a refactor
3b9a45627 check for case statement in switch (#682)
b3edf7f9e cleaner cursor call
c746dbc7f reltime search
5d8153eec string match
dc34b2461 small fixes (#678)
da8ac5b8e remove pattern match
b0237b039 other small touches (#677)
53f843b64 shorten s:var names
4ee476b45 init (#676)
69f2c87dc small minification and perf (#675)
e643047f4 simplify trimline (#673)
920873e91 simplify balance func (#672)
c51624124 more variables
e4452cf87 remove identical
371a71aae template pline
d55813b14 ws start, again
3d59c74c7 date, first char whitespace
8df58fec2 cleaning
3a3cae8a6 do while made accurate (#671)
31b2fff3e cleaning
1811b3e92 various little updates (#670)
baa07dd0d refactor isblock for jsx (#668)
d736e9533 Merge pull request #653 from pangloss/develop
7d30463e1 Revert "Merge branch 'master' into develop"
7e9aeb30f word boundary to start/end
822dfe5f9 Merge branch 'master' into develop
da65c0cdd massive expression to if chain (#667)
25e98656f Merge pull request #660 from tomxtobin/fix-jsdoc-optional-parameter-highlighting
06a3b8109 Merge pull request #654 from BenoitZugmeyer/develop
ba0ae275c remove random nl
214450913 shorten long line,date
67ebe06ed skip comment (#665)
8d904f65f improve end of line trim (#662)
ba2245fbe Misc improvements (#661)
292d90161 Fix JSDoc highlighting for optional parameters
f674cbab5 case label needs non whitespace- (#658)
f64dae710 for await indent (#656)
b0d7c153a add support for "for await" (asynchronous iteration)
ecc674fc5 flow generic classes (#652)
572b98d12 Fixing another funky comment situation
cd4ace412 wrap for magic (#651)
c76d65bd5 fail earlier
833d6ec12 short circuit cache check
6656f37bf small regex changes
88111be6a factor out
840f12917 more regex line endings
77c4ae620 better line cleaning (#649)
d6b2fd599 change regex case
6ecbda3b3 clean isBlock (#648)
92f1d98db switch accuracy and performance (#647)
dc678406d more optimization (#646)
02c8c644c remove rar
5453eb09d more string/comment cleaning
ce7c06c39 simplify comments
2202e5804 Merge pull request #645 from remiprev/fix/js-flow-type-custom-regex
fcdc1dcdb Fix jsFlowTypeCustom regex to allow dots
3bb395c39 normalize header in vim and current, date (#642)
d94ab71e2 optimize top scope indentation speed (#640)
a7225e4bd Fix jsGlobalNodeObjects and jsFuncCall priority
afbe2844e more minor optimizations (#638)
1219b150b small skip_func improvements (#637)
ff5f3f144 fix concat bug
3b38947f2 prev
5df8b344a more number conversion
b2ded1258 change num <= 0 to 0
aa37199ec change to searchpair helper
6426110f8 Update javascript.vim
48567e03b Update javascript.vim
ebd222b3d date,format
d3e952cf8 multi-braceless statements (#636)
854d431c0 Merge pull request #635 from pangloss/async-await
a59f5cb99 First pass at improved async/await support
a50df5fc7 Merge pull request #630 from pangloss/develop
d5dbecb6e Group link fixes
2bc46635a Merge pull request #631 from jfelchner/fix/syntax-highlighting-issues
5c4de0c43 slight changes to the skip_func (#632)
0cb2e1134 Change ClassKeywords to Keywords instead of Define
6c78b77ad Whitespace
801aad41b Change highlight link for decorators to 'Tag'
20bb09ae6 Fix decorator syntax highlighting
aa2fb9015 Add section comments
430b5284f Removed 'contained' constraint from 'this' keyword highlight
615f83754 Add more specialized groups for the various braces
355d6650d Add individual syntax groups for various parenthesis
4e2e37755 Add highlight group specifically for object colons
faf6f67ef remove indent copy
14198ab62 copy indent if in same scope only
0b6aad4c4 speed increase attempt (#629)
81e4e6f61 small script function changes (#628)
c15142cf3 allow bind op as line end continuation
5a5cdf03f remove 1 char
fce8e771e fix blocks after case statement
91314f3f3 fix objects after ternary ':'
b53274d98 more small improvements
81d85029a refactor adjustment and simplify
0ab4b1d18 small fix
89b5505ab Allow any comment or empty in adjustment
a7e64a92a don't let variable in block
e69cc1691 no adjustment in block statements
0134b36de little optimizations (#627)
39f09ee50 simplify assignment
4d7a4227e superfluous condition
46b6dd514 allow blank line in adjustment calc
d51ef6ab2 small change
2dd5dff8f cleaning
172aae659 cleaning
c36a91b78 fix
224fcee54 small changes
5f7e36a4a formatting,date
023e1d851 other fixes with cache
22d0e64ee more performance and bugfixes
058667839 far better version of last commit
bf74844aa fix cached blank line problem
7e6d96313 Merge pull request #621 from pangloss/adj
8711b66df remove variables from readme
2f5937e0c deprecate options
cc9bd56e8 Update javascript.vim
0a3bb5242 Update javascript.vim
c9f6fadbd performance refactor
174d94e6f produce cindent-like
f8a4a45f3 fixes for the bugfixes
0bba85764 bugfixes
d6616d5fd Update javascript.vim
6aba38457 adjustable indent (experimental)
941b38962 Merge pull request #619 from pangloss/jsx
51035b51a react property expressions
aa5586ce1 small bugfixes
f1bd983c6 allow nl in export default
af4374115 regex update
27ec99a6e Merge pull request #614 from pangloss/fix-export-default-indent
fd6c2b756 Fix export default style indents
2e3ab0a8b improve regex
cd0fc2822 comment fix
faf8bda63 containing braces which aren't blocks
782cc1078 Merge pull request #604 from pangloss/develop
5900fce5a last commit revert
6787729dc remove ugly function call
34a070cc3 minor style changes
951619284 case statements update
055ce0ca6 switch stuff
efab7db0b date
8eea63270 fix foreach method calls
0a955ee44 function removed,cleaning
d0a4aa401 more regex (#608)
67f2990a8 regex improvements (#607)
ba6dce3cb Rename function
f16fe69f0 Change function names
aadf36b73 cache can be invalid for he current line
cef306faf settings (#603)
3a20412d2 cleaning (#601)
28b5a8768 block statement (#596)
0cab45687 regex improvements
debb9bf72 Readme Updates (#599)
898a536e0 disambiguate vars
6f31d7213 fix regex
9703a61af cleaning, minor performance improvements
b59dfbc87 Update javascript.vim
a7e60bbe4 remove repeated syn checking
0a7432f3e remove transparent syntax check
29519c62a case sensitive
4a126ee6a negatives are truthy in vimscript
2a85b3c34 ind updates (#593)
5632438f0 simplify regex
fc43554f2 case-sensitivity
336d4351c more cleaning
6a3fac49a cleaning
b8762e8af remove buggy linehasopeningbracket trick
73c85a3f7 awful off-by-one bug
23b4639fc accuracy and speed increase for line_term regex
97e5fcab6 last commit extended to blocks
b65cd1447 update comments
27a37b4a7 for 585 (#586)
6de8f62f6 more regex
4278caa27 unicode identifiers
bd4c5270e limit regex lookbehind
58095d864 regex char classes
c003d8b97 join lines
86413728b Don't join strings in multiple lines
5ba6eab76 case-sensitivity (#583)
a328e8175 add label support (#582)
6706a2442 few remaining touches
60eaba7be Update javascript.vim
bc6422b5a had a problem with some of the changes
e8bb2bad7 remove line comment appended to code (#581)
5923f8092 comment on performance, angle brackets
ee3183e7f fix ftplugin var and clean indent (#580)
924a6456c misc fixes (#578)
8e3f58977 Merge pull request #544 from pangloss/develop
6d70fab41 fix c-style continuation (#576)
1d32e38b0 regex for word boundary
9e2c10e32 remove else
33833cc48 allow for line breaks before blocks (#575)
13610e67c Updating indent top comments
d17aee51b Flow tweaks
cbcfaaf09 adding more operators (#573)
2905f34d8 removing mode-line
acb4f0032 fix syn function
506783bc1 move lines from search pair function
57470573a remove obvious comment
f90b8c85e more cleaning
ad8d72ad4 cleaning indent
bf7d4b663 remove switch syn check (#571)
ab5d96bbb possible reuse of logic (simple lexing) (#570)
e895bd162 fix syn-indent issue
9a6c48548 minor refactor
b4038a26c addresses unindented code
6c440b3ec perf continued
96885ca80 small perf gain
0c3a3509e add jsfunccall to not indent args
f25397549 more cleaning
84e1cc1c0 cleaning
71c9fc825 negative and decimal switch label values (#569)
df6c7ef9c remove whitespace and regex mistake
31d8b39f2 switch enhanced (#568)
005928682 operators & continuation (#566)
c68ecbe99 removing custom formatting (#565)
178566475 Fixed another maybe case
c7dca1bd6 Merge pull request #564 from pangloss/even-more-flow-fixes
125337c11 More flow improvements
9677d923c Merge pull request #561 from dmitrivereshchagin/update-syntax
bd177f373 Merge pull request #562 from pangloss/flow-fixes
215e9572b Fix jsFlowClassDefinitions
c1d8d3766 Add jsFlowReturnMaybe
19b1d4fcc Remove unused g:javascript_conceal variable
3089ddda7 Merge remote-tracking branch 'origin/switch' into develop
f2b8aeb4c Update javascript.vim
995007aea Switch (#555)
35ac627aa Update javascript.vim
e6a4f2f2d Update ftplugin (#553)
023f02c8d Update javascript.vim
d745bd019 Merge pull request #556 from pangloss/flow-refactor
c2b7c0550 JS Flow refactor
6f82a0cec Re revert (#554)
2efcfa3ab Remove 'smartindent' from indent plugin (#551)
1c9a3dc4f undo_indent
b88468056 possible indent revert(dev branch) (#550)
aadffc04e Update javascript.vim
61aea7bcb Update javascript.vim
2792e6324 switch offset always calculated when inside switch
e41dbaacc for 194 (#548)
08c4fd784 Merge pull request #540 from dmitrivereshchagin/numeric-literals
68b8596d4 Merge pull request #547 from pangloss/nodejs-constants
25ff93778 Adding some common NodeJS globals
352bcc283 try ..catch (#546)
32e7c7871 indentation refactoring (#515)
a70cd8d51 Merge pull request #541 from dmitrivereshchagin/syntax-iskeyword
307295889 Merge pull request #543 from dmitrivereshchagin/update-ftplugin
653858c18 Make use of b:undo_indent variable (#542)
8cf97bdc7 Update filetype plugin
550e1e8e8 Make use of syntax specific iskeyword setting
ed40c9cb6 Tweak highlighting of numeric literals
2af5f55ff Merge pull request #533 from romgrk/patch-1
7982ec46f typo
4a6376aee Merge pull request #532 from pangloss/fix-oddly-placed-comments
ac813c03a Adding support for oddly placed comments
6acba740c Merge pull request #531 from jridgewell/patch-1
3b8017ef6 Remove jsOperator from jsClassBlock
d11bc09fb Merge pull request #530 from pangloss/do-expression-support
ac92e1b28 Adding do expression support
2f4838257 Merge pull request #526 from amadeus/link-jsclassdefinition
4133fcad0 Linking jsClassDefinition to jsFuncName
ad5d09edf Merge pull request #518 from pangloss/more-flow-fixes
5a699857e Adding bool to jsFlowType
583a4948d Including jsFlow in other contexts
4670d4fca Fix for jsFlowTypeValue
bfbc10d2f Fixed jsFlowTypeObjects not being closed
26c7330de Merge pull request #513 from pangloss/develop
dbfa5f067 Merge pull request #512 from pangloss/flow-updates
fdc96c469 More misc fixes for various flow things
bf53654d6 A fix for jsFlowReturn
3af93bd3d Merge pull request #511 from pangloss/fix-import-comments
ebda7fee0 Adding jsComment to import/export blocks
560b4fde6 Improvements for one line scope (#509)
29e1e0561 minor indentation cleaning (#508)
9206ec55b Merge pull request #507 from pangloss/misc-fixes
d6a969942 Added async to jsObjectMethodTypes
e8a6f93e5 Adding support for switch blocks
1586f7230 Added async to jsClassMethodDefinitions
c04d09988 Merge pull request #501 from pangloss/develop
f90113a1e Merge pull request #504 from pangloss/jscomment-tweaks
3306f6365 jsComment updates
7541e0208 Merge pull request #503 from pangloss/misc-fixes
5b4233850 Fixes for Flow on Classes
8a972d317 Whitespace
fb1c662cc Support destructuring values following assignment
57f5013bd Merge pull request #500 from pangloss/improved-exports
4eab47d67 First pass at improved export support
8deb69846 Merge pull request #470 from pangloss/js-flow-support
5cefcff31 Unpluralizing files and variable names
37bfc8ccf Plugin usage tweaks
af791ed19 Adding object key flow support
be5207068 Using runtime over syntax include
b6eccf90b Adding NGDoc support
752cee263 Moving jsdoc support into a separate file.
9d0bea561 Masking Flow support behind a global var
5f839a225 Removing jsFlow from jsAll cluster
926b7f935 Adding < and > to jsFlowNoise
ef37a147c Adds a ton of support for various parts of jsFlow
82fb8b974 Adding some basic Flow support
01150776b accurate switch indenting (#499)
420f98cc2 let a continuation be determined with block close (#496)
6bb633fb7 comment misalignment (#495)
0e0878577 Merge pull request #494 from pangloss/improve-destructuring
7d41c3c63 Improvements to Spread and Rest
9d816e398 Fixes to array destructuring
afe61796a Improved array destructuring
47951eec6 Refinements to destructuring
939f478f6 Improvements to destructuring
52e8f90e2 incorrect change in cursor pos (#489)
ea5803348 a solution for 486 (#488)
d70bb4e3f Merge pull request #480 from pangloss/develop
22c6f6d0d Merge pull request #485 from pangloss/fix-promise-catch
d3d09b9c5 First pass at fixing Promise catch methods.
b2baf85d6 Merge pull request #483 from pangloss/fix-object-strings
ecae87560 Fixing object string keys
233b6c32c paren matching (#474)
be5506443 Merge pull request #479 from pangloss/object-string-key-shorthand
51c16139c Adds support for string func names in objs classes
6b58cd0e0 Merge pull request #472 from pangloss/develop
9e5b60a4f Pulling version number out of README
8e710ba8e changes according to #466 (#463)
ceb3341b8 Make ternary handling more robust
e38617a51 Fix computed class properties
fc3874662 Potential fix for jsClassValue region
5a0ae7639 Misc tweaks
8aea86351 Debugger is no longer a future keys
e6182482b Unlinking jsFutureKeys
37cdc8ccc Improvements to jsClassValue endcase
42512308a Changing a TODO to a DISCUSS
8679129ee Renaming jsArray to jsBracket
648e924dd Add support for spread operator
a0155f59d First pass at fixing/supporting #425 & #393
c3a505bd8 First pass at fix for #433
79b73b3fe Whitespace
9550877e6 jsTaggedTemplate tweaks
99d658fec Code style tweaks
da492ea96 Improvements to import/exports syntax matching
533beaa3c Bug fixes and tweaks
c48323a21 Tons of syntax block granularity
a0d1abc17 More refactoring
6c2de108f Removing DOM CSS stuff
671e605cd Notes and general cleanup
ec96793e9 First attempted pass at jsObjectBlock
943d90b29 spread operator doesn't change indent (#462)
c9dc41ff5 working detection of object/array properties (#460)
06d8d160e Improve jsClassMethodDefinition matches
d00e8ddf6 get a correct indent for initial operator first
51bf45fe4 limiting for slow function and operator fix (#455)
12bbabac6 timeout the paren searching (#453)
120352b12 readability changes in the indent script (#450)
0f0e4a725 Merge pull request #442 from pangloss/develop
f39eb1fa7 Merge pull request #448 from dNItro/patch-1
5b143bd2a change the regex engine according to warning (#449)
fcec8b72d Shebang doesn't have to contain env
8c5695764 Merge pull request #445 from pangloss/bounceme-patch-1
b5de6ec2c Update javascript.vim
d54b138f9 a comma should be considered an operator
fe096c0ee another edge side effect (#443)
c5fba22a9 wrapping comments improved (#440)
c180b0c32 little bug affecting previous few commits
77387efb2 Update javascript.vim (#437)
27671558c Merge pull request #436 from amadeus/fix-class-definitions
bf34e60dc Forcing `class` text to be a keyword
2c7087871 random fixes and improvements (#435)
04e412b77 removing some clutter (#434)
3ebaef31a slight changes continuing from before
7c7add5fe my mistake
75fcd09e7 must actually return a number
fd98935f2 more fixes (#432)
dc117664c last actual column (#431)
206b85cfb literal indentation in a multiline string (#430)
a6e90baf0 minor changes (#429)
61b89844d specify template as a string
bf45f9caf Merge pull request #417 from amadeus/fix-lookbehind-limiting
7137e7eac Prevent limited lookbehinds in older vers of vim
b3ebfa5d9 c style opening curly braces (#426)
aa9a46ae9 for better switch handling (#424)
c9eda1f5c template fixes (#422)
8f16491ac indent following line ending in comma with arrow (#420)
10b6c649b Merge pull request #414 from amadeus/fix-lookbehinds
0fecb9295 Temporary fix for older versions of vim
8fb5fa8c6 parentheses regex is thankfully gone (#412)
617ccb50d Update javascript.vim
d2fa17618 multiline comment (#408)
304e2ac90 Merge pull request #409 from amadeus/fix-406
50c433e82 Fix Issue 406
e60e4ebf2 Merge pull request #404 from pangloss/misc.fixes
187594a91 Merge pull request #403 from amadeus/fix-261
b4e2faecd Update javascript.vim
c4ccee695 Custom jsFuncName for object definitions
e8657a8b7 Merge pull request #402 from amadeus/fix-401
dde16a056 Fix class definitions with no name
0e7983dd6 Merge pull request #400 from pangloss/switch
105a4aadf Switch mechanics, indent
d7f4728f8 Merge pull request #395 from pangloss/develop
4b6f9c5d9 Bumping version number to v1.0.0
09fde1910 Merge pull request #391 from amadeus/performance-improvements
c2bc4c701 Limiting jsRegexpString look behinds
842b0ceaa Improved performance of jsRegexpString
3a4991eaf Improved jsTaggedTemplate performance
508c1a337 Remove syntax sync clear
33eb9fe82 Optimized jsArrowFuncArgs selector
f7d220719 Optimized jsGlobalObjects
01ecaf9ab Removing deprecated selectors
a7f221678 Optimize JSNoise and JSOperator regexes
9ece5d53b Merge pull request #397 from amadeus/fix-jsdoc-records
1c75d8a3c Fix JSDoc record matching
d7a586975 Merge pull request #399 from pangloss/bounceme-patch-1
af08aae55 Merge pull request #398 from amadeus/last-minute-tweaks
a51d0f3c4 Update javascript.vim
48067d6dc Add code folding documentation
2f0b1d266 Removing deprecated folding logic
e74d75822 Refactored README.md
c438302c6 Merge pull request #392 from amadeus/fix-jsdocparam
f7cec8c79 Fixing bizarre jsDocParam bug
c5250b382 Merge pull request #396 from pangloss/bounceme-patch-1
af37b2253 [-+] not by another
3e1373184 Merge pull request #394 from amadeus/fix-341
1da09b622 Move jsDocTag @file to a different jsDocTag group
e9f6a4d4b Merge pull request #389 from bounceme/patch-15
a607a7d36 spanning multiple lines detection
48263c84e Merge pull request #388 from amadeus/lambda-experiments
b9feef086 Improved lambda argument handling
20b0eb6f4 Merge pull request #370 from bounceme/patch-6
5b7445e24 Merge pull request #390 from bounceme/patch-16
ff62d63ed #324
6cb0c96b6 old changes reset
d388b88c1 Merge pull request #373 from bounceme/patch-8
cc5a971cf Merge pull request #387 from amadeus/add-license
16673accd Adding a license note to the README
c4725ca4d Merge pull request #380 from amadeus/temporary-fix-for-arrow-func-args
992b76dc5 Temporarily disabled jsArrowFuncArgs with parens
dd95ac26a Merge pull request #385 from bounceme/patch-14
3208fc5d6 Operator first support,including ternary,dot etc.
2adca537e Merge pull request #384 from amadeus/fix-comments-in-class-declaration
7d371ddea Fixing comments in ES6 Class declarations
989deba7e Merge pull request #379 from bounceme/patch-11
17fa18cae simplifies the parentheses handling
c8ac1c874 Merge pull request #377 from amadeus/add-brackets-to-destructuring
f13009e40 Adding [ and ] to jsFuncArgDestructuring
734cdfc04 Improve one line scope
2881bbab3 Merge pull request #366 from amadeus/arrow-functions-in-class
f286f94dc Fix lambda definitions in class definitions
7f5c7b8de Merge pull request #367 from bounceme/patch-1
6858535ab Merge pull request #357 from bounceme/develop
293108695 line following arrow indentation
1833982f7 Merge pull request #361 from pangloss/develop
2d11ec04e Merge pull request #363 from amadeus/misc-fixes
113abc267 Fix jsBlock vs jsFuncBlock priority
36f34b25d Improved function declaration destructuring
d8c18d9d3 Fix Comment Regions
d87bcd106 Merge pull request #358 from amadeus/arrow-functions
6590bbcdf Fix Generator definitions
82473d0d6 Allow ... in arrow arguments definition
91f860b1b Linking jsArrowFuncArgs to jsFuncArgs
ae177c45e First pass at handling lamba arguments
c1ea11050 Adding jsFuncBlock support
22f9a0225 Merge pull request #360 from amadeus/update-spread-matching
73232334f Improvements to rest highlighting
1ec6674f6 Merge pull request #359 from amadeus/js-template-braces
a57c0a154 Higher specificity for jsTemplate braces
5fea23eee fast attempt for issues with multiple declarations
152f36e7c Merge pull request #354 from amadeus/es6-class-support
559c5f4a2 Merge pull request #337 from juneidysoo/develop
43784bc2a Added jsduck documentation types
995183bd1 ES6 Class Fixes
fd99d7778 Adding first pass at ES6 Class support
47b89fbf4 Merge pull request #293 from camsteffen/develop
62c15f602 Issue #294 better one line scope
55da36b58 Merge pull request #348 from zbinlin/sw
412bdd5d8 Merge pull request #309 from vekat/develop
dbacf7edb Merge pull request #313 from simono/feature/add-jsDomElemFuncs
f099955fb Merge pull request #342 from kevinfahy/bug-nested-template-strings
2b4d3a91f Merge pull request #352 from damionvega/buffer-to-global
bc74a6fff Added Buffer to jsGlobalObjects
32137f1f0 Use shfitwidth() instead of &sw in indent/javascript.vim
91fa38c65 Merge pull request #347 from artm/localize-m
68290c3e7 make the m variable script-local
63fdf235c Merge pull request #345 from whitneyit/feature/add-line-comment-support
f41da19fc Add jsLineComment to jsFuncArgs
c4fda0513 Merge pull request #344 from whitneyit/feature/support-comment-in-func-args
ee412e34c Add jsComment to jsFuncArgs
ca58cddde Fix nested template variable syntax highlighting
06326d595 Merge pull request #306 from Delapouite/arrow
cbe66636a Merge pull request #340 from WChargin/fix-jsAssignmentExpr
c024f95c0 Respect 'very-magic' in 'jsAssignmentExpr' regexp
70c621089 Merge pull request #339 from WChargin/arrow-functions
7b9e11ad8 Make arrow-functions one-liners
4c983baf2 Add common DOM Functions
de7a60c5c Add dollar sign to jsDocParam matches
49d46bf9e feat(conceal): add arrow_function option
1d8c2677d Merge branch 'develop'
255d5e6d6 Merge pull request #302 from unclechu/develop-prop-synonym
131c2d364 Added jsdoc synonym @prop for @property
924de0eb6 Merge pull request #292 from wbinnssmith/wbinnssmith/async-await-develop
e9ee38953 Add support for async and await keywords
3d91f8197 Merge pull request #250 from utix/develop
5cbbdd4e5 Case indent: use cinoptions : and = values
487e0c659 Manage case indent
c3787301c Merge pull request #281 from ccarpita/develop
dfc554e8a fix: import statement ending regex
c606532e3 Merge pull request #279 from jedverity/develop
bf0858a18 Adding support for ES7/ES2016 decorators
709fd619e Merge pull request #276 from ccarpita/fix-gh-272
062607d2c Merge pull request #275 from ccarpita/develop
9664e22ab Merge pull request #277 from ccarpita/fix-gh-247
a489b1706 fix GH-247: Single-line comments after import statement
325c0487f fix GH-272: Highlight arrow funcs without parenthesized params
139f6f6ae fix: export region should support es6 class and block openings
2f5a9ef64 Merge pull request #273 from gf3/import-noise-blocks
bcf4bfee6 Add jsNoise and jsBlock to jsImportContainer
bab4f3944 Merge pull request #269 from AlexanderSkafte/patch-1
9564d9076 Found a typo
70ec8e8a3 Merge pull request #268 from crusoexia/develop
89ce201ec fix issue #107, makes 'arguments' become global keyword
d48397093 Merge pull request #265 from lencioni/suffixesadd
02750cff1 Merge pull request #266 from lencioni/constlet
8bd60a331 Add `const` and `let` to indent file
152e2e58a Add `setlocal suffixesadd+=.js` to ftplugin
8a409f7fd Merge pull request #258 from pierreozoux/patch-1
b39a28f65 One liner for Pathogen
e628cba07 Merge pull request #252 from jvanbaarsen/patch-1
3afb1731a Vundle requires single quotes
e286463c1 Merge pull request #244 from pangloss/tagged-templates
6cad2d987 Fixes #242
e9709a9fb Update README.md
b5245213e Merge pull request #240 from pangloss/develop
f1efe180a Merge pull request #239 from pangloss/fix-js-class
368bad663 Adds jsClass to all expressions
27f16d5b4 Merge pull request #238 from dragn/develop
b022c816a issue#34
b579e3551 Merge pull request #237 from pangloss/tagged-template-fix
9c9be0f48 Merge pull request #236 from pangloss/fix/module-syntax
2180f51d0 Fixes tagged templates on multi lines
7848de5df Fixes module syntax for common js
e36841515 Merge pull request #234 from amadeus/indent-fix
5fa60043d A fix for #212
7ea00af3e Merge pull request #233 from pangloss/es6-modules-and-class
6d167f10e Adds support for default arguments
b3c811bc5 Adds of operator
2a037505f Adds Promise to globals
bed118969 Adds tagged templates
8dbf22456 Adds Map, WeakMap, and Set
687a90049 Adds Symbol to global
f4c1c9cf8 Fixes code whitespace issue
97ff4e35c Removes static and super from reserved words
fcf7a26b3 More rigid syntax checking
c76ae11fb Better module support
1769504fd Adds es6 modules support and change class
ca779b431 Merge pull request #232 from amadeus/fix-block-comment
1ee35c5d5 Alignment fixes and removal of deprecated comments
29c2875e6 Renamed and fixed block comments
10b0c75fd Merge pull request #231 from pangloss/develop
736ff8df2 Merge pull request #230 from amadeus/update-vundle-api
ead4c2ca3 Updated README to properly reflect Vundle's API
638d628d8 Merge pull request #213 from jedborovik/develop
20d260b32 Merge pull request #229 from JelteF/develop
75d908784 Disable custom gq for comments
2e9424d48 Merge pull request #227 from amadeus/fix-jsAssignmentExpr
54481c98e Added jsNoise matching to jsAssignmentExpr
f6b2cc1c0 Merge pull request #223 from davidchambers/exponential-notation
439f702bc Merge pull request #220 from crusoexia/develop
8ecccd62e Merge pull request #225 from ryanoasis/jsdoc-optional-param-highlight
8f0bc59dd modified jsDocParam to highlight jsdoc optional parameter and default value
063e7a0f6 number: match literals such as 1e-3
e84c352a5 add js assignment expression and relate identifier match syntax
7f6a736df Merge pull request #221 from buztard/generator-syntax
5d204c996 Add syntax support for ES6 generators
977e220b3 Merge pull request #217 from pangloss/develop
7f5c2d8f7 Merge pull request #216 from pangloss/feature/eol-terminated-strings
dc8b363b9 Simplify string skip pattern
86e376c62 Make strings EOL-terminated
56a4a237b Merge pull request #214 from davidchambers/regexp
9b8524865 regexp: prevent ")" inside character class from terminating group
057ed8049 Add @api annotation
51a337b77 Use a default &tw of 80 for formatting
18106a3db Use &tw instead of hard-coded 80 for formatting
125f931f1 Merge pull request #205 from JelteF/develop
0077e5782 Fix some gq bugs when tw was set
c92fbd243 Merge pull request #204 from qiao/closure-compiler-annotations
03bd5d28b Add Closure Compiler annotations
29caa7f70 Merge pull request #201 from JelteF/develop
ca201905d Fix gq to not split strings halfway through
f01cc1764 Merge pull request #200 from qstrahl/develop
1881c848a Add blurb about pull requests to CONTRIBUTING.md
9b094acf5 Merge pull request #187 from xtian/develop
d9baadd38 Allow customizing individual concealing characters
8704ea152 Add some ES6 keywords.
6b057a97e Merge pull request #168 from mrhooray/develop
f8122fd1c Merge pull request #176 from pangloss/develop
c832002d3 Merge pull request #174 from pangloss/add-contributing
7f6cdb6aa Adding a proper CONTRIBUTING file
a1165dca3 Merge pull request #167 from pangloss/develop
b17135bda Merge pull request #171 from pangloss/useless-whitespace
d6a4e2ef5 Fixing odd indentation levels in syntax file
6921496c3 Merge pull request #170 from pangloss/add-misc-contained
7126372eb Adding additional `contained`s
fbe4ca069 Merge pull request #169 from davidchambers/shorthand-character-classes
bbf61f287 limit scope in which jsSpecial may be matched
d2412a100 regexp: add jsSpecial to jsRegexpSpecial cluster
045cbaff2 support CommonJS syntax highlighting
7e64e51e6 Merge pull request #145 from pangloss/feature/rest-args
2507247f8 Merge branch 'pr/163' into develop
46fe678d3 Add basic support for ECMAScript 6 Template Strings
7bc85e499 Merge pull request #162 from davidchambers/spell-checking
cb0fa68ce string: spell-check string literals
2cfdae856 Merge branch 'pr/160' into develop
8fddc6f4f regexp: prevent unescaped "/" in character class from terminating regexp
dd7f97727 regexp: prevent escaped "]" from terminating character class
c08d3b7eb Merge branch 'pr/154' into develop
3f06dbba1 Add missed @tutorial tag
bad20eb0a Case agnostic JSDoc tags
a08e6cc33 Merge remote-tracking branch 'source/master' into develop
a957e1e34 Merge pull request #149 from iammerrick/develop
a6f71af54 remove redundant prototype declaration
d52f89954 feature(conceal): add prototype to the list of conceals
7e28dbd4e Merge pull request #146 from eddiemonge/patch-2
ef239d861 JSON is not JavaScript
53b508214 Merge pull request #144 from pangloss/feature/arrow-function
80407fd90 Merge pull request #136 from brutasse/patch-1
4b6c266d1 Fixes issue with spec where rest parameter should be last
52c22556f Adds es6 support for rest parameters in function signatures
3882ae3b4 Adds es6 support for arrow function syntax
ca3ee3801 Fix formatting of pathogen instructions
932b67541 Merge branch 'master' of github.com:pangloss/vim-javascript
2d732ba69 Merge branch 'release/0.9.0'
776b7bcff v0.9.0
17a557abb Merge pull request #133 from pangloss/feature/fix-ternary-noise
5cf445046 Fixing jsNoise to work within ternaries
f46a38073 Merge pull request #132 from pangloss/feature/funcblock-fix
83f3ed7fa Fixing jsFuncBlock when braces are on a new line
ae0ab5279 Merge pull request #131 from pangloss/hotfix/regex-note
764094a0d README note on regexes
e1c29c7fc Merge pull request #127 from pangloss/feature/add-jsfunctionkey
304815ab7 Better whitespace support for jsFunctionKey
71b9b5402 Removing `-` as a valid character for jsObjectKey
42d9e77f8 Adds jsFunctionKey to jsObjectKey
159590e1e Merge branch 'release/0.8.0' into develop
75b9896cb Merge branch 'release/0.8.0'
a2710cd0e Bump version number: 0.8.0
1c100f332 Merge pull request #123 from pangloss/feature/fix-comments
2cf625ed9 Fixes maintainer comment and removes version
2ea3c2dcd Merge pull request #122 from pangloss/feature/remove-deprecated-groups
ce20af34b Removed deprecated highlight groups
d5d2e5f2a Merge pull request #121 from pangloss/feature/regex-fixes
2133e7a96 Removing the unneeded matchgroup for jsRegexpGroup
92987e14d A few regexpengine=1 / vim 7.3 fixes
2f2f522e2 Merge branch 'feature/delink-jsFuncCall' into develop
6a89948c8 Unlink `jsFuncCall` from `Function`
e34cfbec8 Merge pull request #119 from pangloss/hotfix/nested-ternaries
cf75f6998 Fix for nested ternaries
ba16004cd Merge pull request #117 from aeosynth/patch-2
35f2609aa Delete .keep
73bac7d18 Merge pull request #114 from pangloss/feature/add-folds
2bede5c7b Adding folds for main JS block types
59fedee13 Merge pull request #112 from pangloss/feature/jsFuncParens-noise
f0415ad44 Add `jsFuncParens` to `Noise`
05ed3a07e Merge pull request #109 from pangloss/remove-jsopassign
154affe07 Merge pull request #110 from pangloss/add-js-object-key
878fa130e Adding jsObjectKey
b25654850 Removing jsOpAssign
128f153bd Merge branch 'hotfix/nevermind-they-only-do-http' into develop
033062e2e Merge branch 'hotfix/nevermind-they-only-do-http'
b8f5d6410 Force http on gitflow link
7d685e1ab Merge branch 'hotfix/nevermind-they-only-do-http'
960152aaa Force http on gitflow link
262b6c132 Merge branch 'hotfix/readme-gitflow-link' into develop
16d70af63 Merge branch 'hotfix/readme-gitflow-link'
25fa2c45d Fix link to gitflow (original article) in README
138be409d Merge branch 'hotfix/readme-gitflow-module-link' into develop
b82dc69dd Merge branch 'hotfix/readme-gitflow-module-link'
5896732fc Fix link to gitflow module in README
df1e287f8 Merge pull request #108 from pangloss/improve-booleans
6ca76f3f1 Higher specificity for `true` and `false`
e68fc0406 Merge branch 'hotfix/readme-spacing' into develop
83c0551bf Merge branch 'hotfix/readme-spacing'
1e154f25e Fix spacing issue in README file
c09a0d1db Merge branch 'release/0.1.0' into develop
a496df91a Merge branch 'release/0.1.0'
cc77bdbb9 Add version number
6e54ebf7c Update README to reflect new git flow development process
3a148155e Add `jsFuncBraces` to `Noise`
8a2e04127 Change `Blocks` to `Braces`: `jsBlocks` and `jsFuncBlocks`
17a0556a3 Update README; mention `beta` branch under `Contributing`
502bf7d6d Merge pull request #102 from amadeus/function-arguments
eac3432f5 Removing gratuitous HiLink groups
9d59178e7 Adding `jsArgsObj` keyword
d3b37e8a4 Removing deprecated jsType groups
eaf58b824 Setting jsFuncBlocks to be part of Function group
c8db23b12 Improvements to function, name and arguments
1ab789c64 Merge pull request #104 from amadeus/new-operators
be40e8b7d Tweaks to jsOperator, jsKeyword and jsStatement
64d012ce4 Merge pull request #103 from pangloss/revert-readme
68f95638a Fixes README
2452462d9 Merge branch 'rm-indent'
f4a03f88c Merge pull request #100 from pangloss/add-ternary-indent-support
9dda622a7 Fixes case where there are nested conditionals
85eeb98ae Adds leading ternary operator indentation support
790e09584 Merge pull request #98 from pangloss/fix-readme
aaf41aa1a Merge pull request #99 from pangloss/rm-rake
51e43b6c6 Removes Rakefile
fc627c7ef Removes features
399e04839 Adds config options to readme
4c5cf643b Removes html indentation
2666f1526 Merge pull request #96 from amadeus/globals-tweaks
e50319120 Removing legacy globals
4d541965b Remove `jsIdentifier`
93a465a64 Add `document` and `window` to global objects
0a01543c3 Merge pull request #90 from qstrahl/develop
207421921 Move program keywords above comments
f16ae3c33 Merge pull request #92 from amadeus/isolating-brackets-parents-blocks
e193b66dc Isolating curly/square brackets and parenthesis
0073b670e Merge branch 'master' of github.com:pangloss/vim-javascript
3a091a413 Adds contributing guide to readme
588989c63 Merge pull request #84 from robin-allen/master
501ad5d1c Link `jsNan` to `Number`
2a7d133d2 Move `Infinity` to `jsNumber` (from `jsType`)
10e3c2028 Add missing operators
03e0f2454 Merge pull request #87 from qstrahl/develop
c7ffd1b35 Link `jsFloat` to `Float` (from `Number`)
7c24dbd93 Update global objects / builtin functions
16aedfcb3 Refactor `jsType`
b53a6fdf3 Refactor `Statement` family
df84f5756 Move jsNoise higher up
c7aabe248 Change highlight links to be more semantically correct
fb677cd26 Refactor `jsFunction`/`jsFuncName`/`jsFuncBlock`/`jsOpAssign`
71e9619b8 Add `jsNan` keyword; link to `Constant` highlight group
4fcf5ce57 Update `jsType` and `jsOperator`
80ee77bc7 Add `jsNoise` so users can subdue noisy syntax clutter
c242ceecd Link `jsLabel` to `Identifier` highlight group
dbf6adbe7 Remove `-` from valid characters for `jsLabel`
c59b387e0 Add `jsFuncCall`
a4373e6f0 Add `jsIdentifier`
873da1385 Remove `jsSource` and `jsCommonJS`; not part of JavaScript
a03016945 Merge pull request #83 from mwcz/back-incompat
56dea5e12 Fix case where line ends with [ within (
336c41eb0 highlight the parameter of the @alias tag (back-incompat) version
67a7a2f95 remove deprecated jsdoc tags
3f7a3e550 add missing @arg tag
169e10b1e add jsdoc tags from jsdoc v3.2-dev
ccdf8b73b Merge pull request #81 from kevnchu/master
575602dca Fixed multiline comment indentation.
b21629b37 Merge pull request #78 from brianarn/indent-fix-77
caaa7ee42 Fixing multiline differentiation, fixes #77
22475fcbc detect javascript from shbang
f07cc6708 Merge pull request #70 from noprompt/noprompt-regexp
0329a2499 Makes the conceal syntax optional
6049b8f79 Adds concealing to some JS statements
079c5adec Adds fixes for multi var indent for comma first
df6bed93b Contain jsRegexpOr
57daa9e1a Add new regular expression syntax groups
870ffca47 Fixes some cases of multiple var indentation
647c33b04 Merge branch 'master' of github.com:pangloss/vim-javascript
c8730a184 Merge pull request #68 from hickop/fixes
e5bdc9450 Merge remote-tracking branch 'hickop/fixes' into 68
4dee33f79 Adds multiple var indent and comma-first style
b64a25099 Merge remote-tracking branch 'utyf/master'
c6cf517c7 Correct the fix.
bf6397024 Fixes whitespace nits in indent file
5bfea9bd0 Adds futurekeys to syntax highlighting
4fe016837 Renames javaScript to js
f62100276 Do not treat line comments with cindent.
4ff3b73b8 Allows CommonJS syntax inside function blocks
8c82cf076 Moves CommonJS from Define to Include
2e9791544 Merge commit '2f3935516d1aea7dc3fbd9a45efec4ba9f0b6d50'
7fab32d95 Adds CommonJS keywords to syntax highlighting
d28b72d6c Adds new maintainer info. Removes trailing whitespace
ba4f29212 linkify
08c5b1f57 Update README.md
1f68f539c Merge pull request #64 from goatslacker/patch-1
5da54c409 Adds syntax for Identifiers in labeled statements
395f8901b Fix bug in a method that is apparently not called very often (if ever)
3d11c693f improvment of indenting multi-line var statements
77ce5f02a comments in multi-line var statements
ae278efc2 adding var statement block indentation
827c47c10 Merge pull request #50 from lepture/master
35b56be77 detect json as javascript
6148d1381 Merge pull request #48 from lepture/master
1066fb67a add readme for html configuration
310c5aa38 replace html #48
e4270b2f4 add feature section in readme
3286328a8 add indent for html
97e663fda add readme
a599ac8ec Merge pull request #43 from 3rd-Eden/master
de06ab628 Merge pull request #44 from vxsx/syntax-methodof
2a84f6399 Added syntax highlighting for @methodOf tag
4ff72b7e3 Added syntax highlighting for `@api` and `@const` in JSDoc comments
a8ce72170 Support FF's sticky regex flag.
cc074c30d Fix highlighting in HTML files.
9bc0eb178 Fix indentation after multi-line comments.
5267b4f9c Handle indent correctly in multi-line comments.
faabfc83e Merge pull request #41 from int3/master
fd8d4465e Improve highlighting of ternary if statements.
e80eb0a99 Fix comment typos.
c0753fe82 Fix regex character class matching.
e66f9019b Merge pull request #37 from indygreg/master
2713e881a detect .jsm files as javascript
2f3935516 Modified syntax groups regular expressions
9990a7676 Applied nornagon's patch. Fixes #19.
2e753d85f Merge pull request #25 from regolith/master
abfbc3849 Made @returns {anything goes here} work as well.
ccd298869 Curly-braces around the type in @param allows spaces/non-word characters.
6362ba99c Merge pull request #22 from tpope/master
ecdf53438 Remove additional fold option meddling
e8d6e107f Merge pull request #21 from mando/master
3178b33c7 Syntax file adjusts folding settings
91540f635 Merge pull request #18 from int3/master
ed58aec17 Distinguish keyword operations from math expressions.
6b11ba9ca Merge pull request #16 from int3/master
91d9805df Match regexes that contain slashes in character classes.
b2c210a1e Merge pull request #13 from tanob/master
569e64c14 Merge pull request #15 from kwellman/master
56cb1680f Merge pull request #11 from keitahaga/env_comment
92bf4e715 Don't add extra indent to each continuation line
66dc2bf47 Fixed issue #12 around indentation with colon and slashes.
d5b98a9d7 switch to PreProc syntax group
2a4d50d79 javaScriptEnvComment highlight group cleanup
67be84dd2 added #! comments for executing js in shell
abb6c374f Merge remote branch 'wavded/master'
2e34e9171 remove const as a 'future' key, in use for v8, sm
7a7b75f68 Merge remote branch 'upstream/master'
dc882db43 separating out this from javaScriptType
aad288df4 Added ftdetect
9a5a6b5ed Merge remote branch 'ukstv/master'
891915672 Merge remote branch 'wavded/master'
f92d83cc1 added support for newer JSDoc / JSToolkit tags
ccdb9becc Added ftdetect
c2df2e430 Disambiguate regex strings and mathematical statements
cf76032a4 Added javascript ctags patterns and a rake task to install them
cb52fbc88 Allow those one line scopes to be on one line and terminated with ;
6a1bb6b32 Updated syntax highlighter region names
e94532de7 Imported files
REVERT: 3093f26be Squashed 'vim/bundle/javascript/' content from commit bf8edcb

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

@ -1,4 +1,4 @@
# vim-javascript v1.0.0 # vim-javascript
JavaScript bundle for vim, this bundle provides syntax highlighting and JavaScript bundle for vim, this bundle provides syntax highlighting and
improved indentation. improved indentation.
@ -35,24 +35,37 @@ And install it:
## Configuration Variables ## Configuration Variables
The following variables control certain syntax highlighting features. You can The following variables control certain syntax highlighting plugins. You can
add them to your `.vimrc` to enable/disable their features. add them to your `.vimrc` to enable their features.
-----------------
``` ```
let g:javascript_enable_domhtmlcss = 1 let g:javascript_plugin_jsdoc = 1
``` ```
Enables HTML/CSS syntax highlighting in your JavaScript file. Enables syntax highlighting for [JSDocs](http://usejsdoc.org/).
Default Value: 0 Default Value: 0
----------------- -----------------
``` ```
let g:javascript_ignore_javaScriptdoc = 1 let g:javascript_plugin_ngdoc = 1
``` ```
Disables JSDoc syntax highlighting Enables some additional syntax highlighting for NGDocs. Requires JSDoc plugin
to be enabled as well.
Default Value: 0
-----------------
```
let g:javascript_plugin_flow = 1
```
Enables syntax highlighting for [Flow](https://flowtype.org/).
Default Value: 0 Default Value: 0
@ -84,6 +97,9 @@ variables:
let g:javascript_conceal_super = "Ω" let g:javascript_conceal_super = "Ω"
let g:javascript_conceal_arrow_function = "⇒" let g:javascript_conceal_arrow_function = "⇒"
## Indentation Specific
* `:h cino-:`
## Contributing ## Contributing
@ -101,18 +117,6 @@ proposed change and how it is valuable.
Report a bug on [GitHub Issues](https://github.com/pangloss/vim-javascript/issues). Report a bug on [GitHub Issues](https://github.com/pangloss/vim-javascript/issues).
## A Quick Note on Regexes
Vim 7.4 with patches LESS than 1-7 exhibits a bug that broke how we handle
javascript regexes. Please update to a newer version or run the following
commands to fix:
```
:set regexpengine=1
:syntax enable
```
## License ## License
Distributed under the same terms as Vim itself. See `:help license`. Distributed under the same terms as Vim itself. See `:help license`.

@ -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

@ -0,0 +1,87 @@
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 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 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 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 jsFlowReturnKeyword contained /\k\+/ contains=jsFlowType,jsFlowTypeCustom skipwhite skipempty nextgroup=jsFlowReturnGroup,jsFuncBlock,jsFlowReturnOrOp
syntax match jsFlowReturnMaybe contained /?/ skipwhite skipempty nextgroup=jsFlowReturnKeyword
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 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 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 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 jsFlowInterfaceBlock contained matchgroup=jsFlowNoise start=/{/ end=/}/ contains=jsObjectKey,jsObjectKeyString,jsObjectKeyComputed,jsObjectSeparator,jsObjectFuncName,jsObjectMethodType,jsGenerator,jsComment,jsObjectStringKey,jsSpreadExpression,jsFlowNoise keepend
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
if version >= 508 || !exists("did_javascript_syn_inits")
if version < 508
let did_javascript_syn_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
HiLink jsFlowDefinition PreProc
HiLink jsFlowClassDef jsFlowDefinition
HiLink jsFlowArgumentDef jsFlowDefinition
HiLink jsFlowType Type
HiLink jsFlowTypeCustom PreProc
HiLink jsFlowTypeof PreProc
HiLink jsFlowArray PreProc
HiLink jsFlowObject PreProc
HiLink jsFlowParens PreProc
HiLink jsFlowGroup PreProc
HiLink jsFlowReturn PreProc
HiLink jsFlowReturnObject jsFlowReturn
HiLink jsFlowReturnArray jsFlowArray
HiLink jsFlowReturnParens jsFlowParens
HiLink jsFlowReturnGroup jsFlowGroup
HiLink jsFlowFunctionGroup PreProc
HiLink jsFlowClassGroup PreProc
HiLink jsFlowArrowArguments PreProc
HiLink jsFlowArrow PreProc
HiLink jsFlowTypeStatement PreProc
HiLink jsFlowTypeKeyword PreProc
HiLink jsFlowTypeOperator PreProc
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 PreProc
HiLink jsFlowReturnOrOp jsFlowOrOperator
delcommand HiLink
endif

@ -0,0 +1,39 @@
"" 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\)\>" 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
" 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 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 <args>
else
command -nargs=+ HiLink hi def link <args>
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

@ -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\|\"\|-\|\.\|:\|{\|}\|\/\|\[\|]\|=\)\+"

@ -3,7 +3,7 @@ au BufNewFile,BufRead *.jsm setf javascript
au BufNewFile,BufRead Jakefile setf javascript au BufNewFile,BufRead Jakefile setf javascript
fun! s:SelectJavascript() fun! s:SelectJavascript()
if getline(1) =~# '^#!.*/bin/env\s\+node\>' if getline(1) =~# '^#!.*/bin/\%(env\s\+\)\?node\>'
set ft=javascript set ft=javascript
endif endif
endfun endfun

@ -1 +0,0 @@
setlocal suffixesadd+=.js

@ -1,25 +1,25 @@
" Vim indent file " Vim indent file
" Language: Javascript " Language: Javascript
" Acknowledgement: Based off of vim-ruby maintained by Nikolai Weibull http://vim-ruby.rubyforge.org " Maintainer: Chris Paul ( https://github.com/bounceme )
" URL: https://github.com/pangloss/vim-javascript
" 0. Initialization {{{1 " Last Change: November 6, 2016
" =================
" Only load this indent file when no other was loaded. " Only load this indent file when no other was loaded.
if exists("b:did_indent") if exists('b:did_indent')
finish finish
endif endif
let b:did_indent = 1 let b:did_indent = 1
setlocal nosmartindent
" Now, set up our indentation expression and keys that trigger it. " Now, set up our indentation expression and keys that trigger it.
setlocal indentexpr=GetJavascriptIndent() setlocal indentexpr=GetJavascriptIndent()
setlocal formatexpr=Fixedgq(v:lnum,v:count) setlocal autoindent nolisp nosmartindent
setlocal indentkeys=0{,0},0),0],0\,:,!^F,o,O,e setlocal indentkeys=0{,0},0),0],:,!^F,o,O,e
setlocal cinoptions+=j1,J1
let b:undo_indent = 'setlocal indentexpr< smartindent< autoindent< indentkeys< cinoptions<'
" Only define the function once. " Only define the function once.
if exists("*GetJavascriptIndent") if exists('*GetJavascriptIndent')
finish finish
endif endif
@ -28,584 +28,235 @@ set cpo&vim
" Get shiftwidth value " Get shiftwidth value
if exists('*shiftwidth') if exists('*shiftwidth')
func s:sw() function s:sw()
return shiftwidth() return shiftwidth()
endfunc endfunction
else else
func s:sw() function s:sw()
return &sw return &sw
endfunc endfunction
endif endif
" 1. Variables {{{1 let s:case_stmt = '\<\%(case\>\s*[^ \t:].*\|default\s*\):\C'
" ============
let s:js_keywords = '^\s*\(break\|catch\|const\|continue\|debugger\|delete\|do\|else\|finally\|for\|function\|if\|in\|instanceof\|let\|new\|return\|switch\|this\|throw\|try\|typeof\|var\|void\|while\|with\)'
let s:expr_case = '^\s*\(case\s\+[^\:]*\|default\)\s*:\s*'
" Regex of syntax group names that are or delimit string or are comments. " Regex of syntax group names that are or delimit string or are comments.
let s:syng_strcom = '\%(\%(template\)\@<!string\|regex\|comment\)\c' let s:syng_strcom = 'string\|comment\|regex\|special\|doc\|template'
" Regex of syntax group names that are or delimit template strings
let s:syng_template = 'template\c'
" Regex of syntax group names that are strings.
let s:syng_string = 'regex\c'
" Regex of syntax group names that are strings or documentation.
let s:syng_multiline = 'comment\c'
" Regex of syntax group names that are line comment.
let s:syng_linecom = 'linecomment\c'
" Expression used to check whether we should skip a match with searchpair(). " Expression used to check whether we should skip a match with searchpair().
let s:skip_expr = "synIDattr(synID(line('.'),col('.'),1),'name') =~ '".s:syng_strcom."'" let s:skip_expr = "synIDattr(synID(line('.'),col('.'),0),'name') =~? '".s:syng_strcom."'"
function s:skip_func(lnum)
let s:line_term = '\s*\%(\%(\/\/\).*\)\=$' if !s:free || search('`\|\*\/','nW',a:lnum)
let s:free = !eval(s:skip_expr . " . '\\|html'")
" Regex that defines continuation lines, not including (, {, or [. let s:looksyn = s:free ? line('.') : s:looksyn
let s:continuation_regex = '\%([\\*/.:]\|+\@<!+\|-\@<!-\|\%(<%\)\@<!=\|\W[|&?]\|||\|&&\|[^=]=[^=>].*,\)' . s:line_term return !s:free
endif
" Regex that defines continuation lines. let s:looksyn = line('.')
" TODO: this needs to deal with if ...: and so on return (search('\/','nbW',s:looksyn) || search('[''"\\]','nW',s:looksyn)) && eval(s:skip_expr . " . '\\|html'")
let s:msl_regex = s:continuation_regex.'\|'.s:expr_case
let s:one_line_scope_regex = '\%(\%(\<else\>\|\<\%(if\|for\|while\)\>\s*(\%([^()]*\|[^()]*(\%([^()]*\|[^()]*(\%([^()]*\|[^()]*([^()]*)[^()]*\))[^()]*\))[^()]*\))\)\|=>\)' . s:line_term
" Regex that defines blocks.
let s:block_regex = '\%([{([]\)\s*\%(|\%([*@]\=\h\w*,\=\s*\)\%(,\s*[*@]\=\h\w*\)*|\)\=' . s:line_term
let s:operator_first = '^\s*\%([*/.:?]\|\([-+]\)\1\@!\|||\|&&\)'
let s:var_stmt = '^\s*\%(const\|let\|var\)'
let s:comma_first = '^\s*,'
let s:comma_last = ',\s*$'
let s:case_indent = s:sw()
let s:case_indent_after = s:sw()
let s:m = matchlist(&cinoptions, ':\(.\)')
if (len(s:m) > 2)
let s:case_indent = s:m[1]
endif
let s:m = matchlist(&cinoptions, '=\(.\)')
if (len(s:m) > 2)
let s:case_indent_after = s:m[1]
endif
" 2. Auxiliary Functions {{{1
" ======================
" Check if the character at lnum:col is inside a string, comment, or is ascii.
function s:IsInStringOrComment(lnum, col)
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_strcom
endfunction
" Check if the character at lnum:col is inside a string.
function s:IsInString(lnum, col)
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_string
endfunction endfunction
" Check if the character at lnum:col is inside a template string. if has('reltime')
function s:IsInTempl(lnum, col) function s:GetPair(start,end,flags,skip,time,...)
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_template return searchpair(a:start,'',a:end,a:flags,a:skip,max([prevnonblank(v:lnum) - 2000,0] + a:000),a:time)
endfunction endfunction
" Check if the character at lnum:col is inside a multi-line comment.
function s:IsInMultilineComment(lnum, col)
return !s:IsLineComment(a:lnum, a:col) && synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_multiline
endfunction
" Check if the character at lnum:col is a line comment.
function s:IsLineComment(lnum, col)
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_linecom
endfunction
" Find line above 'lnum' that isn't empty, in a comment, or in a string.
function s:PrevNonBlankNonString(lnum)
let in_block = 0
let lnum = prevnonblank(a:lnum)
while lnum > 0
" Go in and out of blocks comments as necessary.
" If the line isn't empty (with opt. comment) or in a string, end search.
let line = getline(lnum)
if s:IsInMultilineComment(lnum, matchend(line, '/\*') - 1)
if in_block
let in_block = 0
else else
break function s:GetPair(start,end,flags,skip,...)
endif return searchpair(a:start,'',a:end,a:flags,a:skip,max([prevnonblank(v:lnum) - 1000,get(a:000,1)]))
elseif !in_block && s:IsInMultilineComment(lnum, matchend(line, '\*/') - 1)
let in_block = 1
elseif !in_block && line !~ '^\s*\%(//\).*$' && !(s:IsInStringOrComment(lnum, 1) && s:IsInStringOrComment(lnum, strlen(line)))
break
endif
let lnum = prevnonblank(lnum - 1)
endwhile
return lnum
endfunction endfunction
" Find line above 'lnum' that started the continuation 'lnum' may be part of.
function s:GetMSL(lnum, in_one_line_scope)
" Start on the line we're at and use its indent.
let msl = a:lnum
let lnum = s:PrevNonBlankNonString(a:lnum - 1)
while lnum > 0
" If we have a continuation line, or we're in a string, use line as MSL.
" Otherwise, terminate search as we have found our MSL already.
let line = getline(lnum)
let col = match(line, s:msl_regex) + 1
let line2 = getline(msl)
let col2 = matchend(line2, ')')
if (col > 0 && !s:IsInStringOrComment(lnum, col)) || s:IsInString(lnum, strlen(line))
let msl = lnum
" if there are more closing brackets, continue from the line which has the matching opening bracket
elseif col2 > 0 && !s:IsInStringOrComment(msl, col2) && s:LineHasOpeningBrackets(msl)[0] == '2' && !a:in_one_line_scope
call cursor(msl, 1)
if searchpair('(', '', ')', 'bW', s:skip_expr) > 0
let lnum = line('.')
let msl = lnum
endif endif
else function s:current_char()
return getline('.')[col('.')-1]
" Don't use lines that are part of a one line scope as msl unless the
" flag in_one_line_scope is set to 1
"
if a:in_one_line_scope
break
end
let msl_one_line = s:Match(lnum, s:one_line_scope_regex)
if msl_one_line == 0
break
endif
end
let lnum = s:PrevNonBlankNonString(lnum - 1)
endwhile
return msl
endfunction endfunction
function s:RemoveTrailingComments(content) function s:token()
let single = '\/\/\(.*\)\s*$' return s:current_char() =~ '\k' ? expand('<cword>') : s:current_char()
let multi = '\/\*\(.*\)\*\/\s*$'
return substitute(substitute(a:content, single, '', ''), multi, '', '')
endfunction endfunction
" Find if the string is inside var statement (but not the first string) " NOTE: moves the cursor
function s:InMultiVarStatement(lnum) function s:previous_token()
let lnum = s:PrevNonBlankNonString(a:lnum - 1) return search('\<\|[][`^!"%-/:-?{-~]','bW') ? s:token() : ''
endfunction
" let type = synIDattr(synID(lnum, indent(lnum) + 1, 0), 'name')
" loop through previous expressions to find a var statement
while lnum > 0
let line = getline(lnum)
" if the line is a js keyword
if (line =~ s:js_keywords)
" check if the line is a var stmt
" if the line has a comma first or comma last then we can assume that we
" are in a multiple var statement
if (line =~ s:var_stmt)
return lnum
endif
" other js keywords, not a var
return 0
endif
let lnum = s:PrevNonBlankNonString(lnum - 1) 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])
endwhile endwhile
return pline
" beginning of program, not a var
return 0
endfunction endfunction
" Find line above with beginning of the var statement or returns 0 if it's not " configurable regexes that define continuation lines, not including (, {, or [.
" this statement let s:opfirst = '^' . get(g:,'javascript_opfirst',
function s:GetVarIndent(lnum) \ '\%([<>,?^%|*/&]\|\([-.:+]\)\1\@!\|=>\@!\|in\%(stanceof\)\=\>\)')
let lvar = s:InMultiVarStatement(a:lnum) let s:continuation = get(g:,'javascript_continuation',
let prev_lnum = s:PrevNonBlankNonString(a:lnum - 1) \ '\%([<=,.?/*^%|&:]\|+\@<!+\|-\@<!-\|=\@<!>\|\<in\%(stanceof\)\=\)') . '$'
if lvar function s:OneScope(lnum,text)
let line = s:RemoveTrailingComments(getline(prev_lnum)) if cursor(a:lnum, match(' ' . a:text, ')$')) + 1 &&
\ s:GetPair('(', ')', 'bW', s:skip_expr, 100) > 0
" if the previous line doesn't end in a comma, return to regular indent let token = s:previous_token()
if (line !~ s:comma_last) if index(split('await each'),token) + 1
return indent(prev_lnum) - s:sw() return s:previous_token() ==# 'for'
else
return indent(lvar) + s:sw()
endif endif
return index(split('for if let while with'),token) + 1
endif endif
return cursor(a:lnum, match(' ' . a:text, '\%(\<else\|\<do\|=>\)$\C')) + 1
return -1
endfunction endfunction
function s:iscontOne(i,num,cont)
" Check if line 'lnum' has more opening brackets than closing ones. let [l:i, l:cont, l:num] = [a:i, a:cont, a:num + !a:num]
function s:LineHasOpeningBrackets(lnum) let pind = a:num ? indent(l:num) + s:W : 0
let open_0 = 0 let ind = indent(l:i) + (a:cont ? 0 : s:W)
let open_2 = 0 let bL = 0
let open_4 = 0 while l:i >= l:num && (!l:cont || ind > pind)
let line = getline(a:lnum) if indent(l:i) < ind " first line always true for !a:cont, false for !!a:cont
let pos = match(line, '[][(){}]', 0) if s:OneScope(l:i,s:Trim(l:i))
while pos != -1 let bL += s:W
if !s:IsInStringOrComment(a:lnum, pos + 1) let [l:cont, l:i] = [0, line('.')]
let idx = stridx('(){}[]', line[pos]) elseif !l:cont
if idx % 2 == 0 break
let open_{idx} = open_{idx} + 1
else
let open_{idx - 1} = open_{idx - 1} - 1
endif endif
elseif !a:cont
break
endif endif
let pos = match(line, '[][(){}]', pos + 1) let ind = min([ind, indent(l:i)])
let l:i = s:PrevCodeLine(l:i - 1)
endwhile endwhile
return (open_0 > 0 ? 1 : (open_0 == 0 ? 0 : 2)) . (open_2 > 0) . (open_4 > 0) return bL
endfunction
function s:Match(lnum, regex)
let col = match(getline(a:lnum), a:regex) + 1
return col > 0 && !s:IsInStringOrComment(a:lnum, col) ? col : 0
endfunction endfunction
function s:IndentWithContinuation(lnum, ind, width) " https://github.com/sweet-js/sweet.js/wiki/design#give-lookbehind-to-the-reader
" Set up variables to use and search for MSL to the previous line. function s:IsBlock(...)
let p_lnum = a:lnum let l:ln = get(a:000,0,line('.'))
let lnum = s:GetMSL(a:lnum, 1) let char = s:previous_token()
let line = getline(lnum) let syn = char =~ '[{>/]' || l:ln != line('.') ? synIDattr(synID(line('.'),col('.')-(char == '{'),0),'name') : ''
if char is ''
" If the previous line wasn't a MSL and is continuation return its indent. return 1
" TODO: the || s:IsInString() thing worries me a bit. elseif syn =~? 'xml\|jsx'
if p_lnum != lnum return char != '{'
if s:Match(p_lnum,s:continuation_regex)||s:IsInString(p_lnum,strlen(line)) elseif syn =~? 'comment'
return a:ind return search('\/[/*]','bW') && s:IsBlock(l:ln)
endif elseif char == '>'
endif return getline('.')[col('.')-2] == '=' || syn =~? '^jsflow'
elseif char == ':'
" Set up more variables now that we know we aren't continuation bound. return cursor(0,match(' ' . strpart(getline('.'),0,col('.')),'.*\zs' . s:case_stmt . '$')) + 1 &&
let msl_ind = indent(lnum) \ (expand('<cword>') !=# 'default' || s:previous_token() !~ '[,{]')
endif
" If the previous line ended with [*+/.-=], start a continuation that return index(split('return const let import export yield default delete var void typeof throw new in instanceof'
" indents an extra level. \ . ' - = ~ ! < * + , / ? ^ % | & ( ['), char) < (0 + (line('.') != l:ln))
if s:Match(lnum, s:continuation_regex)
if lnum == p_lnum
return msl_ind + a:width
else
return msl_ind
endif
endif
return a:ind
endfunction endfunction
function s:InOneLineScope(lnum) " Find line above 'lnum' that isn't empty, in a comment, or in a string.
let msl = s:GetMSL(a:lnum, 1) function s:PrevCodeLine(lnum)
if msl > 0 && s:Match(msl, s:one_line_scope_regex) let l:lnum = prevnonblank(a:lnum)
return msl while l:lnum
endif let syn = synIDattr(synID(l:lnum,matchend(getline(l:lnum), '^\s*[^''"`]'),0),'name')
return 0 if syn =~? 'html'
return
elseif syn !~? s:syng_strcom
return l:lnum
endif
let l:lnum = prevnonblank(l:lnum - 1)
endwhile
endfunction endfunction
function s:ExitingOneLineScope(lnum) " Check if line 'lnum' has a balanced amount of parentheses.
let msl = s:GetMSL(a:lnum, 1) function s:Balanced(lnum)
if msl > 0 let l:open = 0
" if the current line is in a one line scope .. let l:line = getline(a:lnum)
if s:Match(msl, s:one_line_scope_regex) let pos = match(l:line, '[][(){}]', 0)
return 0 while pos != -1
else if synIDattr(synID(a:lnum,pos + 1,0),'name') !~? s:syng_strcom
let prev_msl = s:GetMSL(msl - 1, 1) let l:open += match(' ' . l:line[pos],'[[({]')
if s:Match(prev_msl, s:one_line_scope_regex) if l:open < 0
return prev_msl return
endif
endif endif
endif endif
return 0 let pos = match(l:line, '[][(){}]', pos + 1)
endwhile
return !l:open
endfunction endfunction
" 3. GetJavascriptIndent Function {{{1
" =========================
function GetJavascriptIndent() function GetJavascriptIndent()
" 3.1. Setup {{{2 let b:js_cache = get(b:,'js_cache',[0,0,0])
" ----------
" Set up variables for restoring position in file. Could use v:lnum here.
let vcol = col('.')
" 3.2. Work on the current line {{{2
" -----------------------------
let ind = -1
" Get the current line. " Get the current line.
let line = getline(v:lnum) let l:line = getline(v:lnum)
" previous nonblank line number let syns = synIDattr(synID(v:lnum, 1, 0), 'name')
let prevline = prevnonblank(v:lnum - 1)
if (line =~ s:expr_case) " start with strings,comments,etc.
if (getline(prevline) =~ s:expr_case) if syns =~? 'comment\|doc'
return indent(prevline) if l:line =~ '^\s*\*'
else return cindent(v:lnum)
if (getline(prevline) =~ s:block_regex) elseif l:line !~ '^\s*\/'
return indent(prevline) + s:case_indent return -1
else
return indent(prevline) - s:case_indent_after
endif
endif endif
elseif syns =~? 'string\|template' && l:line !~ '^[''"]'
return -1
endif endif
" If we got a closing bracket on an empty line, find its match and indent let l:lnum = s:PrevCodeLine(v:lnum - 1)
" according to it. For parentheses we indent to its column - 1, for the if !l:lnum
" others we indent to the containing line's MSL's level. Return -1 if fail. return
let col = matchend(line, '^\s*[],})]') endif
if col > 0 && !s:IsInStringOrComment(v:lnum, col)
call cursor(v:lnum, col) let l:line = substitute(substitute(l:line,'^\s*\%(\/\*.\{-}\*\/\s*\)*','',''),'^\/[/*].*','','')
let lvar = s:InMultiVarStatement(v:lnum) " the containing paren, bracket, curly. Many hacks for performance
if lvar call cursor(v:lnum,1)
let prevline_contents = s:RemoveTrailingComments(getline(prevline)) let idx = strlen(l:line) ? stridx('])}',l:line[0]) : -1
if indent(l:lnum)
" check for comma first let [s:looksyn,s:free] = [v:lnum - 1,1]
if (line[col - 1] =~ ',') if b:js_cache[0] >= l:lnum && b:js_cache[0] < v:lnum &&
" if the previous line ends in comma or semicolon don't indent \ (b:js_cache[0] > l:lnum || s:Balanced(l:lnum))
if (prevline_contents =~ '[;,]\s*$') call call('cursor',b:js_cache[1:])
return indent(s:GetMSL(line('.'), 0)) elseif idx + 1
" get previous line indent, if it's comma first return prevline indent call s:GetPair(['\[','(','{'][idx], '])}'[idx],'bW','s:skip_func(s:looksyn)',2000)
elseif (prevline_contents =~ s:comma_first) elseif indent(v:lnum) && syns =~? 'block'
return indent(prevline) call s:GetPair('{','}','bW','s:skip_func(s:looksyn)',2000)
" otherwise we indent 1 level
else else
return indent(lvar) + s:sw() call s:GetPair('[({[]','[])}]','bW','s:skip_func(s:looksyn)',2000)
endif
endif endif
endif
let bs = strpart('(){}[]', stridx(')}]', line[col - 1]) * 2, 2)
if searchpair(escape(bs[0], '\['), '', bs[1], 'bW', s:skip_expr) > 0
if line[col-1]==')' && col('.') != col('$') - 1
let ind = virtcol('.')-1
else else
let ind = indent(s:GetMSL(line('.'), 0)) call s:GetPair('[({[]','[])}]','bW',s:skip_expr,200,l:lnum)
endif
endif
return ind
endif endif
" If the line is comma first, dedent 1 level if idx + 1
if (getline(prevline) =~ s:comma_first) if idx == 2 && search('\S','bW',line('.')) && s:current_char() == ')'
return indent(prevline) - s:sw() call s:GetPair('(',')','bW',s:skip_expr,200)
endif endif
if (getline(prevline) =~ s:expr_case) return indent(line('.'))
return indent(prevline) + s:case_indent_after
endif endif
" If line starts with an operator... let b:js_cache = [v:lnum] + (line('.') == v:lnum ? [0,0] : [line('.'),col('.')])
if (s:Match(v:lnum, s:operator_first)) let num = b:js_cache[1]
if (s:Match(prevline, s:operator_first))
" and so does previous line, don't indent
return indent(prevline)
end
let counts = s:LineHasOpeningBrackets(prevline)
if counts[0] == '2'
call cursor(prevline, 1)
" Search for the opening tag
let mnum = searchpair('(', '', ')', 'bW', s:skip_expr)
if mnum > 0 && s:Match(mnum, s:operator_first)
return indent(mnum)
end
elseif counts[0] != '1' && counts[1] != '1' && counts[2] != '1'
" otherwise, indent 1 level
return indent(prevline) + s:sw()
end
" If previous line starts with an operator...
elseif s:Match(prevline, s:operator_first) && !s:Match(prevline, s:comma_last) && !s:Match(prevline, '};\=' . s:line_term)
let counts = s:LineHasOpeningBrackets(prevline)
if counts[0] == '2' && counts[1] == '1'
call cursor(prevline, 1)
" Search for the opening tag
let mnum = searchpair('(', '', ')', 'bW', s:skip_expr)
if mnum > 0 && !s:Match(mnum, s:operator_first)
return indent(mnum) + s:sw()
end
elseif counts[0] != '1' && counts[1] != '1' && counts[2] != '1'
return indent(prevline) - s:sw()
end
end
if getline(prevline) =~ '^\s*`$' && s:IsInTempl(v:lnum, 1) let [s:W, pline, isOp, stmt, bL, switch_offset] = [s:sw(), s:Trim(l:lnum),0,0,0,0]
if line !~ '^\s*`$' if num && s:current_char() == '{' && s:IsBlock()
return indent(prevline) + s:sw() 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
endif endif
elseif line =~ '^\s*`$' && s:IsInTempl(prevline, 1) let stmt = pline !~# s:case_stmt . '$'
return indent(prevline) - s:sw()
endif
" If we are in a multi-line comment, cindent does the right thing.
if s:IsInMultilineComment(v:lnum, 1) && !s:IsLineComment(v:lnum, 1)
return cindent(v:lnum)
endif endif
" Check for multiple var assignments
" let var_indent = s:GetVarIndent(v:lnum)
" if var_indent >= 0
" return var_indent
" endif
" 3.3. Work on the previous line. {{{2
" -------------------------------
" If the line is empty and the previous nonblank line was a multi-line
" comment, use that comment's indent. Deduct one char to account for the
" space in ' */'.
if line =~ '^\s*$' && s:IsInMultilineComment(prevline, 1)
return indent(prevline) - 1
endif endif
" Find a non-blank, non-multi-line string line above the current line. if stmt || !num
let lnum = s:PrevNonBlankNonString(v:lnum - 1) let isOp = l:line =~# s:opfirst || pline =~# s:continuation
let bL = s:iscontOne(l:lnum,num,isOp)
" If the line is empty and inside a string, use the previous line. let bL -= (bL && l:line[0] == '{') * s:W
if line =~ '^\s*$' && lnum != prevline
return indent(prevnonblank(v:lnum))
endif endif
" At the start of the file use zero indent. " main return
if lnum == 0 if isOp
return 0 return (num ? indent(num) : -s:W) + (s:W * 2) + switch_offset + bL
elseif num
return indent(num) + s:W + switch_offset + bL
endif endif
return bL
" If the previous line ended with a block opening, add a level of indent.
if s:Match(lnum, s:block_regex)
if (line =~ s:expr_case)
return indent(s:GetMSL(lnum, 0)) + s:sw()/2
else
return indent(s:GetMSL(lnum, 0)) + s:sw()
endif
endif
" Set up variables for current line.
let line = getline(lnum)
let ind = indent(lnum)
" If the previous line contained an opening bracket, and we are still in it,
" add indent depending on the bracket type.
if line =~ '[[({]'
let counts = s:LineHasOpeningBrackets(lnum)
if counts[0] == '1' && searchpair('(', '', ')', 'bW', s:skip_expr) > 0
if col('.') + 1 == col('$') || line =~ s:one_line_scope_regex
return ind + s:sw()
else
return virtcol('.')
endif
elseif counts[1] == '1' || counts[2] == '1' && counts[0] != '2'
return ind + s:sw()
else
call cursor(v:lnum, vcol)
end
elseif line =~ '.\+};\=' . s:line_term
call cursor(lnum, 1)
" Search for the opening tag
let mnum = searchpair('{', '', '}', 'bW', s:skip_expr)
if mnum > 0
return indent(s:GetMSL(mnum, 0))
end
elseif line =~ '.\+);\=' || line =~ s:comma_last
let counts = s:LineHasOpeningBrackets(lnum)
if counts[0] == '2'
call cursor(lnum, 1)
" Search for the opening tag
let mnum = searchpair('(', '', ')', 'bW', s:skip_expr)
if mnum > 0
return indent(s:GetMSL(mnum, 0))
end
elseif line !~ s:var_stmt
return indent(prevline)
end
end
" 3.4. Work on the MSL line. {{{2
" --------------------------
let ind_con = ind
let ind = s:IndentWithContinuation(lnum, ind_con, s:sw())
" }}}2
"
"
let ols = s:InOneLineScope(lnum)
if ols > 0
let ind = ind + s:sw()
else
let ols = s:ExitingOneLineScope(lnum)
while ols > 0 && ind > 0
let ind = ind - s:sw()
let ols = s:InOneLineScope(ols - 1)
endwhile
endif
return ind
endfunction endfunction
" }}}1
let &cpo = s:cpo_save let &cpo = s:cpo_save
unlet s:cpo_save unlet s:cpo_save
function! Fixedgq(lnum, count)
let l:tw = &tw ? &tw : 80;
let l:count = a:count
let l:first_char = indent(a:lnum) + 1
if mode() == 'i' " gq was not pressed, but tw was set
return 1
endif
" This gq is only meant to do code with strings, not comments
if s:IsLineComment(a:lnum, l:first_char) || s:IsInMultilineComment(a:lnum, l:first_char)
return 1
endif
if len(getline(a:lnum)) < l:tw && l:count == 1 " No need for gq
return 1
endif
" Put all the lines on one line and do normal spliting after that
if l:count > 1
while l:count > 1
let l:count -= 1
normal J
endwhile
endif
let l:winview = winsaveview()
call cursor(a:lnum, l:tw + 1)
let orig_breakpoint = searchpairpos(' ', '', '\.', 'bcW', '', a:lnum)
call cursor(a:lnum, l:tw + 1)
let breakpoint = searchpairpos(' ', '', '\.', 'bcW', s:skip_expr, a:lnum)
" No need for special treatment, normal gq handles edgecases better
if breakpoint[1] == orig_breakpoint[1]
call winrestview(l:winview)
return 1
endif
" Try breaking after string
if breakpoint[1] <= indent(a:lnum)
call cursor(a:lnum, l:tw + 1)
let breakpoint = searchpairpos('\.', '', ' ', 'cW', s:skip_expr, a:lnum)
endif
if breakpoint[1] != 0
call feedkeys("r\<CR>")
else
let l:count = l:count - 1
endif
" run gq on new lines
if l:count == 1
call feedkeys("gqq")
endif
return 0
endfunction

@ -12,210 +12,223 @@ if !exists("main_syntax")
let main_syntax = 'javascript' let main_syntax = 'javascript'
endif endif
if !exists('g:javascript_conceal') " Dollar sign is permitted anywhere in an identifier
let g:javascript_conceal = 0 if v:version > 704 || v:version == 704 && has('patch1142')
endif syntax iskeyword @,48-57,_,192-255,$
else
"" dollar sign is permittd anywhere in an identifier
setlocal iskeyword+=$ setlocal iskeyword+=$
endif
syntax sync fromstart syntax sync fromstart
" TODO: Figure out what type of casing I need
" syntax case ignore
syntax case match
syntax match jsNoise /[:,\;\.]\{1}/ syntax match jsNoise /[:,\;\.]\{1}/
syntax match jsFuncCall /\k\+\%(\s*(\)\@=/
syntax match jsParensError /[)}\]]/
"" Program Keywords " Program Keywords
syntax keyword jsStorageClass const var let syntax keyword jsStorageClass const var let skipwhite skipempty nextgroup=jsDestructuringBlock,jsDestructuringArray,jsVariableDef
syntax keyword jsOperator delete instanceof typeof void new in syntax match jsVariableDef contained /\k\+/ nextgroup=jsFlowDefinition
syntax keyword jsOperator delete instanceof typeof void new in of
syntax match jsOperator /[\!\|\&\+\-\<\>\=\%\/\*\~\^]\{1}/ syntax match jsOperator /[\!\|\&\+\-\<\>\=\%\/\*\~\^]\{1}/
syntax keyword jsBooleanTrue true syntax keyword jsBooleanTrue true
syntax keyword jsBooleanFalse false syntax keyword jsBooleanFalse false
syntax keyword jsModules import export contained
syntax keyword jsModuleWords default from as contained
syntax keyword jsOf of contained
syntax keyword jsArgsObj arguments
syntax region jsImportContainer start="^\s\?import \?" end=";\|$" contains=jsModules,jsModuleWords,jsLineComment,jsComment,jsStringS,jsStringD,jsTemplateString,jsNoise,jsBlock
syntax region jsExportContainer start="^\s\?export \?" end="$" contains=jsModules,jsModuleWords,jsComment,jsTemplateString,jsStringD,jsStringS,jsRegexpString,jsNumber,jsFloat,jsThis,jsOperator,jsBooleanTrue,jsBooleanFalse,jsNull,jsFunction,jsArrowFunction,jsGlobalObjects,jsExceptions,jsDomErrNo,jsDomNodeConsts,jsHtmlEvents,jsDotNotation,jsBracket,jsParen,jsFuncCall,jsUndefined,jsNan,jsKeyword,jsStorageClass,jsPrototype,jsBuiltins,jsNoise,jsArgsObj,jsBlock,jsClassDefinition
"" JavaScript comments
syntax keyword jsCommentTodo TODO FIXME XXX TBD contained
syntax region jsLineComment start=+\/\/+ end=+$+ keepend contains=jsCommentTodo,@Spell extend
syntax region jsEnvComment start="\%^#!" end="$" display
syntax region jsLineComment start=+^\s*\/\/+ skip=+\n\s*\/\/+ end=+$+ keepend contains=jsCommentTodo,@Spell fold
syntax region jsCvsTag start="\$\cid:" end="\$" oneline contained
syntax region jsComment start="/\*" end="\*/" contains=jsCommentTodo,jsCvsTag,@Spell fold extend
"" JSDoc / JSDoc Toolkit
if !exists("javascript_ignore_javaScriptdoc")
syntax case ignore
"" syntax coloring for javadoc comments (HTML)
"syntax include @javaHtml <sfile>:p:h/html.vim
"unlet b:current_syntax
syntax region jsBlockComment 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\)\>" nextgroup=jsDocParam skipwhite
" tags containing type and param
syntax match jsDocTags contained "@\(arg\|argument\|cfg\|param\|property\|prop\)\>" nextgroup=jsDocType skipwhite
" tags containing type but no param
syntax match jsDocTags contained "@\(callback\|define\|enum\|external\|implements\|this\|type\|typedef\|return\|returns\)\>" nextgroup=jsDocTypeNoParam skipwhite
" tags containing references
syntax match jsDocTags contained "@\(lends\|see\|tutorial\)\>" nextgroup=jsDocSeeTag skipwhite
" 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 region jsDocType matchgroup=jsDocTypeBrackets start="{" end="}" oneline contained nextgroup=jsDocParam skipwhite contains=jsDocTypeRecord
syntax match jsDocType contained "\%(#\|\"\|\w\|\.\|:\|\/\)\+" nextgroup=jsDocParam skipwhite
syntax region jsDocTypeRecord start=/{/ end=/}/ contained extend contains=jsDocTypeRecord
syntax region jsDocTypeRecord start=/\[/ end=/\]/ contained extend contains=jsDocTypeRecord
syntax region jsDocTypeNoParam start="{" end="}" oneline contained
syntax match jsDocTypeNoParam contained "\%(#\|\"\|\w\|\.\|:\|\/\)\+"
syntax match jsDocParam contained "\%(#\|\$\|-\|'\|\"\|{.\{-}}\|\w\|\.\|:\|\/\|\[.{-}]\|=\)\+"
syntax region jsDocSeeTag contained matchgroup=jsDocSeeTag start="{" end="}" contains=jsDocTags
syntax case match " Modules
endif "" JSDoc end syntax keyword jsModuleKeywords contained import
syntax keyword jsModuleKeywords contained export skipwhite skipempty nextgroup=jsExportBlock,jsModuleDefault
syntax case match syntax keyword jsModuleOperators contained from
syntax keyword jsModuleOperators contained as
"" Syntax in the JavaScript code syntax region jsModuleGroup contained matchgroup=jsModuleBraces start=/{/ end=/}/ contains=jsModuleOperators,jsNoise,jsComment
syntax match jsFuncCall /\k\+\%(\s*(\)\@=/ syntax match jsModuleAsterisk contained /*/
syntax match jsSpecial "\v\\%(0|\\x\x\{2\}\|\\u\x\{4\}\|\c[A-Z]|.)" contained syntax keyword jsModuleDefault contained default skipwhite skipempty nextgroup=@jsExpression
syntax region jsTemplateVar matchgroup=jsTemplateBraces start=+${+ end=+}+ contained contains=@jsExpression syntax region jsImportContainer start=/\<import\> / end="\%(;\|$\)" contains=jsModuleKeywords,jsModuleOperators,jsComment,jsString,jsTemplateString,jsNoise,jsModuleGroup,jsModuleAsterisk
syntax region jsStringD start=+"+ skip=+\\\("\|$\)+ end=+"\|$+ contains=jsSpecial,@htmlPreproc,@Spell syntax region jsExportContainer start=/\<export\> / end="\%(;\|$\)" contains=jsModuleKeywords,jsModuleOperators,jsStorageClass,jsModuleDefault,@jsExpression
syntax region jsStringS start=+'+ skip=+\\\('\|$\)+ end=+'\|$+ contains=jsSpecial,@htmlPreproc,@Spell syntax region jsExportBlock contained matchgroup=jsExportBraces start=/{/ end=/}/ contains=jsModuleOperators,jsNoise,jsComment
syntax region jsTemplateString start=+`+ skip=+\\\(`\|$\)+ end=+`+ contains=jsTemplateVar,jsSpecial,@htmlPreproc
syntax region jsTaggedTemplate start=/\k\+\%([\n\s]\+\)\?`/ end=+`+ contains=jsTemplateString keepend " Strings, Templates, Numbers
syntax region jsRegexpCharClass start=+\[+ skip=+\\.+ end=+\]+ contained syntax region jsString start=+"+ skip=+\\\("\|$\)+ end=+"\|$+ contains=jsSpecial,@Spell extend
syntax match jsRegexpBoundary "\v%(\<@![\^$]|\\[bB])" contained syntax region jsString start=+'+ skip=+\\\('\|$\)+ end=+'\|$+ contains=jsSpecial,@Spell extend
syntax match jsRegexpBackRef "\v\\[1-9][0-9]*" contained syntax region jsTemplateString start=+`+ skip=+\\\(`\|$\)+ end=+`+ contains=jsTemplateVar,jsSpecial extend
syntax match jsRegexpQuantifier "\v\\@<!%([?*+]|\{\d+%(,|,\d+)?})\??" contained syntax match jsTaggedTemplate /\k\+\%(`\)\@=/ nextgroup=jsTemplateString
syntax match jsRegexpOr "\v\<@!\|" contained syntax match jsNumber /\<\d\+\%([eE][+-]\=\d\+\)\=\>\|\<0[bB][01]\+\>\|\<0[oO]\o\+\>\|\<0[xX]\x\+\>/
syntax match jsRegexpMod "\v\(@<=\?[:=!>]" contained
syntax cluster jsRegexpSpecial contains=jsSpecial,jsRegexpBoundary,jsRegexpBackRef,jsRegexpQuantifier,jsRegexpOr,jsRegexpMod
syntax region jsRegexpGroup start="\\\@<!(" skip="\\.\|\[\(\\.\|[^]]\)*\]" end="\\\@<!)" contained contains=jsRegexpCharClass,@jsRegexpSpecial keepend
syntax region jsRegexpString start=+\%(\%(\%(return\|case\)\s\+\)\@50<=\|\%(\%([)\]"']\|\d\|\w\)\s*\)\@50<!\)/\(\*\|/\)\@!+ skip=+\\.\|\[\%(\\.\|[^]]\)*\]+ end=+/[gimy]\{,4}+ contains=jsRegexpCharClass,jsRegexpGroup,@jsRegexpSpecial,@htmlPreproc oneline keepend
syntax match jsNumber /\<-\=\d\+\(L\|[eE][+-]\=\d\+\)\=\>\|\<0[xX]\x\+\>/
syntax keyword jsNumber Infinity syntax keyword jsNumber Infinity
syntax match jsFloat /\<-\=\%(\d\+\.\d\+\|\d\+\.\|\.\d\+\)\%([eE][+-]\=\d\+\)\=\>/ syntax match jsFloat /\<\%(\d\+\.\d\+\|\d\+\.\|\.\d\+\)\%([eE][+-]\=\d\+\)\=\>/
syntax match jsObjectKey /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>\(\s*:\)\@=/ contains=jsFunctionKey contained
syntax match jsFunctionKey /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>\(\s*:\s*function\s*\)\@=/ contained " Regular Expressions
syntax match jsDecorator "@" display contains=jsDecoratorFunction nextgroup=jsDecoratorFunction skipwhite syntax match jsSpecial contained "\v\\%(0|\\x\x\{2\}\|\\u\x\{4\}\|\c[A-Z]|.)"
syntax match jsDecoratorFunction "[a-zA-Z_][a-zA-Z0-9_.]*" display contained nextgroup=jsFunc skipwhite 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
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
else
syntax region jsRegexpString start=+\%(\%(\%(return\|case\)\s\+\)\@<=\|\%(\%([)\]"']\|\d\|\w\)\s*\)\@<!\)/\(\*\|/\)\@!+ skip=+\\.\|\[\%(\\.\|[^]]\)*\]+ end=+/[gimy]\{,4}+ contains=jsRegexpCharClass,jsRegexpGroup,@jsRegexpSpecial oneline keepend extend
endif
syntax cluster jsRegexpSpecial contains=jsSpecial,jsRegexpBoundary,jsRegexpBackRef,jsRegexpQuantifier,jsRegexpOr,jsRegexpMod
" Objects
syntax match jsObjectKey contained /\<[0-9a-zA-Z_$]*\>\(\s*:\)\@=/ contains=jsFunctionKey skipwhite skipempty nextgroup=jsObjectValue
syntax match jsObjectColon contained /:/ skipwhite skipempty
syntax region jsObjectKeyString contained start=+"+ skip=+\\\("\|$\)+ end=+"\|$+ contains=jsSpecial,@Spell skipwhite skipempty nextgroup=jsObjectValue
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 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 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 jsNull null '.(exists('g:javascript_conceal_null') ? 'conceal cchar='.g:javascript_conceal_null : '')
exe 'syntax keyword jsReturn return '.(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 : '')
exe 'syntax keyword jsUndefined undefined '.(exists('g:javascript_conceal_undefined') ? 'conceal cchar='.g:javascript_conceal_undefined : '') 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 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 : '') exe 'syntax keyword jsPrototype prototype '.(exists('g:javascript_conceal_prototype') ? 'conceal cchar='.g:javascript_conceal_prototype : '')
exe 'syntax keyword jsThis this '.(exists('g:javascript_conceal_this') ? 'conceal cchar='.g:javascript_conceal_this : '') exe 'syntax keyword jsThis this '.(exists('g:javascript_conceal_this') ? 'conceal cchar='.g:javascript_conceal_this : '')
exe 'syntax keyword jsStatic static '.(exists('g:javascript_conceal_static') ? 'conceal cchar='.g:javascript_conceal_static : '') exe 'syntax keyword jsSuper super contained '.(exists('g:javascript_conceal_super') ? 'conceal cchar='.g:javascript_conceal_super : '')
exe 'syntax keyword jsSuper super '.(exists('g:javascript_conceal_super') ? 'conceal cchar='.g:javascript_conceal_super : '')
" Statement Keywords
"" Statement Keywords syntax keyword jsStatement contained break continue with yield debugger
syntax keyword jsStatement break continue with syntax keyword jsConditional if skipwhite skipempty nextgroup=jsParenIfElse
syntax keyword jsConditional if else switch syntax keyword jsConditional else skipwhite skipempty nextgroup=jsCommentMisc,jsIfElseBlock
syntax keyword jsRepeat do while for syntax keyword jsConditional switch skipwhite skipempty nextgroup=jsParenSwitch
syntax keyword jsLabel case default syntax keyword jsRepeat while for skipwhite skipempty nextgroup=jsParenRepeat,jsForAwait
syntax keyword jsKeyword yield syntax keyword jsDo do skipwhite skipempty nextgroup=jsRepeatBlock
syntax keyword jsException try catch throw finally 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 keyword jsException throw
syntax keyword jsAsyncKeyword async await syntax keyword jsAsyncKeyword async await
syntax match jsSwitchColon contained /:/ skipwhite skipempty nextgroup=jsSwitchBlock
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 " 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 jsExceptions Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError 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 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?
syntax keyword jsFutureKeys abstract enum int short boolean interface byte long char final native synchronized float package throws goto private transient implements protected volatile double public
syntax keyword jsFutureKeys abstract enum int short boolean interface byte long char final native synchronized float package throws goto private transient debugger implements protected volatile double public " DISCUSS: Should we really be matching stuff like this?
"" DOM/HTML/CSS specified things
" DOM2 Objects " DOM2 Objects
syntax keyword jsGlobalObjects DOMImplementation DocumentFragment Document Node NodeList NamedNodeMap CharacterData Attr Element Text Comment CDATASection DocumentType Notation Entity EntityReference ProcessingInstruction syntax keyword jsGlobalObjects DOMImplementation DocumentFragment Document Node NodeList NamedNodeMap CharacterData Attr Element Text Comment CDATASection DocumentType Notation Entity EntityReference ProcessingInstruction
syntax keyword jsExceptions DOMException syntax keyword jsExceptions DOMException
" DISCUSS: Should we really be matching stuff like this?
" DOM2 CONSTANT " DOM2 CONSTANT
syntax keyword jsDomErrNo INDEX_SIZE_ERR DOMSTRING_SIZE_ERR HIERARCHY_REQUEST_ERR WRONG_DOCUMENT_ERR INVALID_CHARACTER_ERR NO_DATA_ALLOWED_ERR NO_MODIFICATION_ALLOWED_ERR NOT_FOUND_ERR NOT_SUPPORTED_ERR INUSE_ATTRIBUTE_ERR INVALID_STATE_ERR SYNTAX_ERR INVALID_MODIFICATION_ERR NAMESPACE_ERR INVALID_ACCESS_ERR syntax keyword jsDomErrNo INDEX_SIZE_ERR DOMSTRING_SIZE_ERR HIERARCHY_REQUEST_ERR WRONG_DOCUMENT_ERR INVALID_CHARACTER_ERR NO_DATA_ALLOWED_ERR NO_MODIFICATION_ALLOWED_ERR NOT_FOUND_ERR NOT_SUPPORTED_ERR INUSE_ATTRIBUTE_ERR INVALID_STATE_ERR SYNTAX_ERR INVALID_MODIFICATION_ERR NAMESPACE_ERR INVALID_ACCESS_ERR
syntax keyword jsDomNodeConsts ELEMENT_NODE ATTRIBUTE_NODE TEXT_NODE CDATA_SECTION_NODE ENTITY_REFERENCE_NODE ENTITY_NODE PROCESSING_INSTRUCTION_NODE COMMENT_NODE DOCUMENT_NODE DOCUMENT_TYPE_NODE DOCUMENT_FRAGMENT_NODE NOTATION_NODE syntax keyword jsDomNodeConsts ELEMENT_NODE ATTRIBUTE_NODE TEXT_NODE CDATA_SECTION_NODE ENTITY_REFERENCE_NODE ENTITY_NODE PROCESSING_INSTRUCTION_NODE COMMENT_NODE DOCUMENT_NODE DOCUMENT_TYPE_NODE DOCUMENT_FRAGMENT_NODE NOTATION_NODE
" DISCUSS: Should we really be special matching on these props?
" HTML events and internal variables " HTML events and internal variables
syntax case ignore
syntax keyword jsHtmlEvents onblur onclick oncontextmenu ondblclick onfocus onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup onresize syntax keyword jsHtmlEvents onblur onclick oncontextmenu ondblclick onfocus onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup onresize
syntax case match
" Follow stuff should be highligh within a special context " Code blocks
" While it can't be handled with context depended with Regex based highlight syntax region jsBracket matchgroup=jsBrackets start=/\[/ end=/\]/ contains=@jsExpression extend fold
" So, turn it off by default syntax region jsParen matchgroup=jsParens start=/(/ end=/)/ contains=@jsAll extend fold
if exists("javascript_enable_domhtmlcss") 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
" DOM2 things syntax region jsParenRepeat contained matchgroup=jsParensRepeat start=/(/ end=/)/ contains=@jsAll skipwhite skipempty nextgroup=jsCommentMisc,jsRepeatBlock extend fold
syntax match jsDomElemAttrs contained /\%(nodeName\|nodeValue\|nodeType\|parentNode\|childNodes\|firstChild\|lastChild\|previousSibling\|nextSibling\|attributes\|ownerDocument\|namespaceURI\|prefix\|localName\|tagName\)\>/ syntax region jsParenSwitch contained matchgroup=jsParensSwitch start=/(/ end=/)/ contains=@jsAll skipwhite skipempty nextgroup=jsSwitchBlock extend fold
syntax match jsDomElemFuncs contained /\%(insertBefore\|replaceChild\|removeChild\|appendChild\|hasChildNodes\|cloneNode\|normalize\|isSupported\|hasAttributes\|getAttribute\|setAttribute\|removeAttribute\|getAttributeNode\|setAttributeNode\|removeAttributeNode\|getElementById\|getElementsByClassName\|getElementsByTagName\|querySelector\|querySelectorAll\|getAttributeNS\|setAttributeNS\|removeAttributeNS\|getAttributeNodeNS\|setAttributeNodeNS\|getElementsByTagNameNS\|hasAttribute\|hasAttributeNS\)\>/ nextgroup=jsParen skipwhite syntax region jsParenCatch contained matchgroup=jsParensCatch start=/(/ end=/)/ skipwhite skipempty nextgroup=jsTryCatchBlock extend fold
" HTML things syntax region jsFuncArgs contained matchgroup=jsFuncParens start=/(/ end=/)/ contains=jsFuncArgCommas,jsComment,jsFuncArgExpression,jsDestructuringBlock,jsRestExpression,jsFlowArgumentDef skipwhite skipempty nextgroup=jsCommentFunction,jsFuncBlock,jsFlowReturn extend fold
syntax match jsHtmlElemAttrs contained /\%(className\|clientHeight\|clientLeft\|clientTop\|clientWidth\|dir\|id\|innerHTML\|lang\|length\|offsetHeight\|offsetLeft\|offsetParent\|offsetTop\|offsetWidth\|scrollHeight\|scrollLeft\|scrollTop\|scrollWidth\|style\|tabIndex\|title\)\>/ syntax region jsClassBlock contained matchgroup=jsClassBraces start=/{/ end=/}/ contains=jsClassFuncName,jsClassMethodType,jsArrowFunction,jsArrowFuncArgs,jsComment,jsGenerator,jsDecorator,jsClassProperty,jsClassPropertyComputed,jsClassStringKey,jsNoise extend fold
syntax match jsHtmlElemFuncs contained /\%(blur\|click\|focus\|scrollIntoView\|addEventListener\|dispatchEvent\|removeEventListener\|item\)\>/ nextgroup=jsParen skipwhite syntax region jsFuncBlock contained matchgroup=jsFuncBraces start=/{/ end=/}/ contains=@jsAll extend fold
syntax region jsIfElseBlock contained matchgroup=jsIfElseBraces start=/{/ end=/}/ contains=@jsAll extend fold
" CSS Styles in JavaScript syntax region jsBlock contained matchgroup=jsBraces start=/{/ end=/}/ contains=@jsAll extend fold
syntax keyword jsCssStyles contained color font fontFamily fontSize fontSizeAdjust fontStretch fontStyle fontVariant fontWeight letterSpacing lineBreak lineHeight quotes rubyAlign rubyOverhang rubyPosition syntax region jsTryCatchBlock contained matchgroup=jsTryCatchBraces start=/{/ end=/}/ contains=@jsAll skipwhite skipempty nextgroup=jsCatch,jsFinally extend fold
syntax keyword jsCssStyles contained textAlign textAlignLast textAutospace textDecoration textIndent textJustify textJustifyTrim textKashidaSpace textOverflowW6 textShadow textTransform textUnderlinePosition syntax region jsFinallyBlock contained matchgroup=jsFinallyBraces start=/{/ end=/}/ contains=@jsAll extend fold
syntax keyword jsCssStyles contained unicodeBidi whiteSpace wordBreak wordSpacing wordWrap writingMode syntax region jsSwitchBlock contained matchgroup=jsSwitchBraces start=/{/ end=/}/ contains=@jsAll,jsLabel,jsSwitchColon extend fold
syntax keyword jsCssStyles contained bottom height left position right top width zIndex syntax region jsRepeatBlock contained matchgroup=jsRepeatBraces start=/{/ end=/}/ contains=@jsAll extend fold
syntax keyword jsCssStyles contained border borderBottom borderLeft borderRight borderTop borderBottomColor borderLeftColor borderTopColor borderBottomStyle borderLeftStyle borderRightStyle borderTopStyle borderBottomWidth borderLeftWidth borderRightWidth borderTopWidth borderColor borderStyle borderWidth borderCollapse borderSpacing captionSide emptyCells tableLayout syntax region jsDestructuringBlock contained matchgroup=jsDestructuringBraces start=/{/ end=/}/ contains=jsDestructuringProperty,jsDestructuringAssignment,jsDestructuringNoise,jsDestructuringPropertyComputed,jsSpreadExpression extend fold
syntax keyword jsCssStyles contained margin marginBottom marginLeft marginRight marginTop outline outlineColor outlineStyle outlineWidth padding paddingBottom paddingLeft paddingRight paddingTop syntax region jsDestructuringArray contained matchgroup=jsDestructuringBraces start=/\[/ end=/\]/ contains=jsDestructuringPropertyValue,jsNoise,jsDestructuringProperty,jsSpreadExpression extend fold
syntax keyword jsCssStyles contained listStyle listStyleImage listStylePosition listStyleType syntax region jsObject matchgroup=jsObjectBraces start=/{/ end=/}/ contains=jsObjectKey,jsObjectKeyString,jsObjectKeyComputed,jsObjectSeparator,jsObjectFuncName,jsObjectMethodType,jsGenerator,jsComment,jsObjectStringKey,jsSpreadExpression,jsDecorator extend fold
syntax keyword jsCssStyles contained background backgroundAttachment backgroundColor backgroundImage backgroundPosition backgroundPositionX backgroundPositionY backgroundRepeat syntax region jsTernaryIf matchgroup=jsTernaryIfOperator start=/?/ end=/\%(:\|[\}]\@=\)/ contains=@jsExpression
syntax keyword jsCssStyles contained clear clip clipBottom clipLeft clipRight clipTop content counterIncrement counterReset cssFloat cursor direction display filter layoutGrid layoutGridChar layoutGridLine layoutGridMode layoutGridType syntax region jsSpreadExpression contained matchgroup=jsSpreadOperator start=/\.\.\./ end=/[,}\]]\@=/ contains=@jsExpression
syntax keyword jsCssStyles contained marks maxHeight maxWidth minHeight minWidth opacity MozOpacity overflow overflowX overflowY verticalAlign visibility zoom cssText syntax region jsRestExpression contained matchgroup=jsRestOperator start=/\.\.\./ end=/[,)]\@=/
syntax keyword jsCssStyles contained scrollbar3dLightColor scrollbarArrowColor scrollbarBaseColor scrollbarDarkShadowColor scrollbarFaceColor scrollbarHighlightColor scrollbarShadowColor scrollbarTrackColor syntax region jsTernaryIf matchgroup=jsTernaryIfOperator start=/?/ end=/\%(:\|[\}]\@=\)/ contains=@jsExpression
" Highlight ways syntax match jsGenerator contained /\*/ skipwhite skipempty nextgroup=jsFuncName,jsFuncArgs
syntax match jsDotNotation "\." nextgroup=jsPrototype,jsDomElemAttrs,jsDomElemFuncs,jsHtmlElemAttrs,jsHtmlElemFuncs syntax match jsFuncName contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>/ skipwhite skipempty nextgroup=jsFuncArgs,jsFlowFunctionGroup
syntax match jsDotNotation "\.style\." nextgroup=jsCssStyles syntax region jsFuncArgExpression contained matchgroup=jsFuncArgOperator start=/=/ end=/[,)]\@=/ contains=@jsExpression extend
endif "DOM/HTML/CSS
"" end DOM/HTML/CSS specified things
"" Code blocks
syntax cluster jsExpression contains=jsComment,jsLineComment,jsBlockComment,jsTaggedTemplate,jsTemplateString,jsStringD,jsStringS,jsRegexpString,jsNumber,jsFloat,jsThis,jsStatic,jsSuper,jsOperator,jsBooleanTrue,jsBooleanFalse,jsNull,jsFunction,jsArrowFunction,jsGlobalObjects,jsExceptions,jsFutureKeys,jsDomErrNo,jsDomNodeConsts,jsHtmlEvents,jsDotNotation,jsBracket,jsParen,jsBlock,jsFuncCall,jsUndefined,jsNan,jsKeyword,jsStorageClass,jsPrototype,jsBuiltins,jsNoise,jsCommonJS,jsImportContainer,jsExportContainer,jsArgsObj,jsDecorator,jsAsyncKeyword,jsClassDefinition,jsArrowFunction,jsArrowFuncArgs
syntax cluster jsAll contains=@jsExpression,jsLabel,jsConditional,jsRepeat,jsReturn,jsStatement,jsTernaryIf,jsException
syntax region jsBracket matchgroup=jsBrackets start="\[" end="\]" contains=@jsAll,jsParensErrB,jsParensErrC,jsBracket,jsParen,jsBlock,@htmlPreproc fold
syntax region jsParen matchgroup=jsParens start="(" end=")" contains=@jsAll,jsOf,jsParensErrA,jsParensErrC,jsParen,jsBracket,jsBlock,@htmlPreproc fold extend
syntax region jsClassBlock matchgroup=jsClassBraces start="{" end="}" contains=jsFuncName,jsClassMethodDefinitions,jsOperator,jsArrowFunction,jsArrowFuncArgs,jsComment,jsBlockComment,jsLineComment contained fold
syntax region jsFuncBlock matchgroup=jsFuncBraces start="{" end="}" contains=@jsAll,jsParensErrA,jsParensErrB,jsParen,jsBracket,jsBlock,@htmlPreproc,jsClassDefinition fold extend
syntax region jsBlock matchgroup=jsBraces start="{" end="}" contains=@jsAll,jsParensErrA,jsParensErrB,jsParen,jsBracket,jsBlock,jsObjectKey,@htmlPreproc,jsClassDefinition fold extend
syntax region jsTernaryIf matchgroup=jsTernaryIfOperator start=+?+ end=+:+ contains=@jsExpression,jsTernaryIf
"" catch errors caused by wrong parenthesis
syntax match jsParensError ")\|}\|\]"
syntax match jsParensErrA contained "\]"
syntax match jsParensErrB contained ")"
syntax match jsParensErrC contained "}"
syntax match jsFuncArgDestructuring contained /\({\|}\|=\|:\|\[\|\]\)/ extend
exe 'syntax match jsFunction /\<function\>/ nextgroup=jsGenerator,jsFuncName,jsFuncArgs skipwhite '.(exists('g:javascript_conceal_function') ? 'conceal cchar='.g:javascript_conceal_function : '')
exe 'syntax match jsArrowFunction /=>/ skipwhite nextgroup=jsFuncBlock contains=jsFuncBraces '.(exists('g:javascript_conceal_arrow_function') ? 'conceal cchar='.g:javascript_conceal_arrow_function : '')
syntax match jsGenerator contained '\*' nextgroup=jsFuncName,jsFuncArgs skipwhite
syntax match jsFuncName contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*/ nextgroup=jsFuncArgs skipwhite
syntax region jsFuncArgs contained matchgroup=jsFuncParens start='(' end=')' contains=jsFuncArgCommas,jsFuncArgRest,jsComment,jsLineComment,jsStringS,jsStringD,jsNumber,jsFuncArgDestructuring,jsArrowFunction,jsParen,jsArrowFuncArgs nextgroup=jsFuncBlock keepend skipwhite skipempty
syntax match jsFuncArgCommas contained ',' syntax match jsFuncArgCommas contained ','
syntax match jsFuncArgRest contained /\%(\.\.\.[a-zA-Z_$][0-9a-zA-Z_$]*\))/ contains=jsFuncArgRestDots syntax keyword jsArguments contained arguments
syntax match jsFuncArgRestDots contained /\.\.\./ syntax keyword jsForAwait contained await skipwhite skipempty nextgroup=jsParenRepeat
" Matches a single keyword argument with no parens " Matches a single keyword argument with no parens
syntax match jsArrowFuncArgs /\k\+\s*\%(=>\)\@=/ skipwhite contains=jsFuncArgs nextgroup=jsArrowFunction extend syntax match jsArrowFuncArgs /\k\+\s*\%(=>\)\@=/ skipwhite contains=jsFuncArgs skipwhite skipempty nextgroup=jsArrowFunction extend
" Matches a series of arguments surrounded in parens " Matches a series of arguments surrounded in parens
syntax match jsArrowFuncArgs /([^()]*)\s*\(=>\)\@=/ skipempty skipwhite contains=jsFuncArgs nextgroup=jsArrowFunction extend syntax match jsArrowFuncArgs /([^()]*)\s*\(=>\)\@=/ contains=jsFuncArgs skipempty skipwhite nextgroup=jsArrowFunction extend
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 : '')
" Classes
syntax keyword jsClassKeywords contained extends class
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 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
syntax region jsClassStringKey contained start=+"+ skip=+\\\("\|$\)+ end=+"\|$+ contains=jsSpecial,@Spell extend skipwhite skipempty nextgroup=jsFuncArgs
syntax region jsClassStringKey contained start=+'+ skip=+\\\('\|$\)+ end=+'\|$+ contains=jsSpecial,@Spell extend skipwhite skipempty nextgroup=jsFuncArgs
" Destructuring
syntax match jsDestructuringPropertyValue contained /\<[0-9a-zA-Z_$]*\>/
syntax match jsDestructuringProperty contained /\<[0-9a-zA-Z_$]*\>\(\s*=\)\@=/ skipwhite skipempty nextgroup=jsDestructuringValue
syntax match jsDestructuringAssignment contained /\<[0-9a-zA-Z_$]*\>\(\s*:\)\@=/ skipwhite skipempty nextgroup=jsDestructuringValueAssignment
syntax region jsDestructuringValue contained start=/=/ end=/[,}\]]\@=/ contains=@jsExpression extend
syntax region jsDestructuringValueAssignment contained start=/:/ end=/[,}=]\@=/ contains=jsDestructuringPropertyValue,jsDestructuringBlock,jsNoise,jsDestructuringNoise skipwhite skipempty nextgroup=jsDestructuringValue extend
syntax match jsDestructuringNoise contained /[,\[\]]/
syntax region jsDestructuringPropertyComputed contained matchgroup=jsBrackets start=/\[/ end=/]/ contains=@jsExpression skipwhite skipempty nextgroup=jsDestructuringValue,jsDestructuringNoise extend fold
" Comments
syntax keyword jsCommentTodo contained TODO FIXME XXX TBD
syntax region jsComment start=/\/\// end=/$/ contains=jsCommentTodo,@Spell extend keepend
syntax region jsComment start=/\/\*/ end=/\*\// contains=jsCommentTodo,@Spell fold extend keepend
syntax region jsEnvComment start=/\%^#!/ end=/$/ display
" Specialized Comments - These are special comment regexes that are used in
" odd places that maintain the proper nextgroup functionality. It sucks we
" can't make jsComment a skippable type of group for nextgroup
syntax region jsCommentFunction contained start=/\/\// end=/$/ contains=jsCommentTodo,@Spell skipwhite skipempty nextgroup=jsFuncBlock,jsFlowReturn extend keepend
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
" Decorators
syntax match jsDecorator /^\s*@/ nextgroup=jsDecoratorFunction
syntax match jsDecoratorFunction contained /[a-zA-Z_][a-zA-Z0-9_.]*/ nextgroup=jsParenDecorator
if exists("javascript_plugin_jsdoc")
runtime extras/jsdoc.vim
" NGDoc requires JSDoc
if exists("javascript_plugin_ngdoc")
runtime extras/ngdoc.vim
endif
endif
syntax keyword jsClassKeywords extends class contained if exists("javascript_plugin_flow")
syntax match jsClassNoise /\./ contained runtime extras/flow.vim
syntax keyword jsClassMethodDefinitions get set static contained nextgroup=jsFuncName skipwhite skipempty endif
syntax match jsClassDefinition /class [a-zA-Z_$][0-9a-zA-Z_$ \n.]*/ contains=jsClassKeywords,jsClassNoise nextgroup=jsClassBlock skipwhite skipempty
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
" Define the default highlighting. " Define the default highlighting.
" For version 5.7 and earlier: only when not done already " For version 5.7 and earlier: only when not done already
@ -227,25 +240,20 @@ if version >= 508 || !exists("did_javascript_syn_inits")
else else
command -nargs=+ HiLink hi def link <args> command -nargs=+ HiLink hi def link <args>
endif endif
HiLink jsFuncArgRest Special
HiLink jsComment Comment HiLink jsComment Comment
HiLink jsLineComment Comment
HiLink jsEnvComment PreProc HiLink jsEnvComment PreProc
HiLink jsBlockComment Comment HiLink jsParensIfElse jsParens
HiLink jsParensRepeat jsParens
HiLink jsParensSwitch jsParens
HiLink jsParensCatch jsParens
HiLink jsCommentTodo Todo HiLink jsCommentTodo Todo
HiLink jsCvsTag Function HiLink jsString String
HiLink jsDocTags Special HiLink jsObjectKeyString String
HiLink jsDocSeeTag Function
HiLink jsDocType Type
HiLink jsDocTypeBrackets jsDocType
HiLink jsDocTypeRecord jsDocType
HiLink jsDocTypeNoParam Type
HiLink jsDocParam Label
HiLink jsStringS String
HiLink jsStringD String
HiLink jsTemplateString String HiLink jsTemplateString String
HiLink jsObjectStringKey String
HiLink jsClassStringKey String
HiLink jsTaggedTemplate StorageClass HiLink jsTaggedTemplate StorageClass
HiLink jsTernaryIfOperator Conditional HiLink jsTernaryIfOperator Operator
HiLink jsRegexpString String HiLink jsRegexpString String
HiLink jsRegexpBoundary SpecialChar HiLink jsRegexpBoundary SpecialChar
HiLink jsRegexpQuantifier SpecialChar HiLink jsRegexpQuantifier SpecialChar
@ -261,28 +269,30 @@ if version >= 508 || !exists("did_javascript_syn_inits")
HiLink jsLabel Label HiLink jsLabel Label
HiLink jsReturn Statement HiLink jsReturn Statement
HiLink jsRepeat Repeat HiLink jsRepeat Repeat
HiLink jsDo Repeat
HiLink jsStatement Statement HiLink jsStatement Statement
HiLink jsException Exception HiLink jsException Exception
HiLink jsKeyword Keyword HiLink jsTry Exception
HiLink jsFinally Exception
HiLink jsCatch Exception
HiLink jsAsyncKeyword Keyword HiLink jsAsyncKeyword Keyword
HiLink jsForAwait Keyword
HiLink jsArrowFunction Type HiLink jsArrowFunction Type
HiLink jsFunction Type HiLink jsFunction Type
HiLink jsGenerator jsFunction HiLink jsGenerator jsFunction
HiLink jsArrowFuncArgs jsFuncArgs HiLink jsArrowFuncArgs jsFuncArgs
HiLink jsFuncName Function HiLink jsFuncName Function
HiLink jsArgsObj Special HiLink jsClassFuncName jsFuncName
HiLink jsObjectFuncName Function
HiLink jsArguments Special
HiLink jsError Error HiLink jsError Error
HiLink jsParensError Error HiLink jsParensError Error
HiLink jsParensErrA Error
HiLink jsParensErrB Error
HiLink jsParensErrC Error
HiLink jsOperator Operator HiLink jsOperator Operator
HiLink jsOf Operator HiLink jsOf Operator
HiLink jsStorageClass StorageClass HiLink jsStorageClass StorageClass
HiLink jsClassKeywords Structure HiLink jsClassKeywords Keyword
HiLink jsThis Special HiLink jsThis Special
HiLink jsStatic Special HiLink jsSuper Constant
HiLink jsSuper Special
HiLink jsNan Number HiLink jsNan Number
HiLink jsNull Type HiLink jsNull Type
HiLink jsUndefined Type HiLink jsUndefined Type
@ -290,6 +300,7 @@ if version >= 508 || !exists("did_javascript_syn_inits")
HiLink jsFloat Float HiLink jsFloat Float
HiLink jsBooleanTrue Boolean HiLink jsBooleanTrue Boolean
HiLink jsBooleanFalse Boolean HiLink jsBooleanFalse Boolean
HiLink jsObjectColon jsNoise
HiLink jsNoise Noise HiLink jsNoise Noise
HiLink jsBrackets Noise HiLink jsBrackets Noise
HiLink jsParens Noise HiLink jsParens Noise
@ -298,18 +309,47 @@ if version >= 508 || !exists("did_javascript_syn_inits")
HiLink jsFuncParens Noise HiLink jsFuncParens Noise
HiLink jsClassBraces Noise HiLink jsClassBraces Noise
HiLink jsClassNoise Noise HiLink jsClassNoise Noise
HiLink jsIfElseBraces jsBraces
HiLink jsTryCatchBraces jsBraces
HiLink jsModuleBraces jsBraces
HiLink jsObjectBraces Noise
HiLink jsObjectSeparator Noise
HiLink jsFinallyBraces jsBraces
HiLink jsRepeatBraces jsBraces
HiLink jsSwitchBraces jsBraces
HiLink jsExportBraces jsBraces
HiLink jsSpecial Special HiLink jsSpecial Special
HiLink jsTemplateVar Special HiLink jsTemplateVar Special
HiLink jsTemplateBraces jsBraces HiLink jsTemplateBraces jsBraces
HiLink jsGlobalObjects Special HiLink jsGlobalObjects Constant
HiLink jsExceptions Special HiLink jsGlobalNodeObjects Constant
HiLink jsFutureKeys Special HiLink jsExceptions Constant
HiLink jsBuiltins Special HiLink jsBuiltins Constant
HiLink jsModules Include HiLink jsModuleKeywords Include
HiLink jsModuleWords Include HiLink jsModuleOperators Include
HiLink jsModuleDefault Include
HiLink jsDecorator Special HiLink jsDecorator Special
HiLink jsFuncArgRestDots Noise HiLink jsDecoratorFunction Function
HiLink jsFuncArgDestructuring Noise HiLink jsParensDecorator jsParens
HiLink jsFuncArgOperator jsFuncArgs
HiLink jsModuleAsterisk Noise
HiLink jsClassProperty jsObjectKey
HiLink jsSpreadOperator Operator
HiLink jsRestOperator Operator
HiLink jsRestExpression jsFuncArgs
HiLink jsSwitchColon Noise
HiLink jsClassMethodType Type
HiLink jsObjectMethodType Type
HiLink jsClassDefinition jsFuncName
HiLink jsDestructuringBraces Noise
HiLink jsDestructuringProperty jsFuncArgs
HiLink jsDestructuringAssignment jsObjectKey
HiLink jsDestructuringNoise Noise
HiLink jsCommentFunction jsComment
HiLink jsCommentClass jsComment
HiLink jsCommentMisc jsComment
HiLink jsDomErrNo Constant HiLink jsDomErrNo Constant
HiLink jsDomNodeConsts Constant HiLink jsDomNodeConsts Constant
@ -322,14 +362,12 @@ if version >= 508 || !exists("did_javascript_syn_inits")
HiLink jsCssStyles Label HiLink jsCssStyles Label
HiLink jsClassMethodDefinitions Type
delcommand HiLink delcommand HiLink
endif endif
" Define the htmlJavaScript for HTML syntax html.vim " Define the htmlJavaScript for HTML syntax html.vim
syntax cluster htmlJavaScript contains=@jsAll,jsBracket,jsParen,jsBlock syntax cluster htmlJavaScript contains=@jsAll
syntax cluster javaScriptExpression contains=@jsAll,jsBracket,jsParen,jsBlock,@htmlPreproc syntax cluster javaScriptExpression contains=@jsAll
" Vim's default html.vim highlights all javascript as 'Special' " Vim's default html.vim highlights all javascript as 'Special'
hi! def link javaScript NONE hi! def link javaScript NONE

Loading…
Cancel
Save