# [PackageDev] target_format: plist, ext: tmLanguage name: JavaScript Next scopeName: source.js fileTypes: [js, htc, jsx] uuid: 487CF323-A3F9-48FA-B140-DCE8C893E664 firstLineMatch: ^#!/.*\b(node|js)$\n? keyEquivalent: ^~J patterns: - include: '#comments' - include: '#support' - include: '#core' repository: core: patterns: - include: '#leading-space' # literals - include: '#literal-regex' # before operators to avoid ambiguities - include: '#literal-number' - include: '#literal-quasi' - include: '#literal-language-constant' # keywords/operators - include: '#literal-keywords' # modules/classes/functions - include: '#literal-module' - include: '#literal-class' - include: '#literal-function-storage' - include: '#literal-method' - include: '#literal-arrow-function-storage' - include: '#literal-prototype-storage' # after literal-function-storage, which includes some prototype strings - include: '#literal-labels' # after literal-function-storage & literal-labels which requires the below in some cases - include: '#literal-string' - include: '#literal-language-variable' # function calls - include: '#literal-method-call' - include: '#literal-function-call' # punctuation - include: '#literal-variable' - include: '#literal-punctuation' # brackets - include: '#brackets' brackets: patterns: - name: meta.group.braces.round begin: (\() beginCaptures: '1': {name: meta.brace.round.js} end: (\)) endCaptures: '1': {name: meta.brace.round.js} patterns: - include: $self - name: meta.group.braces.square begin: (\[) beginCaptures: '1': {name: meta.brace.square.js} end: (\]) endCaptures: '1': {name: meta.brace.square.js} patterns: - include: $self - name: meta.group.braces.curly begin: ({) beginCaptures: '1': {name: meta.brace.curly.js} end: (}) endCaptures: '1': {name: meta.brace.curly.js} patterns: - include: $self 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: '1': {name: punctuation.definition.parameters.begin.js} end: (\)) endCaptures: '1': {name: punctuation.definition.parameters.end.js} patterns: - name: variable.parameter.function.js match: '[_$a-zA-Z][_$\w]*' - name: punctuation.separator.parameter.function.js match: ',' - name: meta.parameter.optional.js begin: '=' beginCaptures: '0': {name: keyword.operator.assignment.js} end: '(?=[,)])' patterns: - include: $self - include: '#comments' literal-module: patterns: - name: keyword.operator.module.js match: (?- (?x) (?- (?x) \b(?:(static)\s+)? ([_$a-zA-Z][_$\w]*)\s* (?=\([^())]*\)(?:\s|/\*.*\*/)*\{) beginCaptures: '1': {name: storage.type.js} '2': {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-storage: patterns: # 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: variable.language.prototype.js} # 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: variable.language.prototype.js} literal-function-storage: patterns: # e.g. function play(arg1, arg2) { } - name: meta.function.js begin: >- (?x) \b(function(?:\s*\*|(?=\s|[(]))) \s*([_$a-zA-Z][_$\w]*)?\s* beginCaptures: '1': {name: storage.type.function.js} '2': {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*(function(?:\s*\*|(?=\s|[(])))\s* beginCaptures: '1': {name: entity.name.class.js} '2': {name: variable.language.prototype.js} '3': {name: entity.name.function.js} '4': {name: storage.type.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*(function(?:\s*\*|(?=\s|[(])))\s* beginCaptures: '1': {name: entity.name.class.js} '2': {name: entity.name.function.js} '3': {name: storage.type.function.js} end: (?<=\)) patterns: - include: '#function-declaration-parameters' # e.g. play: function(arg1, arg2) { } - name: meta.function.json.js begin: >- (?x) \b([_$a-zA-Z][_$\w]*) \s*(:) \s*(function(?:\s*\*|(?=\s|[(])))\s* beginCaptures: '1': {name: entity.name.function.js} '2': {name: punctuation.separator.key-value.js} '3': {name: storage.type.function.js} end: (?<=\)) patterns: - include: '#function-declaration-parameters' # e.g. "play": function(arg1, arg2) { } - name: meta.function.json.js begin: >- (?x) (?: ((')((?:[^']|\\')*)('))| ((")((?:[^"]|\\")*)(")) )\s* (:)\s* \b(function(?:\s*\*|(?=\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.function.js} end: (?<=\)) patterns: - include: '#function-declaration-parameters' literal-arrow-function-storage: patterns: # e.g. (args) => { } - name: meta.function.arrow.js begin: >- (?x) (?=\([^()]*\)\s*(=>)) end: (?<=\))\s*(=>) endCaptures: '1': {name: storage.type.function.arrow.js} patterns: - include: '#function-declaration-parameters' # 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*(?=\([^()]*\)\s*(=>)) beginCaptures: '1': {name: entity.name.class.js} '2': {name: variable.language.prototype.js} '3': {name: entity.name.function.js} end: (?<=\))\s*(=>) endCaptures: '1': {name: storage.type.function.arrow.js} patterns: - include: '#function-declaration-parameters' # e.g. Sound.play = (args) => { } - name: meta.function.static.arrow.js begin: >- (?x) (\b_?[A-Z][_$\w]*)? \.([_$a-zA-Z][_$\w]*) \s*= \s*(?=\([^()]*\)\s*(=>)) beginCaptures: '1': {name: entity.name.class.js} '2': {name: entity.name.function.js} end: (?<=\))\s*(=>) endCaptures: '1': {name: storage.type.function.arrow.js} patterns: - include: '#function-declaration-parameters' # e.g. play: (args) => { } - name: meta.function.json.arrow.js begin: >- (?x) \b([_$a-zA-Z][_$\w]*) \s*(:) \s*(?=\([^()]*\)\s*(=>)) beginCaptures: '1': {name: entity.name.function.js} '2': {name: punctuation.separator.key-value.js} end: (?<=\))\s*(=>) endCaptures: '1': {name: storage.type.function.arrow.js} patterns: - include: '#function-declaration-parameters' # e.g. "play": (args) => { } - name: meta.function.json.arrow.js begin: >- (?x) (?: ((')((?:[^']|\\')*)('))| ((")((?:[^"]|\\")*)(")) )\s* (:)\s* \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} end: (?<=\))\s*(=>) endCaptures: '1': {name: storage.type.function.arrow.js} patterns: - include: '#function-declaration-parameters' 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: entity.name.function.js} '3': {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: 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: '\?|:' literal-labels: patterns: - begin: >- (?x) (?- (?xi) (?:\B[-+])? (?: \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.object.comma.js match: ',' - name: meta.delimiter.method.period.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: - 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: $self literal-regex: 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 - contentName: 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: string.regexp.js} '2': {name: punctuation.definition.string.begin.js} end: ((/)([gimy]*)) endCaptures: '1': {name: string.regexp.js} '2': {name: punctuation.definition.string.end.js} '3': {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]+' # 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: 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 # firebug - name: support.type.object.firebug.js match: (?