diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 86919162..4f126c09 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -58,205 +58,391 @@ comments: scopes: 'program': 'source.js' - 'property_identifier': [ - { - match: '^[\$A-Z_]+$', - scopes: 'constant.other.property.js' - } + # Keyword + '"if"': 'keyword.control.condition' + '"else"': 'keyword.control.condition' + '"switch"': 'keyword.control.condition' + '"case"': 'keyword.control.condition' + 'switch_statement > "default"': 'keyword.control.condition' + 'export_statement > "default"': 'keyword.control.package' + '"import"': 'keyword.control.package' + '"export"': 'keyword.control.package' + '"from"': 'keyword.control.package' + '"do"': 'keyword.control.loop' + '"while"': 'keyword.control.loop' + '"for"': 'keyword.control.loop' + '"break"': 'keyword.control.jump' + '"continue"': 'keyword.control.jump' + '"yield"': 'keyword.control.jump' + '"return"': 'keyword.control.jump' + '"await"': 'keyword.control.jump' + '"debugger"': 'keyword.control.jump' + '"throw"': 'keyword.control.jump' + '"try"': 'keyword.control.exception' + '"catch"': 'keyword.control.exception' + '"finally"': 'keyword.control.exception' + '"as"': 'keyword.control.evaluate' - 'variable.other.object.property' - ] + '"+"': 'keyword.operator.arithmetic.symbolic' + '"-"': 'keyword.operator.arithmetic.symbolic' + 'binary_expression > "*"': 'keyword.operator.arithmetic.symbolic' + 'binary_expression > "/"': 'keyword.operator.arithmetic.symbolic' + '"%"': 'keyword.operator.arithmetic.symbolic' + '"++"': 'keyword.operator.arithmetic.symbolic' + '"--"': 'keyword.operator.arithmetic.symbolic' - 'member_expression > property_identifier': 'variable.other.object.property.unquoted' + '"&"': 'keyword.operator.bitwise.symbolic' + '"|"': 'keyword.operator.bitwise.symbolic' + '"^"': 'keyword.operator.bitwise.symbolic' + '"~"': 'keyword.operator.bitwise.symbolic' + '"<<"': 'keyword.operator.bitwise.symbolic' + '">>"': 'keyword.operator.bitwise.symbolic' + '">>>"': 'keyword.operator.bitwise.symbolic' - 'formal_parameters > identifier': 'variable.parameter.function' - 'formal_parameters > rest_parameter > identifier': 'variable.parameter.rest.function' + '"="': 'keyword.operator.assignment.symbolic' + '"+="': 'keyword.operator.assignment.compound.symbolic' + '"-="': 'keyword.operator.assignment.compound.symbolic' + '"*="': 'keyword.operator.assignment.compound.symbolic' + '"/="': 'keyword.operator.assignment.compound.symbolic' + '"%="': 'keyword.operator.assignment.compound.symbolic' + '"&="': 'keyword.operator.assignment.compound.symbolic' + '"|="': 'keyword.operator.assignment.compound.symbolic' + '"^="': 'keyword.operator.assignment.compound.symbolic' + '"<<="': 'keyword.operator.assignment.compound.symbolic' + '">>="': 'keyword.operator.assignment.compound.symbolic' + '">>>="': 'keyword.operator.assignment.compound.symbolic' - 'shorthand_property_identifier': [ - { - match: '^[\$A-Z_]{2,}$', - scopes: 'constant.other' - } - ] + '"=="': 'keyword.operator.comparison.symbolic' + '"==="': 'keyword.operator.comparison.symbolic' + '"!="': 'keyword.operator.comparison.symbolic' + '"!=="': 'keyword.operator.comparison.symbolic' + '"<"': 'keyword.operator.comparison.symbolic' + '">"': 'keyword.operator.comparison.symbolic' + '"<="': 'keyword.operator.comparison.symbolic' + '">="': 'keyword.operator.comparison.symbolic' + + '"in"': 'keyword.operator.comparison' + '"of"': 'keyword.operator.comparison' + '"instanceof"': 'keyword.operator.comparison' + '"void"': 'keyword.operator.comparison' + + '"new"': 'keyword.operator.instance' + '"delete"': 'keyword.operator.instance' + '"typeof"': 'keyword.operator.instance' + + '"!"': 'keyword.operator.logical.symbolic' + '"&&"': 'keyword.operator.logical.symbolic' + '"||"': 'keyword.operator.logical.symbolic' + + '"?"': 'keyword.operator.ternary.symbolic' + 'ternary_expression > ":"': 'keyword.operator.ternary.symbolic' + + 'this': 'keyword.variable.this' + 'super': 'keyword.variable.super' + + '"get"': 'keyword.storage.modifier.getter' + '"set"': 'keyword.storage.modifier.setter' + '"extends"': 'keyword.storage.modifier' + '"static"': 'keyword.storage.modifier' + '"async"': 'keyword.storage.modifier' + + '"var"': 'keyword.storage.declaration' + '"let"': 'keyword.storage.declaration' + '"const"': 'keyword.storage.declaration' + '"function"': 'keyword.storage.declaration' + '"class"': 'keyword.storage.declaration' - ' - class > identifier, - new_expression > identifier - ': 'meta.class' + # Entity + ''' + class > identifier, + class_declaration > identifier + ''': 'entity.type.class' - ' - jsx_opening_element > identifier, - jsx_closing_element > identifier, - jsx_self_closing_element > identifier - ': [ + 'class_heritage > identifier': 'entity.type.class.inherited' + + ''' + new_expression > identifier, + new_expression > member_expression > property_identifier + ''': 'entity.type.class.constructor.call' + + 'member_expression > new_expression > member_expression > property_identifier': [ { - match: '^[A-Z]', - scopes: 'meta.class.component.jsx' - } + match: '^[0-9_$]*[A-Z][A-Z0-9_$]*$', + scopes: 'entity.variable.member.immutable' # new _.VARIABLE._() + }, + { + match: '^[0-9_$]*[A-Z]', + scopes: 'entity.type.class' # new _.Type._() + }, + 'entity.variable.member' # new _.variable._() ] - 'call_expression > identifier': {match: '^[A-Z]', scopes: 'meta.class'} - 'arrow_function > identifier:nth-child(0)': 'variable.parameter.function' + 'call_expression > identifier': [ + { + exact: 'require', + scopes: 'entity.function.support.call' + }, + { + match: '^[0-9_$]*[A-Z]', + scopes: 'entity.type.class.constructor.call' # Type() + }, + 'entity.function.call' # function() + ] - 'function > identifier': 'entity.name.function' - 'function_declaration > identifier': 'entity.name.function' - 'generator_function > identifier': 'entity.name.function' + ''' + call_expression > member_expression > property_identifier + ''': [ + { + match: '^[0-9_$]*[A-Z]', + scopes: 'entity.type.class.constructor.call' # _.Type() + }, + 'entity.function.method.call' # _.function() + ] - 'call_expression > identifier': [ - {match: '^require$', scopes: 'support.function'}, - 'entity.name.function' + ''' + function > identifier, + decorator > identifier, + decorator > member_expression > property_identifier, + function_declaration > identifier + ''': [ + { + match: '^[0-9_$]*[A-Z]', + scopes: 'entity.type.class.constructor' # Type + }, + 'entity.function' # function ] - 'call_expression > super': 'support.function.super' + ''' + generator_function > identifier, + generator_function_declaration > identifier + ''': 'entity.function' + + 'method_definition > property_identifier': 'entity.function.method' - 'method_definition > property_identifier': 'entity.name.function' - 'call_expression > member_expression > property_identifier': 'entity.name.function' + ''' + property_identifier, + shorthand_property_identifier + ''': [ + { + match: '^[0-9_$]*[A-Z][A-Z0-9_$]*$', + scopes: 'entity.variable.member.immutable' # _.VARIABLE + }, + { + match: '^[0-9_$]*[A-Z]', + scopes: 'entity.type.class' # _.Type + }, + 'entity.variable.member' # _.variable + ] 'identifier': [ { - match: '^(global|globalThis|module|exports|__filename|__dirname)$', - scopes: 'support.variable' + exact: 'Infinity', + scopes: 'constant.language.numeric' + }, + { + match: '^(global|globalThis||module|exports|process|__filename|__dirname)$', + scopes: 'entity.variable.support' }, { match: '^(window|self|frames|event|document|performance|screen|navigator|console)$' - scopes: 'support.variable.dom' + scopes: 'entity.variable.support.dom' }, { - exact: 'require', - scopes: 'support.function' + exact: 'arguments', + scopes: 'entity.variable.support.arguments' + }, + { + match: '^[0-9_$]*[A-Z][A-Z0-9_$]*$', + scopes: 'entity.variable.immutable' }, { - match: '^[\$A-Z_]{2,}$', - scopes: 'constant.other' + match: '^[0-9_$]*[A-Z]', + scopes: 'entity.type.class' }, + 'entity.variable' + ] + + 'formal_parameters > identifier': 'entity.variable.parameter' + 'arrow_function > identifier:nth-child(0)': 'entity.variable.parameter' + + ''' + jsx_opening_element > identifier, + jsx_closing_element > identifier, + jsx_self_closing_element > identifier + ''': [ { match: '^[A-Z]', - scopes: 'meta.class' + scopes: 'entity.type.component.jsx' }, + 'entity.tag.jsx' ] - 'number': 'constant.numeric' + 'jsx_attribute > property_identifier': 'entity.attribute.jsx' + + # String 'string': 'string.quoted' - 'regex': 'string.regexp' - 'escape_sequence': 'constant.character.escape' - 'template_string': 'string.quoted.template' - 'undefined': 'constant.language' + + 'template_string': 'string.template.quoted' + 'template_substitution': 'string.part.interpolation' + + 'regex': 'string.regexp.quoted' + 'regex > regex_flags': 'string.regexp.part.language.control.mode' + + 'jsx_attribute > string': 'string.quoted.attribute-value.jsx' + + # Constant + 'escape_sequence': [ + { + match: '^\\\\[uUxftvnrb0-9]', + scopes: 'constant.character.escape.code' + }, + 'constant.character.escape' + ] + + 'number': 'constant.numeric' + + 'undefined': 'constant.language.undefined' 'null': 'constant.language.null' 'true': 'constant.language.boolean.true' 'false': 'constant.language.boolean.false' + + # Text + 'jsx_text': 'text.jsx' + + # Comment 'comment': [ { - match: "^//", + match: '^//', scopes: 'comment.line' }, 'comment.block' ] 'hash_bang_line': 'comment.block' - ' - jsx_expression > "{", - jsx_expression > "}", - template_substitution > "${", - template_substitution > "}" - ': 'punctuation.section.embedded' - 'template_substitution': 'embedded.source' - - '"("': 'punctuation.definition.parameters.begin.bracket.round' - '")"': 'punctuation.definition.parameters.end.bracket.round' - '"{"': 'punctuation.definition.function.body.begin.bracket.curly' - '"}"': 'punctuation.definition.function.body.end.bracket.curly' - '";"': 'punctuation.terminator.statement.semicolon' - '"["': 'punctuation.definition.array.begin.bracket.square' - '"]"': 'punctuation.definition.array.end.bracket.square' - - '"var"': 'storage.type' - '"let"': 'storage.type' - '"class"': 'storage.type' - '"extends"': 'storage.modifier' - '"const"': 'storage.modifier' - '"static"': 'storage.modifier' - '"function"': 'storage.type.function' - '"=>"': 'storage.type.function.arrow' - - '"="': 'keyword.operator.js' - '"+="': 'keyword.operator.js' - '"-="': 'keyword.operator.js' - '"*="': 'keyword.operator.js' - '"/="': 'keyword.operator.js' - '"%="': 'keyword.operator.js' - '"<<="': 'keyword.operator.js' - '">>="': 'keyword.operator.js' - '">>>="': 'keyword.operator.js' - '"&="': 'keyword.operator.js' - '"^="': 'keyword.operator.js' - '"|="': 'keyword.operator.js' - '"!"': 'keyword.operator.js' - '"+"': 'keyword.operator.js' - '"-"': 'keyword.operator.js' - '"*"': 'keyword.operator.js' - '"/"': 'keyword.operator.js' - '"%"': 'keyword.operator.js' - '"=="': 'keyword.operator.js' - '"==="': 'keyword.operator.js' - '"!="': 'keyword.operator.js' - '"!=="': 'keyword.operator.js' - '">="': 'keyword.operator.js' - '"<="': 'keyword.operator.js' - '">"': 'keyword.operator.js' - '"<"': 'keyword.operator.js' - '":"': 'keyword.operator.js' - '"?"': 'keyword.operator.js' - '"&&"': 'keyword.operator.js' - '"||"': 'keyword.operator.js' - '"&"': 'keyword.operator.js' - '"~"': 'keyword.operator.js' - '"^"': 'keyword.operator.js' - '">>"': 'keyword.operator.js' - '">>>"': 'keyword.operator.js' - '"<<"': 'keyword.operator.js' - '"|"': 'keyword.operator.js' - '"++"': 'keyword.operator.js' - '"--"': 'keyword.operator.js' - '"..."': 'keyword.operator.spread.js' - - '"in"': 'keyword.operator.in' - '"instanceof"': 'keyword.operator.instanceof' - '"of"': 'keyword.operator.of' - '"new"': 'keyword.operator.new' - '"typeof"': 'keyword.operator.typeof' - - '"get"': 'keyword.operator.setter' - '"set"': 'keyword.operator.setter' - - '"."': 'meta.delimiter.period' - '","': 'meta.delimiter.comma' - - '"as"': 'keyword.control' - '"if"': 'keyword.control' - '"do"': 'keyword.control' - '"else"': 'keyword.control' - '"while"': 'keyword.control' - '"for"': 'keyword.control' - '"return"': 'keyword.control' - '"break"': 'keyword.control' - '"continue"': 'keyword.control' - '"throw"': 'keyword.control' - '"try"': 'keyword.control' - '"catch"': 'keyword.control' - '"finally"': 'keyword.control' - '"switch"': 'keyword.control' - '"case"': 'keyword.control' - '"default"': 'keyword.control' - '"export"': 'keyword.control' - '"import"': 'keyword.control' - '"from"': 'keyword.control' - '"yield"': 'keyword.control' - '"async"': 'keyword.control' - '"await"': 'keyword.control' - '"debugger"': 'keyword.control' - '"delete"': 'keyword.control' - - 'jsx_attribute > property_identifier': 'entity.other.attribute-name' - 'jsx_opening_element > identifier': 'entity.name.tag' - 'jsx_closing_element > identifier': 'entity.name.tag' - 'jsx_self_closing_element > identifier': 'entity.name.tag' + # Punctuation + '"."': 'punctuation.accessor.member' + '","': 'punctuation.separator' + '";"': 'punctuation.terminator' + '":"': 'punctuation.delimiter' + '"("': 'punctuation.delimiter' + '")"': 'punctuation.delimiter' + '"{"': 'punctuation.delimiter' + '"}"': 'punctuation.delimiter' + '"["': 'punctuation.definition' + '"]"': 'punctuation.definition' + '"*"': 'punctuation.definition' + '"@"': 'punctuation.operation.decorator' + '"..."': 'punctuation.operation.variadic' + '"=>"': 'punctuation.operation.return' + '"\\""': 'punctuation.definition.string' + '"\'"': 'punctuation.definition.string' + 'jsx_attribute > string > "\\""': 'punctuation.definition.string.attribute-value.jsx' + 'jsx_attribute > string > "\'"': 'punctuation.definition.string.attribute-value.jsx' + 'regex > "/"': 'punctuation.definition.string.regexp' + + 'pair > ":"': 'punctuation.association.pair' + + 'generator_function > "*"': 'punctuation.definition.function.generator' + 'generator_function_declaration > "*"': 'punctuation.definition.function.generator' + 'method_definition > "*"': 'punctuation.definition.function.generator' + 'yield_expression > "*"': 'punctuation.definition.function.generator' + + 'export_statement > "*"': 'punctuation.definition.package.export.wildcard' + 'namespace_import > "*"': 'punctuation.definition.package.import.wildcard' + + 'jsx_attribute > "="': 'punctuation.association.pair.attribute-value.jsx' + + 'jsx_fragment > "<"': 'punctuation.definition.tag.jsx' + 'jsx_fragment > "/"': 'punctuation.definition.tag.jsx' + 'jsx_fragment > ">"': 'punctuation.definition.tag.jsx' + 'jsx_opening_element > "<"': 'punctuation.definition.tag.jsx' + 'jsx_opening_element > ">"': 'punctuation.definition.tag.jsx' + 'jsx_closing_element > "<"': 'punctuation.definition.tag.jsx' + 'jsx_closing_element > "/"': 'punctuation.definition.tag.jsx' + 'jsx_closing_element > ">"': 'punctuation.definition.tag.jsx' + 'jsx_self_closing_element > "<"': 'punctuation.definition.tag.jsx' + 'jsx_self_closing_element > "/"': 'punctuation.definition.tag.jsx' + 'jsx_self_closing_element > ">"': 'punctuation.definition.tag.jsx' + + 'jsx_expression > "{"': 'punctuation.delimiter.embedded.jsx' + 'jsx_expression > "}"': 'punctuation.delimiter.embedded.jsx' + + 'template_substitution > "${"': 'punctuation.delimiter.string.part.interpolation' + 'template_substitution > "}"': 'punctuation.delimiter.string.part.interpolation' + + 'class_body > "{"': 'punctuation.delimiter.body.class' + 'class_body > "}"': 'punctuation.delimiter.body.class' + + 'function > statement_block > "{"': 'punctuation.delimiter.body.function' + 'function > statement_block > "}"': 'punctuation.delimiter.body.function' + 'function_declaration > statement_block > "{"': 'punctuation.delimiter.body.function' + 'function_declaration > statement_block > "}"': 'punctuation.delimiter.body.function' + 'arrow_function > statement_block > "{"': 'punctuation.delimiter.body.function.lambda' + 'arrow_function > statement_block > "}"': 'punctuation.delimiter.body.function.lambda' + 'method_definition > statement_block > "{"': 'punctuation.delimiter.body.function.method' + 'method_definition > statement_block > "}"': 'punctuation.delimiter.body.function.method' + 'generator_function > statement_block > "{"': 'punctuation.delimiter.body.function.generator' + 'generator_function > statement_block > "}"': 'punctuation.delimiter.body.function.generator' + 'generator_function_declaration > statement_block > "{"': 'punctuation.delimiter.body.function.generator' + 'generator_function_declaration > statement_block > "}"': 'punctuation.delimiter.body.function.generator' + + 'switch_body > "{"': 'punctuation.delimiter.body.switch' + 'switch_body > "}"': 'punctuation.delimiter.body.switch' + + 'export_clause > "{"': 'punctuation.delimiter.package' + 'export_clause > "}"': 'punctuation.delimiter.package' + 'named_imports > "{"': 'punctuation.delimiter.package' + 'named_imports > "}"': 'punctuation.delimiter.package' + + 'statement_block > "{"': 'punctuation.delimiter.statement' + 'statement_block > "}"': 'punctuation.delimiter.statement' + + 'object > "{"': 'punctuation.definition.collection.object' + 'object > "}"': 'punctuation.definition.collection.object' + + 'array > "["': 'punctuation.definition.collection.array' + 'array > "]"': 'punctuation.definition.collection.array' + + 'subscript_expression > "["': 'punctuation.delimiter.subscript' + 'subscript_expression > "]"': 'punctuation.delimiter.subscript' + + 'computed_property_name > "["': 'punctuation.delimiter.expression' + 'computed_property_name > "]"': 'punctuation.delimiter.expression' + + 'catch_clause > "("': 'punctuation.delimiter.expression' + 'catch_clause > ")"': 'punctuation.delimiter.expression' + + 'for_statement > "("': 'punctuation.delimiter.expression' + 'for_statement > ")"': 'punctuation.delimiter.expression' + + 'for_in_statement > "("': 'punctuation.delimiter.expression' + 'for_in_statement > ")"': 'punctuation.delimiter.expression' + + 'parenthesized_expression > "("': 'punctuation.delimiter.expression' + 'parenthesized_expression > ")"': 'punctuation.delimiter.expression' + + 'arguments > "("': 'punctuation.delimiter.arguments' + 'arguments > ")"': 'punctuation.delimiter.arguments' + + 'formal_parameters > "("': 'punctuation.delimiter.parameters' + 'formal_parameters > ")"': 'punctuation.delimiter.parameters' + + 'ERROR > "."': 'punctuation.accessor.member.invalid.illegal' + 'ERROR > ","': 'punctuation.separator.invalid.illegal' + 'ERROR > ";"': 'punctuation.terminator.invalid.illegal' + 'ERROR > ":"': 'punctuation.delimiter.invalid.illegal' + 'ERROR > "("': 'punctuation.delimiter.invalid.illegal' + 'ERROR > ")"': 'punctuation.delimiter.invalid.illegal' + 'ERROR > "{"': 'punctuation.delimiter.invalid.illegal' + 'ERROR > "}"': 'punctuation.delimiter.invalid.illegal' + 'ERROR > "["': 'punctuation.definition.invalid.illegal' + 'ERROR > "]"': 'punctuation.definition.invalid.illegal' + 'ERROR > "@"': 'punctuation.operation.decorator.invalid.illegal' + 'ERROR > "..."': 'punctuation.operation.variadic.invalid.illegal' + 'ERROR > "=>"': 'punctuation.operation.return.invalid.illegal' + 'ERROR > "\\""': 'punctuation.definition.string.invalid.illegal' + 'ERROR > "\'"': 'punctuation.definition.string.invalid.illegal' + + # Meta + 'jsx_element': 'meta.embedded.jsx' + 'jsx_element > jsx_element': '' diff --git a/grammars/tree-sitter-jsdoc.cson b/grammars/tree-sitter-jsdoc.cson index a9f8a679..302abb9a 100644 --- a/grammars/tree-sitter-jsdoc.cson +++ b/grammars/tree-sitter-jsdoc.cson @@ -6,11 +6,11 @@ parser: 'tree-sitter-jsdoc' injectionRegex: '^jsdoc$' scopes: - 'tag_name': 'keyword.control' - 'identifier': 'variable.other.jsdoc' - 'type': 'support.type' - 'path_expression > identifier': 'string' - '"."': 'meta.delimiter.period' - '":"': 'meta.delimiter.colon' - '"/"': 'meta.delimiter.slash' - '"#", "~"': 'meta.delimiter' + 'tag_name': 'comment.part.caption' + 'path_expression > identifier': 'comment.part.path' + 'identifier': 'comment.part.term.variable' + 'type': 'comment.part.term.type' + + '".", ":", "/", "#", "~"': 'punctuation.delimiter.comment.part' + '"{", "}"': 'punctuation.delimiter.comment.part.term.type' + 'inline_tag > "{", inline_tag > "}"': 'punctuation.delimiter.comment.part.caption' diff --git a/grammars/tree-sitter-regex.cson b/grammars/tree-sitter-regex.cson index 812bd378..97071ef0 100644 --- a/grammars/tree-sitter-regex.cson +++ b/grammars/tree-sitter-regex.cson @@ -6,12 +6,32 @@ parser: 'tree-sitter-regex' injectionRegex: 'regex' scopes: - 'pattern': 'string.quoted', - 'group_name': 'variable.other.object.property' - 'identity_escape, control_letter_escape, control_escape, class_escape': 'constant.character.character-class.regexp' - 'start_assertion, end_assertion, boundary_assertion, non_boundary_assertion': 'constant.character.character-class.regexp' - 'count_quantifier, one_or_more, zero_or_more, optional': 'storage.modifier' - 'character_class': 'string.regexp' - '"(", "(?", "(?:", "(?<"': 'punctuation.definition.parameters.begin.bracket.round' - '">", ")"': 'punctuation.definition.parameters.end.bracket.round' - '"=", "<=", "!", " "^"': 'punctuation.delimiter.string.regexp.part.set' + '"(", "(?", "(?:", "(?<"': 'punctuation.delimiter.string.regexp.part.group' + '">", ")"': 'punctuation.delimiter.string.regexp.part.group' + '"<=", "!", " "="': 'punctuation.delimiter.string.regexp.part.group' + '"|"': 'punctuation.delimiter.string.regexp.part.disjunction' + + 'character_class_escape > "{"': 'punctuation.definition.constant.character.escape.code' + 'character_class_escape > "}"': 'punctuation.definition.constant.character.escape.code' + 'unicode_property_value_expression > "="': 'punctuation.definition.constant.character.escape.code' + 'class_range > "-"': 'punctuation.definition.constant.character.code.range'