diff --git a/queries/rescript/highlights.scm b/queries/rescript/highlights.scm index e5c555e..57d5642 100644 --- a/queries/rescript/highlights.scm +++ b/queries/rescript/highlights.scm @@ -102,6 +102,17 @@ body: (function)) ; function calls + +; neovim and tree-sitter-cli handle conflicts differently: +; in tree-sitter-cli the first match wins, while in neovim the last match does. +; to get the desired result for `raise` in both, we put it before the general function call +; queries (for the CLI), but also add a priority metadata rule (for neovim). + +(call_expression + function: (value_identifier) @keyword.exception + (#set! "priority" 105) + (#eq? @keyword.exception "raise")) + (call_expression function: (value_identifier_path _ @@ -181,9 +192,6 @@ "catch" ] @keyword.exception -(call_expression - function: (value_identifier) @keyword.exception - (#eq? @keyword.exception "raise")) [ "for" diff --git a/test/highlight/decorators.res b/test/highlight/decorators.res index 66adc13..f0a7d7e 100644 --- a/test/highlight/decorators.res +++ b/test/highlight/decorators.res @@ -1,5 +1,5 @@ @name -//<- annotation +//<- attribute @@name -//<- annotation +//<- attribute diff --git a/test/highlight/expressions.res b/test/highlight/expressions.res index ed756d6..da660b7 100644 --- a/test/highlight/expressions.res +++ b/test/highlight/expressions.res @@ -9,25 +9,25 @@ foo->bar == +x +. 1.0 // ^ property switch foo { -// <- conditional +// <- keyword.conditional | list{1, x, ...rest} => //^ type // ^ number -// ^ parameter +// ^ variable.parameter // ^ punctuation.special -// ^ parameter -// ^ punctuation.special +// ^ variable.parameter +// ^ operator 42 | list{1, 2, ...list{b, ..._} as rest} => rest -// ^ parameter +// ^ variable.parameter // ^ variable | exception Js.Exn.Error(_) => 99 -//^ exception +//^ keyword.exception } switch bar { | #...Mod.t => 33 -//^ constant +//^ constructor } { foo, bar: baz, qux: 1 } @@ -35,16 +35,16 @@ switch bar { // ^ property exception InputClosed(string) -//<- exception +//<- keyword.exception raise(InputClosed("The stream has closed!")) -//<- exception +//<- keyword.exception try { -//<- exception +//<- keyword.exception someOtherJSFunctionThatThrows() } catch { -// ^ exception +// ^ keyword.exception | Not_found => 1 // catch a ReScript exception | Invalid_argument(_) => 2 // catch a second ReScript exception | Js.Exn.Error(obj) => 3 // catch the JS exception diff --git a/test/highlight/functions.res b/test/highlight/functions.res index 59d4bc8..015a61f 100644 --- a/test/highlight/functions.res +++ b/test/highlight/functions.res @@ -1,12 +1,12 @@ let inc = n => n + 1 -// ^ parameter +// ^ variable.parameter // ^ punctuation.special let fn = (a, (b, c), {d, e}, [f, g]) => a + b + c + d + e + f + g -// ^ parameter -// ^ parameter -// ^ parameter -// ^ parameter +// ^ variable.parameter +// ^ variable.parameter +// ^ variable.parameter +// ^ variable.parameter let uncurry = (. u, .x) => (u, x) // ^ operator diff --git a/test/highlight/literals.res b/test/highlight/literals.res index fcbbe88..bd75abe 100644 --- a/test/highlight/literals.res +++ b/test/highlight/literals.res @@ -1,26 +1,26 @@ /**/ #polyvar -// ^ constant -// ^ constant +// ^ constructor +// ^ constructor /**/ #"polyvar" -// ^ constant -// ^ constant -// ^ constant +// ^ constructor +// ^ constructor +// ^ constructor /**/ #\"polyvar" -// ^ constant -// ^ constant -// ^ constant -// ^ constant +// ^ constructor +// ^ constructor +// ^ constructor +// ^ constructor /**/ #77 -// ^ constant -// ^ constant +// ^ constructor +// ^ constructor /**/ 'R' -// ^ string.special -// ^ string.special +// ^ character +// ^ character /**/ '\\' // ^ string.escape diff --git a/test/highlight/modules.res b/test/highlight/modules.res index bd7ba1e..b512cb7 100644 --- a/test/highlight/modules.res +++ b/test/highlight/modules.res @@ -1,23 +1,23 @@ @@warning("-27") -//<- annotation -//^annotation +//<- attribute +//^attribute // ^ string include NumericCurve({ -// ^ include -// ^ namespace +// ^ keyword.import +// ^ module let foo = foo }) let {baz, _} = module(User.Inner) // ^ keyword -// ^ namespace -// ^ namespace +// ^ module +// ^ module module Belt = { include (Belt: module type of Belt with module Map := Belt.Map and module Result := Belt.Result) - // ^ include + // ^ keyword.import // ^ keyword // ^ keyword // ^ operator @@ -29,7 +29,7 @@ let a = module( type t let hello = "Hello" }: X -// ^ namespace +// ^ module ) module B = unpack(a) @@ -46,5 +46,5 @@ module A: A = { } let packedA = module(A: A) -// ^ namespace -// ^ namespace +// ^ module +// ^ module diff --git a/test/highlight/type_declarations.res b/test/highlight/type_declarations.res index e054f20..0b22969 100644 --- a/test/highlight/type_declarations.res +++ b/test/highlight/type_declarations.res @@ -1,13 +1,13 @@ type rec t = -//<- keyword -// ^ keyword +//<- keyword.type +// ^ keyword.modifier // ^ type | Node(t, t) -// ^ constant +// ^ constructor // ^ type | Terminal -// ^ constant +// ^ constructor | Component(module(Foo.t)) // ^ keyword