~rockorager/tree-sitter-hare

1a0b356beac0c2a88db895e1e365d327a1f4ceb5 — Tim Culverhouse 1 year, 6 months ago ecb348a
highlights: add error propagation highlights

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2 files changed, 30 insertions(+), 23 deletions(-)

M grammar.js
M queries/highlights.scm
M grammar.js => grammar.js +2 -2
@@ 160,7 160,7 @@ module.exports = grammar({
        "fn",
        field("name", $._identifier),
        "(",
        optional(field("parameter_list", $.parameter_list)),
        optional(field("parameters", $.parameter_list)),
        ")",
        field("result", $._type),
        optional(seq("=", $._expression)),


@@ 526,7 526,7 @@ module.exports = grammar({
      )),

    error_propagation: ($) =>
      prec.left(PREC.ERROR, seq($._expression, choice("?", "!"))),
      prec.left(PREC.ERROR, seq($._expression, field("operator", choice("?", "!")))),

    variadic_expression: ($) =>
      choice(

M queries/highlights.scm => queries/highlights.scm +28 -21
@@ 1,24 1,18 @@
[
 "as"
 "break"
 "case"
 "continue"
 "const"
 "def"
 "defer"
 "else"
 "export"
 "fn"
 "if"
 "is"
 "let"
 "match"
 "nullable"
 "offset"
 "return"
 "static"
 "struct"
 "switch"
 "type"
 "union"
 "yield"


@@ 27,6 21,7 @@

"use" @include
"for" @repeat
"return" @keyword.return

[
 "if"


@@ 49,10 44,10 @@
 ] @function.builtin

[
 "@test"
 "@init"
 "@fini"
 ] @special
 (decl_attr)
 (fndec_attr)
 (fntype_attr)
 ] @attribute

[
 (alias_type)


@@ 100,18 95,22 @@
(floating_literal) @float
(rune_literal) @number

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

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

(string_literal) @string



@@ 138,3 137,11 @@
  (identifier) @type)

(struct_union_field) @field

(parameter
  name: (identifier) @parameter)

(error_propagation
  operator: "!" @punctuation.special)
(error_propagation
  operator: "?" @punctuation.special)