Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix Dart syntax highlighting issue (#8347)
Sai Gokula Krishnanc6028f665182
diff --git a/extensions/dart/languages/dart/config.toml b/extensions/dart/languages/dart/config.tomlindex 140e4822890..d723d4d6d37 100644--- a/extensions/dart/languages/dart/config.toml+++ b/extensions/dart/languages/dart/config.toml@@ -7,7 +7,9 @@ brackets = [{ start = "{", end = "}", close = true, newline = true },{ start = "[", end = "]", close = true, newline = true },{ start = "(", end = ")", close = true, newline = true },+ { start = "<", end = ">", close = true, newline = false},{ start = "\"", end = "\"", close = true, newline = false, not_in = ["string"] },{ start = "'", end = "'", close = true, newline = false, not_in = ["string"] },{ start = "/*", end = " */", close = true, newline = false, not_in = ["string", "comment"] },+ { start = "`", end = "`", close = true, newline = false, not_in = ["string", "comment"] },]diff --git a/extensions/dart/languages/dart/highlights.scm b/extensions/dart/languages/dart/highlights.scmindex 270b40ec2d1..e75a86cd79f 100644--- a/extensions/dart/languages/dart/highlights.scm+++ b/extensions/dart/languages/dart/highlights.scm@@ -2,201 +2,256 @@; Methods; ---------------------(function_type- name: (identifier) @function)(super) @function+(function_expression_body (identifier) @type)+; ((identifier)(selector (argument_part)) @function)++(((identifier) @function (#match? @function "^_?[a-z]"))+ . (selector . (argument_part))) @function+; Annotations; --------------------(annotation- name: (identifier) @attribute)+ name: (identifier) @attribute); Operators and Tokens; --------------------(template_substitution- "$" @punctuation.special- "{" @punctuation.special- "}" @punctuation.special- ) @none+ "$" @punctuation.special+ "{" @punctuation.special+ "}" @punctuation.special) @none(template_substitution- "$" @punctuation.special- (identifier_dollar_escaped) @variable- ) @none+ "$" @punctuation.special+ (identifier_dollar_escaped) @variable) @none(escape_sequence) @string.escape[- "@"- "=>"- ".."- "??"- "=="- "?"- ":"- "&&"- "%"- "<"- ">"- "="- ">="- "<="- "||"- (increment_operator)- (is_operator)- (prefix_operator)- (equality_operator)- (additive_operator)- ] @operator+ "@"+ "=>"+ ".."+ "??"+ "=="+ "?"+ ":"+ "&&"+ "%"+ "<"+ ">"+ "="+ ">="+ "<="+ "||"+ (multiplicative_operator)+ (increment_operator)+ (is_operator)+ (prefix_operator)+ (equality_operator)+ (additive_operator)+ ] @operator[- "("- ")"- "["- "]"- "{"- "}"- "<"- ">"- ] @punctuation.bracket+ "("+ ")"+ "["+ "]"+ "{"+ "}"+ ] @punctuation.bracket; Delimiters; --------------------[- ";"- "."- ","- ] @punctuation.delimiter+ ";"+ "."+ ","+ ] @punctuation.delimiter; Types; --------------------(class_definition- name: (identifier) @type)+ name: (identifier) @type)(constructor_signature- name: (identifier) @type)+ name: (identifier) @type)(scoped_identifier- scope: (identifier) @type)+ scope: (identifier) @type)(function_signature- name: (identifier) @function)+ name: (identifier) @function.method)+(getter_signature- (identifier) @function)+ (identifier) @function.method)+(setter_signature- name: (identifier) @function)+ name: (identifier) @function.method)(enum_declaration- name: (identifier) @type)+ name: (identifier) @type)(enum_constant- name: (identifier) @type)-(type_identifier) @type+ name: (identifier) @type)(void_type) @type((scoped_identifier- scope: (identifier) @type- name: (identifier) @type)- (#match? @type "^[a-zA-Z]"))+ scope: (identifier) @type+ name: (identifier) @type)+ (#match? @type "^[a-zA-Z]"))(type_identifier) @type+(type_alias+ (type_identifier) @type.definition)+; Variables; --------------------; var keyword(inferred_type) @keyword-(const_builtin) @constant.builtin-(final_builtin) @constant.builtin-((identifier) @type- (#match? @type "^_?[A-Z]"))+ (#match? @type "^_?[A-Z].*[a-z]"))("Function" @type); properties-; TODO: add method/call_expression to grammar and-; distinguish method call from variable access(unconditional_assignable_selector- (identifier) @property)+ (identifier) @property)++(conditional_assignable_selector+ (identifier) @property); assignments(assignment_expression- left: (assignable_expression) @variable)+ left: (assignable_expression) @variable)(this) @variable.builtin+; Parameters+; --------------------+(formal_parameter+ name: (identifier) @variable.parameter)++(named_argument+ (label+ (identifier) @variable.parameter))+; Literals; --------------------[- (hex_integer_literal)- (decimal_integer_literal)- (decimal_floating_point_literal)- ; TODO: inaccessible nodes- ; (octal_integer_literal)- ; (hex_floating_point_literal)- ] @number--(symbol_literal) @symbol+ (hex_integer_literal)+ (decimal_integer_literal)+ (decimal_floating_point_literal)+ ; TODO: inaccessible nodes+ ; (octal_integer_literal)+ ; (hex_floating_point_literal)+ ] @number++(symbol_literal) @string.special.symbol+(string_literal) @string(true) @boolean(false) @boolean(null_literal) @constant.builtin-(documentation_comment) @comment(comment) @comment+(documentation_comment) @comment.documentation+; Keywords; ---------------------["import" "library" "export"] @keyword.include+[+ "import"+ "library"+ "export"+ "as"+ "show"+ "hide"+ ] @keyword.import; Reserved words (cannot be used as identifiers)-; TODO: "rethrow" @keyword[- ; "assert"(case_builtin)- "extension"- "on"- "class"- "enum"- "extends"- "in"- "is"- "new"- "return"- "super"- "with"- ] @keyword+ "late"+ "required"+ "extension"+ "on"+ "class"+ "enum"+ "extends"+ "in"+ "is"+ "new"+ "super"+ "with"+ ] @keyword+"return" @keyword.return; Built in identifiers:; alone these are marked as keywords[- "abstract"- "as"+ "deferred"+ "factory"+ "get"+ "implements"+ "interface"+ "library"+ "operator"+ "mixin"+ "part"+ "set"+ "typedef"+ ] @keyword++["async""async*"- "yield""sync*""await"+ "yield"+] @keyword.coroutine++[+ (const_builtin)+ (final_builtin)+ "abstract""covariant"- "deferred"- "dynamic"- "external"- "factory"- "get"- "implements"- "interface"- "library"- "operator"- "mixin"- "part"- "set"- "show"- "static"- "typedef"- ] @keyword+ "dynamic"+ "external"+ "static"+ "final"+ "base"+ "sealed"+ ] @type.qualifier; when used as an identifier:((identifier) @variable.builtin- (#vim-match? @variable.builtin "^(abstract|as|covariant|deferred|dynamic|export|external|factory|Function|get|implements|import|interface|library|operator|mixin|part|set|static|typedef)$"))+ (#any-of? @variable.builtin+ "abstract"+ "as"+ "covariant"+ "deferred"+ "dynamic"+ "export"+ "external"+ "factory"+ "Function"+ "get"+ "implements"+ "import"+ "interface"+ "library"+ "operator"+ "mixin"+ "part"+ "set"+ "static"+ "typedef"))-["if" "else" "switch" "default"] @keyword+[+ "if"+ "else"+ "switch"+ "default"+] @keyword.conditional["try"@@ -204,6 +259,11 @@"catch""finally"(break_statement)- ] @keyword+] @keyword.exception-["do" "while" "continue" "for"] @keyword+[+ "do"+ "while"+ "continue"+ "for"+] @keyword.repeatdiff --git a/extensions/dart/languages/dart/indents.scm b/extensions/dart/languages/dart/indents.scmindex 3e8210957c7..4d6f8c1cb75 100644--- a/extensions/dart/languages/dart/indents.scm+++ b/extensions/dart/languages/dart/indents.scm@@ -1,7 +1,18 @@-[- (if_statement)- (for_statement)-] @indent+(class_definition+ "class" @context+ name: (_) @name) @item-(_ "{" "}" @end) @indent-(_ "(" ")" @end) @indent+(function_signature+ name: (_) @name) @item++(getter_signature+ "get" @context+ name: (_) @name) @item++(setter_signature+ "set" @context+ name: (_) @name) @item++(enum_declaration+ "enum" @context+ name: (_) @name) @item