2021-10-06 12:30:40 -07:00
|
|
|
; Punctuation
|
2021-10-05 19:35:18 -07:00
|
|
|
[
|
|
|
|
|
","
|
2021-10-06 12:30:40 -07:00
|
|
|
";"
|
2021-10-05 19:35:18 -07:00
|
|
|
] @punctuation.delimiter
|
2021-05-17 20:34:05 +02:00
|
|
|
|
|
|
|
|
[
|
|
|
|
|
"("
|
|
|
|
|
")"
|
2021-08-13 10:09:16 -07:00
|
|
|
"<<"
|
|
|
|
|
">>"
|
2021-05-17 20:34:05 +02:00
|
|
|
"["
|
|
|
|
|
"]"
|
|
|
|
|
"{"
|
|
|
|
|
"}"
|
|
|
|
|
] @punctuation.bracket
|
|
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
"%" @punctuation.special
|
2021-08-13 10:09:16 -07:00
|
|
|
|
2021-10-06 12:30:40 -07:00
|
|
|
; Identifiers
|
|
|
|
|
(identifier) @variable
|
2021-08-13 10:09:16 -07:00
|
|
|
|
2021-10-08 17:07:50 -07:00
|
|
|
; Unused Identifiers
|
2024-01-06 15:05:50 +09:00
|
|
|
((identifier) @comment
|
|
|
|
|
(#lua-match? @comment "^_"))
|
2021-08-13 10:09:16 -07:00
|
|
|
|
2021-10-05 19:35:18 -07:00
|
|
|
; Comments
|
2023-03-02 08:06:35 -05:00
|
|
|
(comment) @comment @spell
|
2021-05-14 21:23:58 +02:00
|
|
|
|
2021-10-06 12:30:40 -07:00
|
|
|
; Strings
|
2023-08-07 15:20:09 +02:00
|
|
|
(string) @string
|
2021-08-01 13:09:41 -06:00
|
|
|
|
2021-10-05 19:35:18 -07:00
|
|
|
; Modules
|
2024-01-09 11:50:31 +02:00
|
|
|
(alias) @module
|
2021-08-13 10:09:16 -07:00
|
|
|
|
2021-10-06 12:30:40 -07:00
|
|
|
; Atoms & Keywords
|
2021-08-13 10:09:16 -07:00
|
|
|
[
|
2021-10-05 19:35:18 -07:00
|
|
|
(atom)
|
2021-10-20 13:20:05 +02:00
|
|
|
(quoted_atom)
|
2021-10-06 12:30:40 -07:00
|
|
|
(keyword)
|
|
|
|
|
(quoted_keyword)
|
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
|
|
|
] @string.special.symbol
|
2021-05-14 21:23:58 +02:00
|
|
|
|
2021-10-05 19:35:18 -07:00
|
|
|
; Interpolation
|
2024-01-06 15:05:50 +09:00
|
|
|
(interpolation
|
|
|
|
|
[
|
|
|
|
|
"#{"
|
|
|
|
|
"}"
|
|
|
|
|
] @string.special)
|
2021-05-14 21:23:58 +02:00
|
|
|
|
2021-10-05 19:35:18 -07:00
|
|
|
; Escape sequences
|
|
|
|
|
(escape_sequence) @string.escape
|
2021-05-14 21:23:58 +02:00
|
|
|
|
2021-10-05 19:35:18 -07:00
|
|
|
; Integers
|
2021-08-13 10:09:16 -07:00
|
|
|
(integer) @number
|
2021-05-14 21:23:58 +02:00
|
|
|
|
2021-10-05 19:35:18 -07:00
|
|
|
; Floats
|
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
|
2021-05-14 21:23:58 +02:00
|
|
|
|
2021-10-05 19:35:18 -07:00
|
|
|
; Characters
|
2021-05-14 21:23:58 +02:00
|
|
|
[
|
2021-10-05 19:35:18 -07:00
|
|
|
(char)
|
|
|
|
|
(charlist)
|
|
|
|
|
] @character
|
|
|
|
|
|
|
|
|
|
; Booleans
|
|
|
|
|
(boolean) @boolean
|
|
|
|
|
|
|
|
|
|
; Nil
|
|
|
|
|
(nil) @constant.builtin
|
|
|
|
|
|
2021-10-06 12:30:40 -07:00
|
|
|
; Operators
|
|
|
|
|
(operator_identifier) @operator
|
|
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(unary_operator
|
|
|
|
|
operator: _ @operator)
|
2021-10-08 17:07:50 -07:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(binary_operator
|
|
|
|
|
operator: _ @operator)
|
2021-10-06 12:30:40 -07:00
|
|
|
|
2021-10-08 17:07:50 -07:00
|
|
|
; Pipe Operator
|
2024-01-06 15:05:50 +09:00
|
|
|
(binary_operator
|
|
|
|
|
operator: "|>"
|
|
|
|
|
right: (identifier) @function)
|
2021-10-06 12:30:40 -07:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(dot
|
|
|
|
|
operator: _ @operator)
|
2021-10-06 12:30:40 -07:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(stab_clause
|
|
|
|
|
operator: _ @operator)
|
2021-10-06 12:30:40 -07:00
|
|
|
|
2021-10-08 13:26:46 -07:00
|
|
|
; Local Function Calls
|
2024-01-06 15:05:50 +09:00
|
|
|
(call
|
|
|
|
|
target: (identifier) @function.call)
|
2021-10-05 19:35:18 -07:00
|
|
|
|
2021-10-08 17:07:50 -07:00
|
|
|
; Remote Function Calls
|
2024-01-06 15:05:50 +09:00
|
|
|
(call
|
2024-03-21 20:44:35 +09:00
|
|
|
target: (dot
|
|
|
|
|
left: [
|
|
|
|
|
(atom) @type
|
|
|
|
|
(_)
|
|
|
|
|
]
|
|
|
|
|
right: (identifier) @function.call)
|
2024-01-06 15:05:50 +09:00
|
|
|
(arguments))
|
2021-10-05 19:35:18 -07:00
|
|
|
|
2021-10-08 13:26:46 -07:00
|
|
|
; Definition Function Calls
|
2024-01-06 15:05:50 +09:00
|
|
|
(call
|
2024-03-21 20:44:35 +09:00
|
|
|
target: ((identifier) @keyword.function
|
|
|
|
|
(#any-of? @keyword.function
|
|
|
|
|
"def" "defdelegate" "defexception" "defguard" "defguardp" "defimpl" "defmacro" "defmacrop"
|
|
|
|
|
"defmodule" "defn" "defnp" "defoverridable" "defp" "defprotocol" "defstruct"))
|
2024-01-06 15:05:50 +09:00
|
|
|
(arguments
|
|
|
|
|
[
|
|
|
|
|
(call
|
|
|
|
|
(identifier) @function)
|
|
|
|
|
(identifier) @function
|
|
|
|
|
(binary_operator
|
2024-03-21 20:44:35 +09:00
|
|
|
left: (call
|
|
|
|
|
target: (identifier) @function)
|
2024-01-06 15:05:50 +09:00
|
|
|
operator: "when")
|
|
|
|
|
])?)
|
2021-10-06 12:30:40 -07:00
|
|
|
|
|
|
|
|
; Kernel Keywords & Special Forms
|
2024-01-06 15:05:50 +09:00
|
|
|
(call
|
2024-03-21 20:44:35 +09:00
|
|
|
target: ((identifier) @keyword
|
|
|
|
|
(#any-of? @keyword
|
|
|
|
|
"alias" "case" "catch" "cond" "else" "for" "if" "import" "quote" "raise" "receive" "require"
|
|
|
|
|
"reraise" "super" "throw" "try" "unless" "unquote" "unquote_splicing" "use" "with")))
|
2021-08-13 10:09:16 -07:00
|
|
|
|
2021-10-08 13:26:46 -07:00
|
|
|
; Special Constants
|
2024-01-06 15:05:50 +09:00
|
|
|
((identifier) @constant.builtin
|
|
|
|
|
(#any-of? @constant.builtin "__CALLER__" "__DIR__" "__ENV__" "__MODULE__" "__STACKTRACE__"))
|
2021-10-06 12:30:40 -07:00
|
|
|
|
|
|
|
|
; Reserved Keywords
|
|
|
|
|
[
|
|
|
|
|
"after"
|
|
|
|
|
"catch"
|
|
|
|
|
"do"
|
|
|
|
|
"end"
|
|
|
|
|
"fn"
|
2021-10-20 13:20:05 +02:00
|
|
|
"rescue"
|
2021-10-06 12:30:40 -07:00
|
|
|
"when"
|
|
|
|
|
"else"
|
|
|
|
|
] @keyword
|
|
|
|
|
|
2021-10-12 16:25:33 -07:00
|
|
|
; Operator Keywords
|
|
|
|
|
[
|
|
|
|
|
"and"
|
|
|
|
|
"in"
|
2021-10-22 14:33:01 -07:00
|
|
|
"not in"
|
2021-10-12 16:25:33 -07:00
|
|
|
"not"
|
|
|
|
|
"or"
|
|
|
|
|
] @keyword.operator
|
|
|
|
|
|
2021-10-06 12:30:40 -07:00
|
|
|
; Capture Operator
|
|
|
|
|
(unary_operator
|
|
|
|
|
operator: "&"
|
2024-03-21 20:44:35 +09:00
|
|
|
operand: [
|
|
|
|
|
(integer) @operator
|
|
|
|
|
(binary_operator
|
|
|
|
|
left: [
|
|
|
|
|
(call
|
|
|
|
|
target: (dot
|
|
|
|
|
left: (_)
|
|
|
|
|
right: (identifier) @function))
|
|
|
|
|
(identifier) @function
|
|
|
|
|
]
|
|
|
|
|
operator: "/"
|
|
|
|
|
right: (integer) @operator)
|
|
|
|
|
])
|
2021-10-08 13:26:46 -07:00
|
|
|
|
2022-01-23 20:39:59 -08:00
|
|
|
; Non-String Sigils
|
2021-10-20 13:20:05 +02:00
|
|
|
(sigil
|
2021-10-06 12:30:40 -07:00
|
|
|
"~" @string.special
|
2024-01-21 22:05:44 +09:00
|
|
|
(sigil_name) @string.special @_sigil_name
|
2021-10-20 13:20:05 +02:00
|
|
|
quoted_start: _ @string.special
|
2021-10-06 12:30:40 -07:00
|
|
|
quoted_end: _ @string.special
|
|
|
|
|
((sigil_modifiers) @string.special)?
|
|
|
|
|
(#not-any-of? @_sigil_name "s" "S"))
|
|
|
|
|
|
2022-01-23 20:39:59 -08:00
|
|
|
; String Sigils
|
2021-10-20 13:20:05 +02:00
|
|
|
(sigil
|
2021-10-06 12:30:40 -07:00
|
|
|
"~" @string
|
2024-01-21 22:05:44 +09:00
|
|
|
(sigil_name) @string @_sigil_name
|
2021-10-20 13:20:05 +02:00
|
|
|
quoted_start: _ @string
|
2021-10-08 17:07:50 -07:00
|
|
|
(quoted_content) @string
|
2021-10-06 12:30:40 -07:00
|
|
|
quoted_end: _ @string
|
|
|
|
|
((sigil_modifiers) @string)?
|
2021-10-08 17:07:50 -07:00
|
|
|
(#any-of? @_sigil_name "s" "S"))
|
2021-10-06 12:30:40 -07:00
|
|
|
|
2021-11-02 16:54:34 +01:00
|
|
|
; Module attributes
|
|
|
|
|
(unary_operator
|
|
|
|
|
operator: "@"
|
2024-03-21 20:44:35 +09:00
|
|
|
operand: [
|
|
|
|
|
(identifier)
|
|
|
|
|
(call
|
|
|
|
|
target: (identifier))
|
|
|
|
|
] @constant) @constant
|
2021-11-02 16:54:34 +01:00
|
|
|
|
2021-10-08 17:07:50 -07:00
|
|
|
; Documentation
|
2021-10-20 13:20:05 +02:00
|
|
|
(unary_operator
|
2021-11-02 16:54:34 +01:00
|
|
|
operator: "@"
|
2024-03-21 20:44:35 +09:00
|
|
|
operand: (call
|
|
|
|
|
target: ((identifier) @_identifier
|
|
|
|
|
(#any-of? @_identifier "moduledoc" "typedoc" "shortdoc" "doc")) @comment.documentation
|
|
|
|
|
(arguments
|
|
|
|
|
[
|
|
|
|
|
(string)
|
|
|
|
|
(boolean)
|
|
|
|
|
(charlist)
|
|
|
|
|
(sigil
|
|
|
|
|
"~" @comment.documentation
|
|
|
|
|
(sigil_name) @comment.documentation
|
|
|
|
|
quoted_start: _ @comment.documentation
|
|
|
|
|
(quoted_content) @comment.documentation
|
|
|
|
|
quoted_end: _ @comment.documentation)
|
|
|
|
|
] @comment.documentation))) @comment.documentation
|