2024-02-21 17:44:01 +04:00
|
|
|
; Most primitive nodes
|
|
|
|
|
(shebang) @keyword.directive
|
|
|
|
|
|
2023-03-28 23:17:43 +02:00
|
|
|
(comment) @comment @spell
|
2020-08-16 20:11:56 -04:00
|
|
|
|
|
|
|
|
[
|
|
|
|
|
"("
|
|
|
|
|
")"
|
|
|
|
|
"{"
|
|
|
|
|
"}"
|
|
|
|
|
"["
|
|
|
|
|
"]"
|
|
|
|
|
] @punctuation.bracket
|
|
|
|
|
|
2024-04-22 13:57:55 +04:00
|
|
|
[
|
|
|
|
|
(nil)
|
|
|
|
|
(nil_binding)
|
|
|
|
|
] @constant.builtin
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2024-04-22 13:57:55 +04:00
|
|
|
[
|
|
|
|
|
(boolean)
|
|
|
|
|
(boolean_binding)
|
|
|
|
|
] @boolean
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2024-04-22 13:57:55 +04:00
|
|
|
[
|
|
|
|
|
(number)
|
|
|
|
|
(number_binding)
|
|
|
|
|
] @number
|
2020-08-16 20:11:56 -04:00
|
|
|
|
2024-04-22 13:57:55 +04:00
|
|
|
[
|
|
|
|
|
(string)
|
|
|
|
|
(string_binding)
|
|
|
|
|
] @string
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2024-04-22 13:57:55 +04:00
|
|
|
[
|
|
|
|
|
(symbol)
|
|
|
|
|
(symbol_binding)
|
|
|
|
|
] @variable
|
|
|
|
|
|
|
|
|
|
(symbol_option) @keyword.directive
|
2020-08-16 20:11:56 -04:00
|
|
|
|
2024-04-22 13:57:55 +04:00
|
|
|
(escape_sequence) @string.escape
|
2020-08-16 20:11:56 -04:00
|
|
|
|
2021-09-10 03:49:35 +03:00
|
|
|
(multi_symbol
|
2024-01-06 15:05:50 +09:00
|
|
|
"." @punctuation.delimiter
|
2024-02-21 17:44:01 +04:00
|
|
|
member: (symbol_fragment) @variable.member)
|
2021-09-10 03:49:35 +03:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(list
|
2024-04-22 13:57:55 +04:00
|
|
|
call: (symbol) @function.call)
|
2024-01-06 15:05:50 +09:00
|
|
|
|
|
|
|
|
(list
|
2024-04-22 13:57:55 +04:00
|
|
|
call: (multi_symbol
|
2024-02-21 17:44:01 +04:00
|
|
|
member: (symbol_fragment) @function.call .))
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2024-02-21 17:44:01 +04:00
|
|
|
(multi_symbol_method
|
|
|
|
|
":" @punctuation.delimiter
|
2024-04-22 13:57:55 +04:00
|
|
|
method: (symbol_fragment) @function.method.call)
|
|
|
|
|
|
|
|
|
|
(quasi_quote_reader_macro
|
|
|
|
|
macro: _ @punctuation.special)
|
2024-02-21 17:44:01 +04:00
|
|
|
|
2024-04-22 13:57:55 +04:00
|
|
|
(quote_reader_macro
|
|
|
|
|
macro: _ @punctuation.special)
|
|
|
|
|
|
|
|
|
|
(unquote_reader_macro
|
|
|
|
|
macro: _ @punctuation.special)
|
|
|
|
|
|
|
|
|
|
(hashfn_reader_macro
|
|
|
|
|
macro: _ @keyword.function)
|
|
|
|
|
|
|
|
|
|
(sequence_arguments
|
|
|
|
|
(symbol_binding) @variable.parameter)
|
|
|
|
|
|
|
|
|
|
(sequence_arguments
|
|
|
|
|
(rest_binding
|
|
|
|
|
rhs: (symbol_binding) @variable.parameter))
|
|
|
|
|
|
|
|
|
|
(docstring) @string.documentation
|
|
|
|
|
|
|
|
|
|
(fn_form
|
|
|
|
|
name: [
|
|
|
|
|
(symbol) @function
|
|
|
|
|
(multi_symbol
|
|
|
|
|
member: (symbol_fragment) @function .)
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
(lambda_form
|
|
|
|
|
name: [
|
|
|
|
|
(symbol) @function
|
|
|
|
|
(multi_symbol
|
|
|
|
|
member: (symbol_fragment) @function .)
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
; NOTE: The macro name is highlighted as @variable because it
|
|
|
|
|
; gives a nicer contrast instead of everything being the same
|
|
|
|
|
; color. Rust queries use this workaround too for `macro_rules!`.
|
|
|
|
|
(macro_form
|
|
|
|
|
name: [
|
|
|
|
|
(symbol) @variable
|
|
|
|
|
(multi_symbol
|
|
|
|
|
member: (symbol_fragment) @variable .)
|
|
|
|
|
])
|
2024-02-21 17:44:01 +04:00
|
|
|
|
|
|
|
|
((symbol) @variable.parameter
|
2025-12-03 20:32:06 +04:00
|
|
|
(#lua-match? @variable.parameter "^%$[1-9]?$"))
|
2024-02-21 17:44:01 +04:00
|
|
|
|
2025-08-11 01:10:03 +04:00
|
|
|
((symbol_fragment) @variable.parameter
|
2025-12-03 20:32:06 +04:00
|
|
|
(#lua-match? @variable.parameter "^%$[1-9]?$"))
|
2025-08-11 01:10:03 +04:00
|
|
|
|
2024-02-21 17:44:01 +04:00
|
|
|
((symbol) @variable.parameter
|
2025-12-03 20:32:06 +04:00
|
|
|
(#eq? @variable.parameter "$..."))
|
2024-02-21 17:44:01 +04:00
|
|
|
|
|
|
|
|
((symbol) @operator
|
|
|
|
|
(#any-of? @operator
|
|
|
|
|
; arithmetic
|
|
|
|
|
"+" "-" "*" "/" "//" "%" "^"
|
|
|
|
|
; comparison
|
|
|
|
|
">" "<" ">=" "<=" "=" "~="
|
|
|
|
|
; other
|
|
|
|
|
"#" "." "?." ".."))
|
|
|
|
|
|
|
|
|
|
((symbol) @keyword.operator
|
|
|
|
|
(#any-of? @keyword.operator
|
|
|
|
|
; comparison
|
|
|
|
|
"not="
|
|
|
|
|
; boolean
|
|
|
|
|
"and" "or" "not"
|
|
|
|
|
; bitwise
|
|
|
|
|
"lshift" "rshift" "band" "bor" "bxor" "bnot"
|
|
|
|
|
; other
|
|
|
|
|
"length"))
|
|
|
|
|
|
2024-04-22 13:57:55 +04:00
|
|
|
(case_guard
|
|
|
|
|
call: (_) @keyword.conditional)
|
|
|
|
|
|
|
|
|
|
(case_guard_or_special
|
|
|
|
|
call: (_) @keyword.conditional)
|
2024-02-21 17:44:01 +04:00
|
|
|
|
|
|
|
|
((symbol) @keyword.function
|
|
|
|
|
(#any-of? @keyword.function "fn" "lambda" "λ" "hashfn"))
|
2024-01-06 15:05:50 +09:00
|
|
|
|
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
|
|
|
((symbol) @keyword.repeat
|
2024-02-21 17:44:01 +04:00
|
|
|
(#any-of? @keyword.repeat "for" "each" "while"))
|
2021-09-10 03:49:35 +03:00
|
|
|
|
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
|
|
|
((symbol) @keyword.conditional
|
2024-04-22 13:57:55 +04:00
|
|
|
(#any-of? @keyword.conditional "if" "when" "match" "case" "match-try" "case-try"))
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2021-09-10 03:49:35 +03:00
|
|
|
((symbol) @keyword
|
2024-02-21 17:44:01 +04:00
|
|
|
(#any-of? @keyword
|
2024-02-23 17:42:01 +09:00
|
|
|
"global" "local" "let" "set" "var" "comment" "do" "doc" "eval-compiler" "lua" "macros" "unquote"
|
|
|
|
|
"quote" "tset" "values" "tail!"))
|
2021-09-10 03:49:35 +03:00
|
|
|
|
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
|
|
|
((symbol) @keyword.import
|
2024-04-22 13:57:55 +04:00
|
|
|
(#any-of? @keyword.import "require-macros" "import-macros" "include"))
|
2021-09-30 18:17:31 +03:00
|
|
|
|
2021-09-10 03:49:35 +03:00
|
|
|
((symbol) @function.macro
|
2024-02-21 17:44:01 +04:00
|
|
|
(#any-of? @function.macro
|
2024-02-23 17:42:01 +09:00
|
|
|
"collect" "icollect" "fcollect" "accumulate" "faccumulate" "->" "->>" "-?>" "-?>>" "?." "doto"
|
|
|
|
|
"macro" "macrodebug" "partial" "pick-args" "pick-values" "with-open"))
|
2024-02-21 17:44:01 +04:00
|
|
|
|
2024-04-22 13:57:55 +04:00
|
|
|
(case_catch
|
|
|
|
|
call: (symbol) @keyword)
|
|
|
|
|
|
|
|
|
|
(import_macros_form
|
|
|
|
|
imports: (table_binding
|
|
|
|
|
(table_binding_pair
|
|
|
|
|
value: (symbol_binding) @function.macro)))
|
|
|
|
|
|
2024-02-21 17:44:01 +04:00
|
|
|
; TODO: Highlight builtin methods (`table.unpack`, etc) as @function.builtin
|
|
|
|
|
([
|
|
|
|
|
(symbol) @module.builtin
|
|
|
|
|
(multi_symbol
|
|
|
|
|
base: (symbol_fragment) @module.builtin)
|
|
|
|
|
]
|
2024-02-23 17:42:01 +09:00
|
|
|
(#any-of? @module.builtin
|
|
|
|
|
"vim" "_G" "debug" "io" "jit" "math" "os" "package" "string" "table" "utf8"))
|
2024-02-21 17:44:01 +04:00
|
|
|
|
|
|
|
|
([
|
|
|
|
|
(symbol) @variable.builtin
|
|
|
|
|
(multi_symbol
|
|
|
|
|
.
|
|
|
|
|
(symbol_fragment) @variable.builtin)
|
|
|
|
|
]
|
|
|
|
|
(#eq? @variable.builtin "arg"))
|
|
|
|
|
|
|
|
|
|
((symbol) @variable.builtin
|
|
|
|
|
(#eq? @variable.builtin "..."))
|
2021-09-10 03:49:35 +03:00
|
|
|
|
|
|
|
|
((symbol) @constant.builtin
|
2024-02-21 17:44:01 +04:00
|
|
|
(#eq? @constant.builtin "_VERSION"))
|
2020-08-16 20:11:56 -04:00
|
|
|
|
2021-09-10 03:49:35 +03:00
|
|
|
((symbol) @function.builtin
|
2024-02-21 17:44:01 +04:00
|
|
|
(#any-of? @function.builtin
|
2024-02-23 17:42:01 +09:00
|
|
|
"assert" "collectgarbage" "dofile" "error" "getmetatable" "ipairs" "load" "loadfile" "next"
|
|
|
|
|
"pairs" "pcall" "print" "rawequal" "rawget" "rawlen" "rawset" "require" "select" "setmetatable"
|
|
|
|
|
"tonumber" "tostring" "type" "warn" "xpcall" "module" "setfenv" "loadstring" "unpack"))
|