nvim-treesitter/queries/gleam/highlights.scm

202 lines
2.6 KiB
Scheme
Raw Normal View History

2022-02-05 11:44:06 -08:00
; Keywords
[
"as"
"let"
"panic"
2022-02-05 11:44:06 -08:00
"todo"
"type"
"use"
2022-02-05 11:44:06 -08:00
] @keyword
; Function Keywords
2024-01-06 15:05:50 +09:00
"fn" @keyword.function
2022-02-05 11:44:06 -08:00
; Imports
2024-01-06 15:05:50 +09:00
"import" @keyword.import
2022-02-05 11:44:06 -08:00
; Conditionals
[
"case"
"if"
feat!: align standard captures with upstream Problem: Sharing highlight queries with upstream tree-sitter and Helix is difficult. Solution: Where reasonable, use capture names in tree-sitter's standard list or Helix's Atom-style hierarchy. Specifically: * tree-sitter "standard capture names" (https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/highlight/src/lib.rs#L20-L72): - `@parameter` -> `@variable.parameter` - `@field` -> `@variable.member` - `@namespace` -> `@module` - `@float` -> `@number.float` - `@symbol` -> `@string.special.symbol` - `@string.regex` -> `@string.regexp` - `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below) - `@text.title` -> `@markup.heading` - `@text.literal` -> `@markup.raw` - `@text.reference` -> `@markup.link` - `@text.uri` -> `@markup.link.url` (in markup links) - `@string.special` -> `@markup.link.label` (non-url links) - `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`) * Helix captures (https://docs.helix-editor.com/master/themes.html#syntax-highlighting): - `@method` -> `@function.method` - `@method.call` -> `@function.method.call` - `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}` - `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}` - `@text.uri` -> `@string.special.url` (outside markup) - `@preproc` -> `@keyword.directive` - `@define` -> `@keyword.directive`(`.define`?) - `@storageclass` -> `@keyword.storage` - `@conditional` -> `@keyword.conditional` - `@debug` -> `@keyword.debug` - `@exception` -> `@keyword.exception` - `@include` -> `@keyword.import` - `@repeat` -> `@keyword.repeat` * cleanup - remove some redundant `@conceal` (but still allow it for conceal-only patterns) - remove obsolete `@error` (syntax linting is out of scope for this repo) - sort, cleanup capture list in `CONTRIBUTING.md`
2023-12-24 10:00:20 +01:00
] @keyword.conditional
2022-02-05 11:44:06 -08:00
; Exceptions
2024-01-06 15:05:50 +09:00
"assert" @keyword.exception
2022-02-05 11:44:06 -08:00
; Punctuation
[
"("
")"
"<<"
">>"
"["
"]"
"{"
"}"
] @punctuation.bracket
[
","
"."
":"
"->"
2022-02-05 11:44:06 -08:00
] @punctuation.delimiter
2024-01-06 15:05:50 +09:00
"#" @punctuation.special
2022-02-05 11:44:06 -08:00
; Operators
[
"%"
"&&"
"*"
"*."
"+"
"+."
"-"
"-."
".."
"/"
"/."
"<"
"<."
"<="
"<=."
"="
"=="
">"
">."
">="
">=."
"|>"
"||"
] @operator
2022-02-12 17:58:14 -08:00
; Identifiers
(identifier) @variable
2022-02-05 11:44:06 -08:00
; Comments
2024-01-06 15:05:50 +09:00
(comment) @comment @spell
2022-02-05 11:44:06 -08:00
[
(module_comment)
(statement_comment)
] @comment.documentation @spell
2022-02-05 11:44:06 -08:00
; Unused Identifiers
[
(discard)
(hole)
] @comment
; Modules & Imports
feat!: align standard captures with upstream Problem: Sharing highlight queries with upstream tree-sitter and Helix is difficult. Solution: Where reasonable, use capture names in tree-sitter's standard list or Helix's Atom-style hierarchy. Specifically: * tree-sitter "standard capture names" (https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/highlight/src/lib.rs#L20-L72): - `@parameter` -> `@variable.parameter` - `@field` -> `@variable.member` - `@namespace` -> `@module` - `@float` -> `@number.float` - `@symbol` -> `@string.special.symbol` - `@string.regex` -> `@string.regexp` - `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below) - `@text.title` -> `@markup.heading` - `@text.literal` -> `@markup.raw` - `@text.reference` -> `@markup.link` - `@text.uri` -> `@markup.link.url` (in markup links) - `@string.special` -> `@markup.link.label` (non-url links) - `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`) * Helix captures (https://docs.helix-editor.com/master/themes.html#syntax-highlighting): - `@method` -> `@function.method` - `@method.call` -> `@function.method.call` - `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}` - `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}` - `@text.uri` -> `@string.special.url` (outside markup) - `@preproc` -> `@keyword.directive` - `@define` -> `@keyword.directive`(`.define`?) - `@storageclass` -> `@keyword.storage` - `@conditional` -> `@keyword.conditional` - `@debug` -> `@keyword.debug` - `@exception` -> `@keyword.exception` - `@include` -> `@keyword.import` - `@repeat` -> `@keyword.repeat` * cleanup - remove some redundant `@conceal` (but still allow it for conceal-only patterns) - remove obsolete `@error` (syntax linting is out of scope for this repo) - sort, cleanup capture list in `CONTRIBUTING.md`
2023-12-24 10:00:20 +01:00
(module) @module
2024-01-06 15:05:50 +09:00
(import
alias: ((identifier) @module)?)
2024-01-06 15:05:50 +09:00
(remote_type_identifier
module: (identifier) @module)
(unqualified_import
name: (identifier) @function)
2022-02-05 11:44:06 -08:00
; Strings
(string) @string
2022-02-11 16:53:50 -08:00
; Bit Strings
(bit_string_segment) @string.special
2022-02-05 11:44:06 -08:00
; Numbers
(integer) @number
feat!: align standard captures with upstream Problem: Sharing highlight queries with upstream tree-sitter and Helix is difficult. Solution: Where reasonable, use capture names in tree-sitter's standard list or Helix's Atom-style hierarchy. Specifically: * tree-sitter "standard capture names" (https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/highlight/src/lib.rs#L20-L72): - `@parameter` -> `@variable.parameter` - `@field` -> `@variable.member` - `@namespace` -> `@module` - `@float` -> `@number.float` - `@symbol` -> `@string.special.symbol` - `@string.regex` -> `@string.regexp` - `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below) - `@text.title` -> `@markup.heading` - `@text.literal` -> `@markup.raw` - `@text.reference` -> `@markup.link` - `@text.uri` -> `@markup.link.url` (in markup links) - `@string.special` -> `@markup.link.label` (non-url links) - `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`) * Helix captures (https://docs.helix-editor.com/master/themes.html#syntax-highlighting): - `@method` -> `@function.method` - `@method.call` -> `@function.method.call` - `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}` - `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}` - `@text.uri` -> `@string.special.url` (outside markup) - `@preproc` -> `@keyword.directive` - `@define` -> `@keyword.directive`(`.define`?) - `@storageclass` -> `@keyword.storage` - `@conditional` -> `@keyword.conditional` - `@debug` -> `@keyword.debug` - `@exception` -> `@keyword.exception` - `@include` -> `@keyword.import` - `@repeat` -> `@keyword.repeat` * cleanup - remove some redundant `@conceal` (but still allow it for conceal-only patterns) - remove obsolete `@error` (syntax linting is out of scope for this repo) - sort, cleanup capture list in `CONTRIBUTING.md`
2023-12-24 10:00:20 +01:00
(float) @number.float
2022-02-05 11:44:06 -08:00
; Function Parameter Labels
2024-01-06 15:05:50 +09:00
(function_call
arguments: (arguments
(argument
label: (label) @label)))
2024-01-06 15:05:50 +09:00
(function_parameter
label: (label)? @label
name: (identifier) @variable.parameter)
2022-02-05 11:44:06 -08:00
; Records
2024-01-06 15:05:50 +09:00
(record
arguments: (arguments
(argument
label: (label) @variable.member)?))
2024-01-06 15:05:50 +09:00
(record_pattern_argument
label: (label) @variable.member)
2024-01-06 15:05:50 +09:00
(record_update_argument
label: (label) @variable.member)
2024-01-06 15:05:50 +09:00
(field_access
record: (identifier) @variable
field: (label) @variable.member)
2024-01-06 15:05:50 +09:00
(data_constructor_argument
(label) @variable.member)
2022-02-12 17:58:14 -08:00
2022-02-05 11:44:06 -08:00
; Types
[
(type_identifier)
(type_parameter)
(type_var)
] @type
2022-02-05 11:44:06 -08:00
((type_identifier) @type.builtin
(#any-of? @type.builtin "Int" "Float" "String" "List"))
2022-02-05 11:44:06 -08:00
; Type Qualifiers
[
"const"
"external"
(opacity_modifier)
(visibility_modifier)
] @keyword.modifier
2022-02-05 11:44:06 -08:00
; Tuples
2024-01-06 15:05:50 +09:00
(tuple_access
index: (integer) @operator)
2022-02-05 11:44:06 -08:00
; Functions
2024-01-06 15:05:50 +09:00
(function
name: (identifier) @function)
(function_call
function: (identifier) @function.call)
(function_call
function: (field_access
field: (label) @function.call))
2022-02-05 11:44:06 -08:00
; External Functions
2024-01-06 15:05:50 +09:00
(external_function
name: (identifier) @function)
(external_function_body
(string) @module
.
(string) @function)
2022-02-05 11:44:06 -08:00
; Constructors
(constructor_name) @type @constructor
2024-01-06 15:05:50 +09:00
([
(type_identifier)
(constructor_name)
] @constant.builtin
(#any-of? @constant.builtin "Ok" "Error"))
; Booleans
2024-01-06 15:05:50 +09:00
((constructor_name) @boolean
(#any-of? @boolean "True" "False"))
2022-02-05 11:44:06 -08:00
; Pipe Operator
2024-01-06 15:05:50 +09:00
(binary_expression
operator: "|>"
right: (identifier) @function)