# [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) keyEquivalent: ^~J patterns: - include: '#comments' - include: '#support' - include: '#core' - include: '#special' repository: arrow-function: patterns: - name: arrow.function.js patterns: # e.g. (args) => - name: storage.type.function.arrow.js match: |- (?x) \s* ( (?: (\() (.*?)? (\)))| ([_$a-zA-Z][_$\w]* ) )\s*(=>) captures: '1': {name: entity.arrow.function.js} '2': {name: punctuation.definition.parameters.begin.js} '3': {name: variable.parameter.function.arrow.js} '4': {name: punctuation.definition.parameters.end.js} '5': {name: variable.parameter.function.arrow.js} '6': {name: punctuation.definition.arrow.js} brackets: patterns: - name: meta.function-call.method.with-arguments.js match: >- (?x) (?<=\.) ([_$a-zA-Z][_$\w]*)? (?=\() captures: '1': {name: entity.name.function.js} - name: meta.group.braces.round begin: (\() beginCaptures: '1': {name: meta.brace.round.js} end: (\)) endCaptures: '1': {name: meta.brace.round.js} patterns: - include: $base - name: meta.group.braces.square begin: (\[) beginCaptures: '1': {name: meta.brace.square.js} end: (\]) endCaptures: '1': {name: meta.brace.square.js} patterns: - include: $base 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.line.double-slash.js match: (//).*$\n? captures: '1': {name: punctuation.definition.comment.js} - name: comment.block.html.js match: () captures: '0': {name: punctuation.definition.comment.html.js} '2': {name: punctuation.definition.comment.html.js} core: patterns: - include: '#leading-space' - include: '#brackets' # literals should precede operators to avoid ambiguoties - include: '#literal-number' - include: '#literal-string' - include: '#literal-quasi' - include: '#literal-regex' - include: '#literal-keywords' - include: '#arrow-function' - include: '#literal-class' - include: '#literal-module' # before function calls, to differentiate methods from them - include: '#literal-method' - include: '#literal-function-call' - include: '#literal-function-constructor' - include: '#literal-labels' - include: '#literal-variable' - include: '#literal-punctuation' literal-module: patterns: # module names are defined using strings - name: storage.type.module.js match: \b(module)\b - name: keyword.operator.module.js match: \b(import|export|from|as)\b literal-class: patterns: # e.g. class MyClass { } - name: meta.class.js match: \b(class)\b(?:\s+([_$a-zA-Z][_$\w]*)\s*(?:\b(extends)\b\s*([_$a-zA-Z][_$\w]*))?)?\s* captures: '1': {name: storage.type.class.js} '2': {name: entity.name.class.js} '3': {name: storage.type.extends.js} '4': {name: entity.name.extends.js} # definitions here don't include field modifications (e.g. this.a = 'b'), as modifications can occur outside the class - match: \b(?:(public|private|static)\s+)(?:(var|let|const)\s+)?([_$a-zA-Z][_$\w]*\s*)(?=\=) captures: '1': {name: storage.modifier.js} '2': {name: storage.type.js} '3': {name: entity.name.field.js} - match: \b(private)(?=\s*\() captures: '1': {name: support.function.private.js} - name: storage.modifier.js match: \b(public|private|static)\b # getter/setter - name: meta.accessor.js match: \b([gs]et\s*)\b([_$a-zA-Z][_$\w]*)\s*(\()(.*?)(\)) captures: '1': {name: storage.type.accessor.js} '2': {name: entity.name.accessor.js} '3': {name: punctuation.definition.parameters.begin.js} '4': {name: variable.parameter.accessor.js} '5': {name: punctuation.definition.parameters.end.js} literal-function-call: patterns: - name: meta.function-call.static.with-arguments.js begin: (?=[_$a-zA-Z][_$\w]*\s*\() end: (?=\() patterns: - name: entity.name.function.js match: ([_$a-zA-Z][_$\w]*)? literal-function-constructor: patterns: # e.g. function myFunc(arg) { } - name: meta.function.js match: \b(function\*?)(?:\s+([a-zA-Z_$]\w*))?\s*(\()(.*?)(\)) captures: '1': {name: storage.type.function.js} '2': {name: entity.name.function.js} '3': {name: punctuation.definition.parameters.begin.js} '4': {name: variable.parameter.function.js} '5': {name: punctuation.definition.parameters.end.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: support.constant.js} # e.g. Sound.prototype.play = function() { } - name: meta.prototype.function.js match: ([_$a-zA-Z][_$\w]*)\.(prototype)\.([_$a-zA-Z][_$\w]*)\s*=\s*(function\*?)?\s*(\()(.*?)(\)) captures: '1': {name: entity.name.class.js} '2': {name: support.constant.js} '3': {name: entity.name.function.js} '4': {name: storage.type.function.js} '5': {name: punctuation.definition.parameters.begin.js} '6': {name: variable.parameter.function.js} '7': {name: punctuation.definition.parameters.end.js} # e.g. Sound.prototype - name: meta.prototype.js match: ([_$a-zA-Z][_$\w]*)\.(prototype) captures: '1': {name: entity.name.class.js} '2': {name: support.constant.js} # e.g. Sound.prototype.play = myfunc - name: meta.function.js match: ([_$a-zA-Z][_$\w]*)\.(prototype)\.([_$a-zA-Z][_$\w]*)\s*=\s* captures: '1': {name: entity.name.class.js} '2': {name: support.constant.js} '3': {name: entity.name.function.js} # e.g. .play = function() { } - name: meta.function.js match: \.([_$a-zA-Z][_$\w]*)\s*=\s*(function\*?)( [_$a-zA-Z][_$\w]*)?\s*(\()(.*?)(\)) captures: '1': {name: entity.name.function.js} '2': {name: storage.type.function.js} '3': {name: entity.name.function.js} '4': {name: punctuation.definition.parameters.begin.js} '5': {name: variable.parameter.function.js} '6': {name: punctuation.definition.parameters.end.js} # e.g. foobar: function() { } - name: meta.function.json.js match: \b([_$a-zA-Z][_$\w]*)\s*(:)\s*\b(function\*?)?\s*(\()(.*?)(\)) captures: '1': {name: entity.name.function.js} '2': {name: punctuation.separator.key-value.js} '3': {name: storage.type.function.js} '4': {name: punctuation.definition.parameters.begin.js} '5': {name: variable.parameter.function.js} '6': {name: punctuation.definition.parameters.end.js} # e.g. "foo": function - name: meta.function.json.js match: (?:((')(.*?)('))|((")(.*?)(")))\s*(:)\s*\b(function\*?)?\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.function.js} '11': {name: punctuation.definition.parameters.begin.js} '12': {name: variable.parameter.function.js} '13': {name: punctuation.definition.parameters.end.js} literal-method: patterns: - name: meta.function-call.method.with-arguments.js match: (?x)(?<= \. ) ([_$a-zA-Z][_$\w]*) (?=\() captures: '1': {name: entity.name.function.js} - name: meta.function-call.method.without-arguments.js match: (?x)(?<= \. ) ([_$a-zA-Z][_$\w]*) ((\( \s* \))) captures: '1': {name: entity.name.function.js} '2': {name: meta.group.braces.round.function.arguments.js} '3': {name: meta.brace.round.js} # e.g. function(one,two,...)\n?{...} - name: meta.function.js begin: |- (?x) \b(function\*?) (?= (?:\b(?:[_$a-zA-Z][_$\w]*))? \s* # The function name \(.*?\) # The properties that the function accepts ) beginCaptures: '1': {name: storage.type.function.js} end: (?<=})(\s*\n)? patterns: - include: $base # ES6 methods, e.g. abc(x, y, z){ - name: meta.method.js match: |- (?x) (?=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|/=|%=|\+=|\-=|&=|\^=' - name: punctuation.separator.key-value match: ':' - name: keyword.operator.logical.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.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.assignment.js match: (?x)= - 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 literal-labels: patterns: - match: (?<=['"])(\s*)(:) captures: '2': {name: punctuation.separator.key-value.js} - name: constant.other.object.key.js match: (?- (?x) (?<= [\[,=(:?]| ^|&&| return )\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' literal-variable: patterns: - name: variable.other.constant.js match: \.?[A-Z][_$\dA-Z]*\b - name: meta.entity.static.js match: \b([A-Z][_$\w]*\.?)\s*?(?:([a-z$_][\w_$]*(?=\())|([a-z$_][\w_$]*))? captures: '1': {name: variable.other.class.js} '2': {name: meta.function-call.class.static.js} '3': {name: variable.other.class.static.js} - 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: \b(console)\b # node - name: support.module.node.js match: \b(natives|buffer|child_process|cluster|crypto|d(gram|ns)|fs|http(s)?|net|os|path|punycode|(query)?string(_decoder)?|re(adline|pl)|tls|tty|util|vm|zlib)\b - name: support.type.object.node.js match: \b(process(.env)?|global|GLOBAL|root|std(out|in|err)|exports|__dirname|__filename|console)\b - name: support.class.node.js match: \b(Buffer|EventEmitter|Server|Pipe|Socket|REPLServer|ReadStream|WriteStream|Stream|Inflate|Deflate|InflateRaw|DeflateRaw|GZip|GUnzip|Unzip|Zip)\b