diff options
| -rw-r--r-- | queries/gleam/highlights.scm | 13 | ||||
| -rw-r--r-- | tests/query/highlights/gleam/assert.gleam | 13 | ||||
| -rw-r--r-- | tests/query/highlights/gleam/function.gleam | 127 | ||||
| -rw-r--r-- | tests/query/highlights/gleam/import.gleam | 22 | ||||
| -rw-r--r-- | tests/query/highlights/gleam/pipe.gleam | 18 | ||||
| -rw-r--r-- | tests/query/highlights/gleam/todo.gleam | 7 | ||||
| -rw-r--r-- | tests/query/highlights/gleam/try.gleam | 11 | ||||
| -rw-r--r-- | tests/query/highlights/gleam/type.gleam | 83 |
8 files changed, 290 insertions, 4 deletions
diff --git a/queries/gleam/highlights.scm b/queries/gleam/highlights.scm index 33c54a355..eadacce61 100644 --- a/queries/gleam/highlights.scm +++ b/queries/gleam/highlights.scm @@ -82,6 +82,9 @@ "||" ] @operator +; Identifiers +(identifier) @variable + ; Comments [ (module_comment) @@ -101,9 +104,6 @@ (remote_type_identifier module: (identifier) @namespace) (unqualified_import name: (identifier) @function) -; Identifiers -(identifier) @variable - ; Strings (string) @string @@ -125,10 +125,14 @@ (record arguments: (arguments (argument label: (label) @property ":" @property)?)) (record_pattern_argument label: (label) @property ":" @property) (record_update_argument label: (label) @property ":" @property) +(field_access record: (identifier) @variable field: (label) @property) ; Type Constructors (type_constructor_argument label: (label) @property ":" @property) +; Type Parameters +(type_parameter) @parameter + ; Types ((type_identifier) @type (#not-any-of? @type "True" "False")) @@ -145,10 +149,11 @@ (function name: (identifier) @function) (public_function name: (identifier) @function) (function_call function: (identifier) @function) -(function_call function: (field_access record: (identifier) @namespace field: (label) @function)) +(function_call function: (field_access field: (label) @function)) ; External Functions (public_external_function name: (identifier) @function) +(external_function name: (identifier) @function) (external_function_body (string) @namespace . (string) @function) ; Pipe Operator diff --git a/tests/query/highlights/gleam/assert.gleam b/tests/query/highlights/gleam/assert.gleam new file mode 100644 index 000000000..e49b3d2c4 --- /dev/null +++ b/tests/query/highlights/gleam/assert.gleam @@ -0,0 +1,13 @@ +pub fn main() { + assert Ok(i) = parse_int("123") + // <- exception + // ^ type + // ^ punctuation.bracket + // ^ variable + // ^ punctuation.bracket + // ^ operator + // ^ function + // ^ punctuation.bracket + // ^ string + // ^ punctuation.bracket +} diff --git a/tests/query/highlights/gleam/function.gleam b/tests/query/highlights/gleam/function.gleam new file mode 100644 index 000000000..89a302706 --- /dev/null +++ b/tests/query/highlights/gleam/function.gleam @@ -0,0 +1,127 @@ +pub fn add(x: Int, y: Int) -> Int { +// <- keyword +// ^ keyword.function +// ^ function +// ^ punctuation.bracket +// ^ parameter +// ^ parameter +// ^ type +// ^ punctuation.delimiter +// ^ parameter +// ^ parameter +// ^ type +// ^ punctuation.bracket +// ^ operator +// ^ type +// ^ punctuation.bracket +} +// <- punctuation.bracket + +pub fn twice(f: fn(t) -> t, x: t) -> t { +// <- keyword +// ^ keyword.function +// ^ function +// ^ punctuation.bracket +// ^ parameter +// ^ parameter +// ^ keyword.function +// ^ punctuation.bracket +// ^ type +// ^ punctuation.bracket +// ^ operator +// ^ type +// ^ punctuation.delimiter +// ^ parameter +// ^ parameter +// ^ type +// ^ punctuation.bracket +// ^ operator +// ^ type +// ^ punctuation.bracket +} +// <- punctuation.bracket + +fn list_of_two(my_value: a) -> List(a) { +// <- keyword.function +// ^ function +// ^ punctuation.bracket +// ^ parameter +// ^ parameter +// ^ type +// ^ punctuation.bracket +// ^ operator +// ^ type +// ^ punctuation.bracket +// ^ type +// ^ punctuation.bracket +// ^ punctuation.bracket +} +// <- punctuation.bracket + +fn replace( +// <- keyword.function +// ^ function +// ^ punctuation.bracket + in string: String, + // <- symbol + // ^ parameter + // ^ parameter + // ^ type + // ^ punctuation.delimiter + each pattern: String, + // <- symbol + // ^ parameter + // ^ parameter + // ^ type + // ^ punctuation.delimiter + with replacement: String, + // <- symbol + // ^ parameter + // ^ parameter + // ^ type + // ^ punctuation.delimiter +) { + replace(in: "A,B,C", each: ",", with: " ") + // <- function + // ^ punctuation.bracket + // ^ symbol + // ^ symbol + // ^ string + // ^ punctuation.delimiter + // ^ symbol + // ^ symbol + // ^ string + // ^ punctuation.delimiter + // ^ symbol + // ^ symbol + // ^ string + // ^ punctuation.bracket +} +// <- punctuation.bracket + +pub external fn random_float() -> Float = "rand" "uniform" +// <- keyword +// ^ keyword +// ^ keyword.function +// ^ function +// ^ punctuation.bracket +// ^ punctuation.bracket +// ^ operator +// ^ type +// ^ operator +// ^ namespace +// ^ function + +pub external fn inspect(a) -> a = "Elixir.IO" "inspect" +// <- keyword +// ^ keyword +// ^ keyword.function +// ^ function +// ^ punctuation.bracket +// ^ type +// ^ punctuation.bracket +// ^ operator +// ^ type +// ^ operator +// ^ namespace +// ^ function diff --git a/tests/query/highlights/gleam/import.gleam b/tests/query/highlights/gleam/import.gleam new file mode 100644 index 000000000..28356ca8c --- /dev/null +++ b/tests/query/highlights/gleam/import.gleam @@ -0,0 +1,22 @@ +import gleam/io +// <- include +// ^ namespace +// ^ namespace +// ^ namespace + +import cat as kitten +// <- include +// ^ namespace +// ^ keyword +// ^ namespace + +import animal/cat.{Cat, stroke} +// <- include +// ^ namespace +// ^ namespace +// ^ punctuation.delimiter +// ^ punctuation.bracket +// ^ type +// ^ punctuation.delimiter +// ^ function +// ^ punctuation.bracket diff --git a/tests/query/highlights/gleam/pipe.gleam b/tests/query/highlights/gleam/pipe.gleam new file mode 100644 index 000000000..33f27312b --- /dev/null +++ b/tests/query/highlights/gleam/pipe.gleam @@ -0,0 +1,18 @@ +pub fn run() { + 1 + // <- number + |> add(_, 2) + // <- operator + // ^ function + // ^ punctuation.bracket + // ^ comment + // ^ punctuation.delimiter + // ^ number + // ^ punctuation.bracket + |> add(3) + // <- operator + // ^ function + // ^ punctuation.bracket + // ^ number + // ^ punctuation.bracket +} diff --git a/tests/query/highlights/gleam/todo.gleam b/tests/query/highlights/gleam/todo.gleam new file mode 100644 index 000000000..27038bb73 --- /dev/null +++ b/tests/query/highlights/gleam/todo.gleam @@ -0,0 +1,7 @@ +fn favourite_number() -> Int { + todo("We're going to decide which number is best tomorrow") + // <- keyword + // ^ punctuation.bracket + // ^ string + // ^ punctuation.bracket +} diff --git a/tests/query/highlights/gleam/try.gleam b/tests/query/highlights/gleam/try.gleam new file mode 100644 index 000000000..136d44eb4 --- /dev/null +++ b/tests/query/highlights/gleam/try.gleam @@ -0,0 +1,11 @@ +pub fn main() { + try x = Ok(1) + // <- keyword + // ^ variable + // ^ operator + // ^ type + // ^ punctuation.bracket + // ^ number + // ^ punctuation.bracket + Ok(x + 1) +} diff --git a/tests/query/highlights/gleam/type.gleam b/tests/query/highlights/gleam/type.gleam new file mode 100644 index 000000000..08887e021 --- /dev/null +++ b/tests/query/highlights/gleam/type.gleam @@ -0,0 +1,83 @@ +pub type Cat { +// <- keyword +// ^ keyword.function +// ^ type +// ^ punctuation.bracket + Cat(name: String, cuteness: Int) + // <- type + // ^ punctuation.bracket + // ^ property + // ^ property + // ^ type + // ^ punctuation.delimiter + // ^ property + // ^ property + // ^ type + // ^ punctuation.bracket +} + +fn cats() { + Cat(name: "Nubi", cuteness: 2001) + // <- type + // ^ punctuation.bracket + // ^ property + // ^ property + // ^ string + // ^ punctuation.delimiter + // ^ property + // ^ property + // ^ number + Cat("Ginny", 1950) + // <- type + // ^ punctuation.bracket + // ^ string + // ^ punctuation.delimiter + // ^ number + // ^ punctuation.bracket +} + +type Box(inner_type) { +// <- keyword.function +// ^ type +// ^ punctuation.bracket +// ^ parameter +// ^ punctuation.bracket +// ^ punctuation.bracket + Box(inner: inner_type) + // <- type + // ^ punctuation.bracket + // ^ property + // ^ property + // ^ type + // ^ punctuation.bracket +} + +pub opaque type Counter { +// <- keyword +// ^ keyword +// ^ keyword.function +// ^ type +// ^ punctuation.bracket + Counter(value: Int) +} + +pub fn have_birthday(person) { + Person(..person, age: person.age + 1, is_happy: True) + // <- type + // ^ punctuation.bracket + // ^ operator + // ^ variable + // ^ punctuation.delimiter + // ^ property + // ^ property + // ^ variable + // ^ punctuation.delimiter + // ^ property + // ^ operator + // ^ number + // ^ punctuation.delimiter + // ^ property + // ^ property + // ^ boolean + // ^ punctuation.bracket +} |
