mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
Gleam highlight tests
This commit is contained in:
parent
b62750e328
commit
00dce44780
8 changed files with 290 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
13
tests/query/highlights/gleam/assert.gleam
Normal file
13
tests/query/highlights/gleam/assert.gleam
Normal file
|
|
@ -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
|
||||
}
|
||||
127
tests/query/highlights/gleam/function.gleam
Normal file
127
tests/query/highlights/gleam/function.gleam
Normal file
|
|
@ -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
|
||||
22
tests/query/highlights/gleam/import.gleam
Normal file
22
tests/query/highlights/gleam/import.gleam
Normal file
|
|
@ -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
|
||||
18
tests/query/highlights/gleam/pipe.gleam
Normal file
18
tests/query/highlights/gleam/pipe.gleam
Normal file
|
|
@ -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
|
||||
}
|
||||
7
tests/query/highlights/gleam/todo.gleam
Normal file
7
tests/query/highlights/gleam/todo.gleam
Normal file
|
|
@ -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
|
||||
}
|
||||
11
tests/query/highlights/gleam/try.gleam
Normal file
11
tests/query/highlights/gleam/try.gleam
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
pub fn main() {
|
||||
try x = Ok(1)
|
||||
// <- keyword
|
||||
// ^ variable
|
||||
// ^ operator
|
||||
// ^ type
|
||||
// ^ punctuation.bracket
|
||||
// ^ number
|
||||
// ^ punctuation.bracket
|
||||
Ok(x + 1)
|
||||
}
|
||||
83
tests/query/highlights/gleam/type.gleam
Normal file
83
tests/query/highlights/gleam/type.gleam
Normal file
|
|
@ -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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue