Gleam highlight tests

This commit is contained in:
Connor Lay (Clay) 2022-02-12 17:58:14 -08:00 committed by Stephan Seitz
parent b62750e328
commit 00dce44780
8 changed files with 290 additions and 4 deletions

View file

@ -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

View 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
}

View 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

View 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

View 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
}

View 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
}

View file

@ -0,0 +1,11 @@
pub fn main() {
try x = Ok(1)
// <- keyword
// ^ variable
// ^ operator
// ^ type
// ^ punctuation.bracket
// ^ number
// ^ punctuation.bracket
Ok(x + 1)
}

View 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
}