# [PackageDev] target_format: plist, ext: tmLanguage name: JavaScript Next scopeName: source.js.es6 fileTypes: [js, htc, jsx] uuid: 487CF323-A3F9-48FA-B140-DCE8C893E664 firstLineMatch: ^#!/.*\b(node|js)$\n? keyEquivalent: ^~J patterns: - include: '#core' repository: core: patterns: - include: '#literal-function-labels' - include: '#literal-arrow-function-labels' - include: '#literal-labels' - include: '#literal-keywords' - include: '#literal-for' - include: '#literal-switch' - include: '#expression' - include: '#literal-punctuation' expression: patterns: - include: '#support' - include: '#literal-function' - include: '#literal-arrow-function' - include: '#literal-prototype' # after literal-function, which includes some prototype strings - include: '#literal-regexp' # before operators to avoid ambiguities - include: '#literal-number' - include: '#literal-quasi' - include: '#literal-string' - include: '#literal-language-constant' - include: '#literal-language-variable' - include: '#literal-method' - include: '#literal-module' - include: '#literal-class' - include: '#literal-constructor' - include: '#literal-method-call' - include: '#literal-function-call' - include: '#comments' - include: '#brackets' - include: '#literal-operators' - include: '#literal-variable' round-brackets: patterns: - name: meta.group.braces.round begin: \( beginCaptures: '0': {name: meta.brace.round.js} end: \) endCaptures: '0': {name: meta.brace.round.js} patterns: - include: '#expression' square-brackets: patterns: - name: meta.group.braces.square begin: \[ beginCaptures: '0': {name: meta.brace.square.js} end: \] endCaptures: '0': {name: meta.brace.square.js} patterns: - include: '#expression' curly-brackets: patterns: - name: meta.group.braces.curly begin: \{ beginCaptures: '0': {name: meta.brace.curly.js} end: \} endCaptures: '0': {name: meta.brace.curly.js} patterns: - include: $self brackets: patterns: - include: '#round-brackets' - include: '#square-brackets' - include: '#curly-brackets' comments: patterns: - include: '#special-comments-conditional-compilation' - name: comment.block.documentation.js begin: /\*\*(?!/) end: \*/ captures: '0': {name: punctuation.definition.comment.js} - name: comment.block.js begin: /\* end: \*/ captures: '0': {name: punctuation.definition.comment.js} - name: comment.block.html.js match: () captures: '0': {name: punctuation.definition.comment.js} - name: comment.line.double-slash.js match: (//).*$\n? captures: '1': {name: punctuation.definition.comment.js} - name: comment.line.shebang.js match: ^(#!).*$\n? captures: '1': {name: punctuation.definition.comment.js} special-comments-conditional-compilation: patterns: - name: comment.block.conditional.js begin: /\*(?=@) end: \*/ endCaptures: '1': {name: keyword.control.conditional.js} '2': {name: punctuation.definition.keyword.js} captures: '0': {name: punctuation.definition.comment.js} patterns: - name: punctuation.definition.comment.js match: /\* - include: $self - name: keyword.control.conditional.js match: (@)(if|elif|else|end|ifdef|endif|cc_on|set)\b captures: '1': {name: punctuation.definition.keyword.js} - name: variable.other.conditional.js match: (@)(_win32|_win16|_mac|_alpha|_x86|_mc680x0|_PowerPC|_jscript|_jscript_build|_jscript_version|_debug|_fast|[a-zA-Z]\w+) captures: '1': {name: punctuation.definition.variable.js} function-declaration-parameters: patterns: - begin: \( beginCaptures: '0': {name: punctuation.definition.parameters.begin.js} end: \) endCaptures: '0': {name: punctuation.definition.parameters.end.js} patterns: - name: keyword.operator.spread.js match: (?- (?x) (?- (?x) (?:\b(static)\s+)? (?:\b(async)\s+)? (?:(\*)\s*)?([_$a-zA-Z][$\w]*)\s* (?=\([^())]*\)(?:\s|/\*.*\*/)*\{) beginCaptures: '1': {name: storage.type.js} '2': {name: storage.type.js} '3': {name: keyword.generator.asterisk.js} '4': {name: entity.name.method.js} end: (?<=\)) patterns: - include: '#function-declaration-parameters' # getter/setter - name: meta.accessor.js begin: >- (?x) \b(?:(static)\s+)? (get|set)\s+ ([_$a-zA-Z][$\w]*)\s* (?=\([^())]*\)(?:\s|/\*.*\*/)*\{) beginCaptures: '1': {name: storage.type.js} '2': {name: storage.type.accessor.js} '3': {name: entity.name.accessor.js} end: (?<=\)) patterns: - include: '#function-declaration-parameters' literal-prototype: patterns: # e.g. Sound.prototype - name: meta.prototype.access.js match: ([_$a-zA-Z][$\w]*)(\.)(prototype)\b captures: '1': {name: entity.name.class.js} '2': {name: keyword.operator.accessor.js} '3': {name: variable.language.prototype.js} # e.g. Sound.prototype = { } when extending an object - name: meta.prototype.declaration.js match: ([_$a-zA-Z][$\w]*)(\.)(prototype)\s*=\s* captures: '1': {name: entity.name.class.js} '2': {name: keyword.operator.accessor.js} '3': {name: variable.language.prototype.js} literal-function: patterns: # e.g. function play(arg1, arg2) { } - name: meta.function.js begin: >- (?x) (?:\b(async)\s+)? \s*(function)(?:\s*(\*)|(?=\s|[(])) \s*([_$a-zA-Z][$\w]*)?\s* beginCaptures: '1': {name: storage.type.js} '2': {name: storage.type.function.js} '3': {name: keyword.generator.asterisk.js} '4': {name: entity.name.function.js} end: (?<=\)) patterns: - include: '#function-declaration-parameters' # e.g. play = function(arg1, arg2) { } - name: meta.function.js begin: >- (?x) (\b[_$a-zA-Z][$\w]*) \s*= \s*(?:(async)\s+)? \s*(function)(?:\s*(\*)|(?=\s|[(])) \s*([_$a-zA-Z][$\w]*)?\s* beginCaptures: '1': {name: entity.name.function.js} '2': {name: storage.type.js} '3': {name: storage.type.function.js} '4': {name: keyword.generator.asterisk.js} '5': {name: entity.name.function.js} end: (?<=\)) patterns: - include: '#function-declaration-parameters' # e.g. Sound.prototype.play = function(arg1, arg2) { } - name: meta.prototype.function.js begin: >- (?x) (\b_?[A-Z][$\w]*)? (\.)(prototype) (\.)([_$a-zA-Z][$\w]*) \s*= \s*(?:(async)\s+)? \s*(function)(?:\s*(\*)|(?=\s|[(])) \s*([_$a-zA-Z][$\w]*)?\s* beginCaptures: '1': {name: entity.name.class.js} '2': {name: keyword.operator.accessor.js} '3': {name: variable.language.prototype.js} '4': {name: keyword.operator.accessor.js} '5': {name: entity.name.function.js} '6': {name: storage.type.js} '7': {name: storage.type.function.js} '8': {name: keyword.generator.asterisk.js} '9': {name: entity.name.function.js} end: (?<=\)) patterns: - include: '#function-declaration-parameters' # e.g. Sound.play = function(arg1, arg2) { } - name: meta.function.static.js begin: >- (?x) (\b_?[A-Z][$\w]*)? (\.)([_$a-zA-Z][$\w]*) \s*= \s*(?:(async)\s+)? \s*(function)(?:\s*(\*)|(?=\s|[(])) \s*([_$a-zA-Z][$\w]*)?\s* beginCaptures: '1': {name: entity.name.class.js} '2': {name: keyword.operator.accessor.js} '3': {name: entity.name.function.js} '4': {name: storage.type.js} '5': {name: storage.type.function.js} '6': {name: keyword.generator.asterisk.js} '7': {name: entity.name.function.js} end: (?<=\)) patterns: - include: '#function-declaration-parameters' literal-function-labels: patterns: # e.g. play: function(arg1, arg2) { } - name: meta.function.json.js begin: >- (?x) \b([_$a-zA-Z][$\w]*) \s*(:) \s*(?:(async)\s+)? \s*(function)(?:\s*(\*)|(?=\s|[(])) \s*([_$a-zA-Z][$\w]*)?\s* beginCaptures: '1': {name: entity.name.function.js} '2': {name: punctuation.separator.key-value.js} '3': {name: storage.type.js} '4': {name: storage.type.function.js} '5': {name: keyword.generator.asterisk.js} '6': {name: entity.name.function.js} end: (?<=\)) patterns: - include: '#function-declaration-parameters' # e.g. "play": function(arg1, arg2) { } - name: meta.function.json.js begin: >- (?x) (?: ((')((?:[^']|\\')*)('))| ((")((?:[^"]|\\")*)(")) ) \s*(:) \s*(?:(async)\s+)? \s*(function)(?:\s*(\*)|(?=\s|[(])) \s*([_$a-zA-Z][$\w]*)?\s* beginCaptures: '1': {name: string.quoted.single.js} '2': {name: punctuation.definition.string.begin.js} '3': {name: entity.name.function.js} '4': {name: punctuation.definition.string.end.js} '5': {name: string.quoted.double.js} '6': {name: punctuation.definition.string.begin.js} '7': {name: entity.name.function.js} '8': {name: punctuation.definition.string.end.js} '9': {name: punctuation.separator.key-value.js} '10': {name: storage.type.js} '11': {name: storage.type.function.js} '12': {name: keyword.generator.asterisk.js} '13': {name: entity.name.function.js} end: (?<=\)) patterns: - include: '#function-declaration-parameters' literal-arrow-function: patterns: # e.g. (args) => { } - name: meta.function.arrow.js begin: >- (?x) (\basync)?\s* (?=\([^()]*\)\s*(=>)) beginCaptures: '1': {name: storage.type.js} end: (?<=\))\s*(=>) endCaptures: '1': {name: storage.type.function.arrow.js} patterns: - include: '#function-declaration-parameters' # e.g. arg => { } - name: meta.function.arrow.js match: >- (?x) (\basync)?\s* \b([_$a-zA-Z][$\w]*)\s*(=>) captures: '1': {name: storage.type.js} '2': {name: variable.parameter.function.js} '3': {name: storage.type.function.arrow.js} # e.g. play = (args) => { } - name: meta.function.arrow.js begin: >- (?x) (\b[_$a-zA-Z][$\w]*) \s*= \s*(async)? \s*(?=\([^()]*\)\s*(=>)) beginCaptures: '1': {name: entity.name.function.js} '2': {name: storage.type.js} end: (?<=\))\s*(=>) endCaptures: '1': {name: storage.type.function.arrow.js} patterns: - include: '#function-declaration-parameters' # e.g. play = arg => { } - name: meta.function.arrow.js match: >- (?x) (\b[_$a-zA-Z][$\w]*) \s*= \s*(async)? \s*\b([_$a-zA-Z][$\w]*)\s*(=>) captures: '1': {name: entity.name.function.js} '2': {name: storage.type.js} '3': {name: variable.parameter.function.js} '4': {name: storage.type.function.arrow.js} # e.g. Sound.prototype.play = (args) => { } - name: meta.prototype.function.arrow.js begin: >- (?x) (\b_?[A-Z][$\w]*)? (\.)(prototype) (\.)([_$a-zA-Z][$\w]*) \s*= \s*(async)? \s*(?=\([^()]*\)\s*(=>)) beginCaptures: '1': {name: entity.name.class.js} '2': {name: keyword.operator.accessor.js} '3': {name: variable.language.prototype.js} '4': {name: keyword.operator.accessor.js} '5': {name: entity.name.function.js} '6': {name: storage.type.js} end: (?<=\))\s*(=>) endCaptures: '1': {name: storage.type.function.arrow.js} patterns: - include: '#function-declaration-parameters' # e.g. Sound.prototype.play = arg => { } - name: meta.prototype.function.arrow.js match: >- (?x) (\b_?[A-Z][$\w]*)? (\.)(prototype) (\.)([_$a-zA-Z][$\w]*) \s*= \s*(async)? \s*\b([_$a-zA-Z][$\w]*)\s*(=>) captures: '1': {name: entity.name.class.js} '2': {name: keyword.operator.accessor.js} '3': {name: variable.language.prototype.js} '4': {name: keyword.operator.accessor.js} '5': {name: entity.name.function.js} '6': {name: storage.type.js} '7': {name: variable.parameter.function.js} '8': {name: storage.type.function.arrow.js} # e.g. Sound.play = (args) => { } - name: meta.function.static.arrow.js begin: >- (?x) (\b_?[A-Z][$\w]*)? (\.)([_$a-zA-Z][$\w]*) \s*= \s*(async)? \s*(?=\([^()]*\)\s*(=>)) beginCaptures: '1': {name: entity.name.class.js} '2': {name: keyword.operator.accessor.js} '3': {name: entity.name.function.js} '4': {name: storage.type.js} end: (?<=\))\s*(=>) endCaptures: '1': {name: storage.type.function.arrow.js} patterns: - include: '#function-declaration-parameters' # e.g. Sound.play = arg => { } - name: meta.function.static.arrow.js match: >- (?x) (\b_?[A-Z][$\w]*)? (\.)([_$a-zA-Z][$\w]*) \s*= \s*(async)? \s*\b([_$a-zA-Z][$\w]*)\s*(=>) captures: '1': {name: entity.name.class.js} '2': {name: keyword.operator.accessor.js} '3': {name: entity.name.function.js} '4': {name: storage.type.js} '5': {name: variable.parameter.function.js} '6': {name: storage.type.function.arrow.js} literal-arrow-function-labels: patterns: # e.g. play: (args) => { } - name: meta.function.json.arrow.js begin: >- (?x) \b([_$a-zA-Z][$\w]*) \s*(:) \s*(async)? \s*(?=\([^()]*\)\s*(=>)) beginCaptures: '1': {name: entity.name.function.js} '2': {name: punctuation.separator.key-value.js} '3': {name: storage.type.js} end: (?<=\))\s*(=>) endCaptures: '1': {name: storage.type.function.arrow.js} patterns: - include: '#function-declaration-parameters' # e.g. play: arg => { } - name: meta.function.json.arrow.js match: >- (?x) \b([_$a-zA-Z][$\w]*) \s*(:) \s*(async)? \s*\b([_$a-zA-Z][$\w]*)\s*(=>) captures: '1': {name: entity.name.function.js} '2': {name: punctuation.separator.key-value.js} '3': {name: storage.type.js} '4': {name: variable.parameter.function.js} '5': {name: storage.type.function.arrow.js} # e.g. "play": (args) => { } - name: meta.function.json.arrow.js begin: >- (?x) (?: ((')((?:[^']|\\')*)('))| ((")((?:[^"]|\\")*)(")) ) \s*(:) \s*(async)? \s*(?=\([^()]*\)\s*(=>)) beginCaptures: '1': {name: string.quoted.single.js} '2': {name: punctuation.definition.string.begin.js} '3': {name: entity.name.function.js} '4': {name: punctuation.definition.string.end.js} '5': {name: string.quoted.double.js} '6': {name: punctuation.definition.string.begin.js} '7': {name: entity.name.function.js} '8': {name: punctuation.definition.string.end.js} '9': {name: punctuation.separator.key-value.js} '10': {name: storage.type.js} end: (?<=\))\s*(=>) endCaptures: '1': {name: storage.type.function.arrow.js} patterns: - include: '#function-declaration-parameters' # e.g. "play": arg => { } - name: meta.function.json.arrow.js match: >- (?x) (?: ((')((?:[^']|\\')*)('))| ((")((?:[^"]|\\")*)(")) ) \s*(:) \s*(async)? \s*\b([_$a-zA-Z][$\w]*)\s*(=>) captures: '1': {name: string.quoted.single.js} '2': {name: punctuation.definition.string.begin.js} '3': {name: entity.name.function.js} '4': {name: punctuation.definition.string.end.js} '5': {name: string.quoted.double.js} '6': {name: punctuation.definition.string.begin.js} '7': {name: entity.name.function.js} '8': {name: punctuation.definition.string.end.js} '9': {name: punctuation.separator.key-value.js} '10': {name: storage.type.js} '11': {name: variable.parameter.function.js} '12': {name: storage.type.function.arrow.js} literal-function-call: patterns: - name: meta.function-call.without-arguments.js match: >- (?x) ([_$a-zA-Z][$\w]*)\s* (\(\s*\)) captures: '1': {name: entity.name.function.js} '2': {name: meta.group.braces.round.function.arguments.js} - name: meta.function-call.with-arguments.js match: >- (?x) ([_$a-zA-Z][$\w]*)\s* (?=\() captures: '1': {name: entity.name.function.js} literal-method-call: patterns: - name: meta.function-call.static.without-arguments.js match: >- (?x) (?:(?<=\.)|\b) ([A-Z][$\w]*)\s*(\.) ([_$a-zA-Z][$\w]*)\s* (\(\s*\)) captures: '1': {name: variable.other.class.js} '2': {name: keyword.operator.accessor.js} '3': {name: entity.name.function.js} '4': {name: meta.group.braces.round.function.arguments.js} - name: meta.function-call.static.with-arguments.js match: >- (?x) (?:(?<=\.)|\b) ([A-Z][$\w]*)\s*(\.) ([_$a-zA-Z][$\w]*)\s* (?=\() captures: '1': {name: variable.other.class.js} '2': {name: keyword.operator.accessor.js} '3': {name: entity.name.function.js} - name: meta.function-call.method.without-arguments.js match: >- (?x) (?<=\.) ([_$a-zA-Z][$\w]*)\s* (\(\s*\)) captures: '1': {name: entity.name.function.js} '2': {name: meta.group.braces.round.function.arguments.js} - name: meta.function-call.method.with-arguments.js match: >- (?x) (?<=\.) ([_$a-zA-Z][$\w]*)\s* (?=\() captures: '1': {name: entity.name.function.js} literal-language-variable: patterns: - name: variable.language.arguments.js match: (?- (?x) !(?!=)| # logical-not right-to-left right && | # logical-and left-to-right both \|\| | # logical-or left-to-right both - name: keyword.operator.assignment.js match: >- (?x) =(?!=)| # assignment right-to-left both - name: keyword.operator.assignment.augmented.js match: >- (?x) %= | # assignment right-to-left both &= | # assignment right-to-left both \*= | # assignment right-to-left both \+= | # assignment right-to-left both -= | # assignment right-to-left both /= | # assignment right-to-left both \^= | # assignment right-to-left both \|= | # assignment right-to-left both <<= | # assignment right-to-left both >>= | # assignment right-to-left both >>>= | # assignment right-to-left both - name: keyword.operator.bitwise.js match: >- (?x) ~ | # bitwise-not right-to-left right << | # bitwise-shift left-to-right both >>> | # bitwise-shift left-to-right both >> | # bitwise-shift left-to-right both & | # bitwise-and left-to-right both \^ | # bitwise-xor left-to-right both \| # bitwise-or left-to-right both - name: keyword.operator.relational.js match: >- (?x) <= | # relational left-to-right both >= | # relational left-to-right both < | # relational left-to-right both > # relational left-to-right both - name: keyword.operator.comparison.js match: >- (?x) === | # equality left-to-right both !== | # equality left-to-right both == | # equality left-to-right both != # equality left-to-right both - name: keyword.operator.arithmetic.js match: >- (?x) -- | # decrement n/a right-or-left \+\+ | # increment n/a right-or-left / | # division left-to-right both % | # modulus left-to-right both \* | # multiplication left-to-right both \+ | # addition left-to-right both - # subtraction left-to-right both - name: keyword.operator.ternary.js match: '\?|:' - name: keyword.operator.spread.js match: (?- (?x) (?- (?xi) (?:\B[-+])? (?: \b0b[0-1]*| # binary \b0o[0-7]*| # octal \b0x[0-9a-f]*| # hex ( \B\.[0-9]+| # e.g. .999 \b[0-9]+(\.[0-9]*)? # e.g. 999.999, 999. or 999 )(e[-+]?[0-9]+)? # e.g. e+123, E-123 ) - name: constant.language.infinity.js match: (?:\B[-+]|\b)(Infinity)\b literal-punctuation: patterns: - name: punctuation.terminator.statement.js match: \; - name: meta.delimiter.comma.js match: ',' literal-quasi: patterns: - name: string.quasi.js begin: ([a-zA-Z$_][\w$_]*)?(`) beginCaptures: '1': {name: entity.quasi.tag.name.js} '2': {name: punctuation.definition.quasi.begin.js} end: '`' endCaptures: '0': {name: punctuation.definition.quasi.end.js} patterns: - include: '#string-content' - name: entity.quasi.element.js begin: \${ beginCaptures: '0': {name: punctuation.quasi.element.begin.js} end: '}' endCaptures: '0': {name: punctuation.quasi.element.end.js} patterns: - include: '#expression' literal-regexp: patterns: # ignore ++, -- since they're uncommon, distinguishing them is not possible in sublime text, see: # http://stackoverflow.com/questions/5519596/when-parsing-javascript-what-determines-the-meaning-of-a-slash - name: string.regexp.js begin: >- (?x) (?<= \.|\(|,|{|}|\[|;|,|<|>|<=|>=|==|!=|===|!==|\+|-|\*|%|\+\+|--|<<|>>|>>>|&|\||\^|!|~|&&|\|\||\?|:|=|\+=|-=|\*=|%=|<<=|>>=|>>>=|&=|\|=|\^=|/|/=| \Wnew|\Wdelete|\Wvoid|\Wtypeof|\Winstanceof|\Win|\Wdo|\Wreturn|\Wcase|\Wthrow| ^new|^delete|^void|^typeof|^instanceof|^in|^do|^return|^case|^throw|^ )\s* (/) (?!/|\*|$) beginCaptures: '1': {name: punctuation.definition.string.begin.js} end: (/)([gimy]*) endCaptures: '1': {name: punctuation.definition.string.end.js} '2': {name: keyword.other.js} patterns: - include: source.regexp.js literal-string: patterns: - name: string.quoted.single.js begin: "'" beginCaptures: '0': {name: punctuation.definition.string.begin.js} end: (')|(\n) endCaptures: '1': {name: punctuation.definition.string.end.js} '2': {name: invalid.illegal.newline.js} patterns: - include: '#string-content' - name: string.quoted.double.js begin: '"' beginCaptures: '0': {name: punctuation.definition.string.begin.js} end: (")|(\n) endCaptures: '1': {name: punctuation.definition.string.end.js} '2': {name: invalid.illegal.newline.js} patterns: - include: '#string-content' string-content: patterns: - name: constant.character.escape.newline.js match: \\\s*\n - name: constant.character.escape.js match: \\(x[\da-fA-F]{2}|u[\da-fA-F]{4}|.) literal-variable: patterns: # e.g. CONSTANT - name: variable.other.constant.js match: '[A-Z][_$\dA-Z]*\b' # dollar variables - name: variable.other.dollar.js match: '(\$)[$\w]+' captures: '1': {name: punctuation.dollar.js} # e.g. Class.property - name: meta.property.class.js match: >- (?x) \b([A-Z][$\w]*)\s*(\.) ([_$a-zA-Z][$\w]*) captures: '1': {name: variable.other.class.js} '2': {name: keyword.operator.accessor.js} '3': {name: variable.other.property.static.js} # e.g. obj.property - name: variable.other.object.js match: (?- (?x) \b( 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|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 )\b # console - match: (?