FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add parameter highlighting for ES2015’s arrow functions. by savetheclocktower · Pull Request #62 · textmate/javascript.tmbundle · GitHub

Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .plist  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
117 changes: 112 additions & 5 deletions Syntaxes/JavaScript.plist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,104 @@
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>(?x)
(?:([_$a-zA-Z][$\w]*)\s*(=)\s*)? # optional assignment to identifier
(?= # lookahead to:
(\( # open parenthesis
(?&gt;(?&gt;[^()]+)|\g&lt;-1&gt;)* # anything except parens (atomic)
\)) # close parenthesis
\s* # optional space
(=&gt;) # arrow
)
</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>entity.name.function.js</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>keyword.operator.assignment.js</string>
</dict>
</dict>
<key>comment</key>
<string>
Arrow function.
https://www.ecma-international.org/ecma-262/6.0/#sec-arrow-function-definitions
</string>
<key>end</key>
<string>(?&lt;=\))\s*(=&gt;)</string>
<key>name</key>
<string>meta.function.js</string>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>\G\(</string>
<key>name</key>
<string>punctuation.definition.parameters.begin.js</string>
</dict>
<dict>
<key>match</key>
<string>\)(?=\s*=&gt;)</string>
<key>name</key>
<string>punctuation.definition.parameters.end.js</string>
</dict>
<dict>
<key>include</key>
<string>#function-params</string>
</dict>
</array>
</dict>
<dict>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>entity.name.function.js</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>keyword.operator.assignment.js</string>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>keyword.control.js</string>
</dict>
<key>4</key>
<dict>
<key>name</key>
<string>variable.parameter.function.js</string>
</dict>
<key>5</key>
<dict>
<key>name</key>
<string>storage.type.function.arrow.js</string>
</dict>
</dict>
<key>comment</key>
<string>
Arrow function, but without parentheses delimiting the parameters. Only valid when there is exactly one parameter without a default value.
https://www.ecma-international.org/ecma-262/6.0/#sec-arrow-function-definitions
</string>
<key>match</key>
<string>(?x)
(?:([_$a-zA-Z][$\w]*)\s*(=)\s*)? # optional assignment to identifier
(?:(async)\s+)? # optional "async" annotation
\b([_$a-zA-Z][$\w]*) # single parameter name
\s*(=&gt;) # optional space and arrow
</string>
<key>name</key>
<string>meta.function.js</string>
</dict>
<dict>
<key>begin</key>
<string>(?&lt;=[\[=(?:+,!]|^|return|=&gt;|&amp;&amp;|\|\|)\s*(?=/[^/*+?].*/)</string>
Expand Down Expand Up @@ -731,7 +829,7 @@
<key>comment</key>
<string>Matching as a capture group prevents false positives with other uses of :</string>
<key>end</key>
<string>([^:"'`\[\]{}()]*)(:)</string>
<string>([^:"`\[\]{}()]*)(:)</string>
<key>endCaptures</key>
<dict>
<key>1</key>
Expand Down Expand Up @@ -1008,10 +1106,8 @@
<string>invalid.illegal.js</string>
</dict>
<dict>
<key>match</key>
<string>\b(false|Infinity|NaN|null|true|undefined)\b</string>
<key>name</key>
<string>constant.language.js</string>
<key>include</key>
<string>#constants</string>
</dict>
<dict>
<key>match</key>
Expand Down Expand Up @@ -1239,6 +1335,13 @@
</dict>
</array>
</dict>
<key>constants</key>
<dict>
<key>match</key>
<string>\b(false|Infinity|NaN|null|true|undefined)\b</string>
<key>name</key>
<string>constant.language.js</string>
</dict>
<key>function-call</key>
<dict>
<key>patterns</key>
Expand Down Expand Up @@ -1316,6 +1419,10 @@
<key>include</key>
<string>#numbers</string>
</dict>
<dict>
<key>include</key>
<string>#constants</string>
</dict>
<dict>
<key>include</key>
<string>#strings</string>
Expand Down

Back | FazBrowse Home | New Git URL