; Keywords
[
  "as"
  "let"
  "todo"
  "try"
] @keyword

; Function Keywords
[
  "fn"
  "type"
] @keyword.function

; Imports
[
  "import"
] @include

; Conditionals
[
  "case"
  "if"
] @conditional

; Exceptions
[
  "assert"
] @exception

; Punctuation
[
  "("
  ")"
  "<<"
  ">>"
  "["
  "]"
  "{"
  "}"
] @punctuation.bracket

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

[
  "#"
] @punctuation.special

  Operators
[
  "%"
  "&&"
  "*"
  "*."
  "+"
  "+."
  "-"
  "-."
  "->"
  ".."
  "/"
  "/."
  ":"
  "<"
  "<."
  "<="
  "<=."
  "="
  "=="
  ">"
  ">."
  ">="
  ">=."
  "|>"
  "||"
] @operator

; Identifiers
(identifier) @variable

; Comments
[
  (module_comment)
  (statement_comment)
  (comment)
] @comment

; Unused Identifiers
[
  (discard)
  (hole)
] @comment

; Modules & Imports
(module ("/" @namespace)?) @namespace
(import alias: ((identifier) @namespace)?)
(remote_type_identifier module: (identifier) @namespace)
(unqualified_import name: (identifier) @function)

; Strings
(string) @string

; Bit Strings
(bit_string_segment) @string.special

; Numbers
[
  (integer)
  (float)
  (bit_string_segment_option_unit)
] @number

; Function Parameter Labels
(function_call arguments: (arguments (argument label: (label) @symbol ":" @symbol)))
(function_parameter label: (label)? @symbol name: (identifier) @parameter (":" @parameter)?)

  Records
(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
(data_constructor_argument label: (label) @property ":" @property)

; Type Parameters
(type_parameter) @parameter

; Types
((type_identifier) @type (#not-any-of? @type "True" "False"))

  Booleans
((type_identifier) @boolean (#any-of? @boolean "True" "False"))

; Type Variables
(type_var) @type

; Type Qualifiers
[
  "const"
  "external"
  "opaque"
  "pub"
] @type.qualifier

  Tuples
(tuple_access index: (integer) @operator)

; Functions
(function name: (identifier) @function)
(public_function name: (identifier) @function)
(function_call function: (identifier) @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
(binary_expression operator: "|>" right: (identifier) @function)

  Parser Errors
(ERROR) @error

 Keywords
 Function Keywords
 Imports
 Conditionals
 Exceptions
 Punctuation
 Identifiers
 Comments
 Unused Identifiers
 Modules & Imports
 Strings
 Bit Strings
 Numbers
 Function Parameter Labels
 Type Parameters
 Types
 Type Variables
 Type Qualifiers
 Functions
 External Functions
 Pipe Operator
[
  "as"
  "let"
  "todo"
  "try"
] @keyword

[
  "fn"
  "type"
] @keyword.function

[
  "import"
] @include

[
  "case"
  "if"
] @conditional

[
  "assert"
] @exception

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

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

[
  "#"
] @punctuation.special

  Operators
[
  "%"
  "&&"
  "*"
  "*."
  "+"
  "+."
  "-"
  "-."
  "->"
  ".."
  "/"
  "/."
  ":"
  "<"
  "<."
  "<="
  "<=."
  "="
  "=="
  ">"
  ">."
  ">="
  ">=."
  "|>"
  "||"
] @operator

(identifier) @variable

[
  (module_comment)
  (statement_comment)
  (comment)
] @comment

[
  (discard)
  (hole)
] @comment

(module ("/" @namespace)?) @namespace
(import alias: ((identifier) @namespace)?)
(remote_type_identifier module: (identifier) @namespace)
(unqualified_import name: (identifier) @function)

(string) @string

(bit_string_segment) @string.special

[
  (integer)
  (float)
  (bit_string_segment_option_unit)
] @number

(function_call arguments: (arguments (argument label: (label) @symbol ":" @symbol)))
(function_parameter label: (label)? @symbol name: (identifier) @parameter (":" @parameter)?)

  Records
(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
(data_constructor_argument label: (label) @property ":" @property)

(type_parameter) @parameter

((type_identifier) @type (#not-any-of? @type "True" "False"))

  Booleans
((type_identifier) @boolean (#any-of? @boolean "True" "False"))

(type_var) @type

[
  "const"
  "external"
  "opaque"
  "pub"
] @type.qualifier

  Tuples
(tuple_access index: (integer) @operator)

(function name: (identifier) @function)
(public_function name: (identifier) @function)
(function_call function: (identifier) @function)
(function_call function: (field_access field: (label) @function))

(public_external_function name: (identifier) @function)
(external_function name: (identifier) @function)
(external_function_body (string) @namespace . (string) @function)

(binary_expression operator: "|>" right: (identifier) @function)

  Parser Errors
(ERROR) @error
