Skip to content

Commit

Permalink
Refactor the dart highlights
Browse files Browse the repository at this point in the history
  • Loading branch information
flukejones committed Dec 12, 2021
1 parent 5883dc1 commit 0804283
Showing 1 changed file with 99 additions and 119 deletions.
218 changes: 99 additions & 119 deletions runtime/queries/dart/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -21,62 +21,6 @@
(marker_annotation
name: (identifier) @attribute)

; Operators and Tokens
; --------------------
(template_substitution
"$" @punctuation.special
"{" @punctuation.special
"}" @punctuation.special
) @none

(template_substitution
"$" @punctuation.special
(identifier_dollar_escaped) @variable
) @none

(escape_sequence) @string.escape

[
"@"
"=>"
".."
"??"
"=="
"?"
":"
"&&"
"%"
"<"
">"
"="
">="
"<="
"||"
(multiplicative_operator)
(increment_operator)
(is_operator)
(prefix_operator)
(equality_operator)
(additive_operator)
] @operator

[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket

; Delimiters
; --------------------
[
";"
"."
","
] @punctuation.delimiter

; Types
; --------------------
(class_definition
Expand Down Expand Up @@ -106,61 +50,133 @@

; Variables
; --------------------
; var keyword
(inferred_type) @keyword

(const_builtin) @constant.builtin
(final_builtin) @constant.builtin

((identifier) @type
(#match? @type "^_?[A-Z].*[a-z]")) ; catch Classes or IClasses not CLASSES

("Function" @type)

; properties
(unconditional_assignable_selector
(identifier) @property)
(identifier) @variable.other.member)

(conditional_assignable_selector
(identifier) @property)
(identifier) @variable.other.member)

; assignments
(assignment_expression
left: (assignable_expression) @variable)
;(assignment_expression (identifier) @variable)
;(assignment_expression
; left: (assignable_expression) @variable)

(this) @variable.builtin
(super) @variable.builtin

; Parameters
; --------------------
(formal_parameter
name: (identifier) @parameter)
name: (identifier) @variable.parameter)

(named_argument
(label (identifier) @parameter))
(label (identifier) @variable.parameter))

; Literals
; --------------------
[
(hex_integer_literal)
(decimal_integer_literal)
(decimal_floating_point_literal)
; TODO: inaccessbile nodes
; (octal_integer_literal)
; (hex_floating_point_literal)
] @number
(hex_integer_literal)
(decimal_integer_literal)
(decimal_floating_point_literal)
;(octal_integer_literal)
;(hex_floating_point_literal)
] @constant.numeric.integer

(symbol_literal) @symbol
(string_literal) @string
(true) @boolean
(false) @boolean
(null_literal) @constant.builtin

[
(null_literal)
] @constant.builtin

[
(true)
(false)
] @constant.builtin.boolean

(documentation_comment) @comment
(comment) @comment

; Operators and Tokens
; --------------------
(template_substitution
"$" @punctuation.special
"{" @punctuation.special
"}" @punctuation.special) @embedded

(template_substitution
"$" @punctuation.special
(identifier_dollar_escaped) @variable
) @embedded

(escape_sequence) @string.escape

; Punctuation
;---------------------
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket

[
";"
"."
","
"?."
] @punctuation.delimiter

; Operators
;---------------------
; Seems to be restricted. Basic ops are not available?
[
"@"
"=>"
".."
"??"
"=="
"?"
":"
"&&"
"%"
"<"
">"
"="
">="
"<="
"||"
(multiplicative_operator)
(increment_operator)
(is_operator)
(prefix_operator)
(equality_operator)
(additive_operator)
] @operator

; Keywords
; --------------------
["import" "library" "export"] @include
["if" "else" "switch" "default"] @keyword.control.conditional
["import" "library" "export"] @keyword.control.import
["do" "while" "continue" "for"] @keyword.control.repeat
["return" "yield"] @keyword.control.return
["in" "is"] @keyword.operator

[
"try"
"throw"
"catch"
"finally"
(break_statement)
] @keyword.control.exception

; Reserved words (cannot be used as identifiers)
[
Expand All @@ -186,15 +202,9 @@
"with"
] @keyword

[
"return"
"yield"
] @keyword.return


; Built in identifiers:
; alone these are marked as keywords
[
"Function"
"abstract"
"as"
"async"
Expand All @@ -217,43 +227,13 @@
"show"
"static"
"typedef"
"var"
] @keyword

; when used as an identifier:
((identifier) @variable.builtin
(#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"] @conditional
(#vim-match? @variable.builtin "^(abstract|as|covariant|deferred|dynamic|export|external|factory|Function|get|implements|import|interface|library|operator|mixin|part|set|static|typedef)$"))

[
"try"
"throw"
"catch"
"finally"
(break_statement)
] @exception

["do" "while" "continue" "for"] @repeat

; Error
(ERROR) @error

0 comments on commit 0804283

Please sign in to comment.