2024-01-06 15:05:50 +09:00
|
|
|
; Keywords
|
2022-01-18 22:15:26 +01:00
|
|
|
"return" @keyword.return
|
2020-09-05 09:53:21 -05:00
|
|
|
|
2020-07-16 09:30:15 +02:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"goto"
|
|
|
|
|
"in"
|
|
|
|
|
"local"
|
2022-01-18 22:15:26 +01:00
|
|
|
] @keyword
|
2020-06-30 08:59:34 +02:00
|
|
|
|
2022-01-18 22:15:26 +01:00
|
|
|
(break_statement) @keyword
|
2020-06-30 08:59:34 +02:00
|
|
|
|
2022-01-18 22:15:26 +01:00
|
|
|
(do_statement
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"do"
|
|
|
|
|
"end"
|
|
|
|
|
] @keyword)
|
2020-09-05 09:53:21 -05:00
|
|
|
|
|
|
|
|
(while_statement
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"while"
|
|
|
|
|
"do"
|
|
|
|
|
"end"
|
|
|
|
|
] @keyword.repeat)
|
2020-07-05 19:58:47 +02:00
|
|
|
|
2020-09-05 09:53:21 -05:00
|
|
|
(repeat_statement
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"repeat"
|
|
|
|
|
"until"
|
|
|
|
|
] @keyword.repeat)
|
2020-06-30 08:59:34 +02:00
|
|
|
|
2022-01-18 22:15:26 +01:00
|
|
|
(if_statement
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"if"
|
|
|
|
|
"elseif"
|
|
|
|
|
"else"
|
|
|
|
|
"then"
|
|
|
|
|
"end"
|
|
|
|
|
] @keyword.conditional)
|
2022-01-18 22:15:26 +01:00
|
|
|
|
|
|
|
|
(elseif_statement
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"elseif"
|
|
|
|
|
"then"
|
|
|
|
|
"end"
|
|
|
|
|
] @keyword.conditional)
|
2022-01-18 22:15:26 +01:00
|
|
|
|
|
|
|
|
(else_statement
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"else"
|
|
|
|
|
"end"
|
|
|
|
|
] @keyword.conditional)
|
2022-01-18 22:15:26 +01:00
|
|
|
|
|
|
|
|
(for_statement
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"for"
|
|
|
|
|
"do"
|
|
|
|
|
"end"
|
|
|
|
|
] @keyword.repeat)
|
2021-01-27 09:29:44 +01:00
|
|
|
|
2022-01-18 22:15:26 +01:00
|
|
|
(function_declaration
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"function"
|
|
|
|
|
"end"
|
|
|
|
|
] @keyword.function)
|
2020-04-20 16:18:02 +02:00
|
|
|
|
2022-01-18 22:15:26 +01:00
|
|
|
(function_definition
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"function"
|
|
|
|
|
"end"
|
|
|
|
|
] @keyword.function)
|
2020-09-13 15:08:11 +02:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Operators
|
2025-12-31 13:47:33 +01:00
|
|
|
(binary_expression
|
|
|
|
|
operator: _ @operator)
|
|
|
|
|
|
|
|
|
|
(unary_expression
|
|
|
|
|
operator: _ @operator)
|
|
|
|
|
|
2025-12-31 14:15:06 +01:00
|
|
|
"=" @operator
|
|
|
|
|
|
2020-09-13 15:08:11 +02:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"and"
|
|
|
|
|
"not"
|
|
|
|
|
"or"
|
2020-09-13 15:08:11 +02:00
|
|
|
] @keyword.operator
|
|
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Punctuations
|
2022-01-18 22:15:26 +01:00
|
|
|
[
|
|
|
|
|
";"
|
|
|
|
|
":"
|
2023-03-19 21:04:38 -04:00
|
|
|
"::"
|
2022-01-18 22:15:26 +01:00
|
|
|
","
|
|
|
|
|
"."
|
|
|
|
|
] @punctuation.delimiter
|
2020-08-11 10:04:34 +02:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Brackets
|
2020-07-27 20:00:18 -05:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"("
|
|
|
|
|
")"
|
|
|
|
|
"["
|
|
|
|
|
"]"
|
|
|
|
|
"{"
|
|
|
|
|
"}"
|
2020-07-27 20:00:18 -05:00
|
|
|
] @punctuation.bracket
|
2020-04-20 16:18:02 +02:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Variables
|
2020-09-12 20:57:01 +02:00
|
|
|
(identifier) @variable
|
|
|
|
|
|
2023-04-28 03:42:54 -04:00
|
|
|
((identifier) @constant.builtin
|
|
|
|
|
(#eq? @constant.builtin "_VERSION"))
|
|
|
|
|
|
2022-03-12 20:17:11 +01:00
|
|
|
((identifier) @variable.builtin
|
2023-04-28 03:42:54 -04:00
|
|
|
(#eq? @variable.builtin "self"))
|
|
|
|
|
|
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
|
|
|
((identifier) @module.builtin
|
|
|
|
|
(#any-of? @module.builtin "_G" "debug" "io" "jit" "math" "os" "package" "string" "table" "utf8"))
|
2023-03-16 03:41:31 -04:00
|
|
|
|
|
|
|
|
((identifier) @keyword.coroutine
|
|
|
|
|
(#eq? @keyword.coroutine "coroutine"))
|
2022-01-18 22:15:26 +01:00
|
|
|
|
2022-11-01 12:27:29 +01:00
|
|
|
(variable_list
|
2023-09-07 11:45:24 +06:00
|
|
|
(attribute
|
|
|
|
|
"<" @punctuation.bracket
|
|
|
|
|
(identifier) @attribute
|
|
|
|
|
">" @punctuation.bracket))
|
2022-11-01 12:27:29 +01:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Labels
|
|
|
|
|
(label_statement
|
|
|
|
|
(identifier) @label)
|
2023-03-19 21:04:38 -04:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(goto_statement
|
|
|
|
|
(identifier) @label)
|
2022-01-18 22:15:26 +01:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Constants
|
2021-08-14 13:33:55 -05:00
|
|
|
((identifier) @constant
|
2024-01-06 15:05:50 +09:00
|
|
|
(#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
|
2020-04-20 16:18:02 +02:00
|
|
|
|
2022-03-12 20:17:11 +01:00
|
|
|
(nil) @constant.builtin
|
|
|
|
|
|
|
|
|
|
[
|
|
|
|
|
(false)
|
|
|
|
|
(true)
|
|
|
|
|
] @boolean
|
|
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Tables
|
|
|
|
|
(field
|
2024-07-21 18:12:27 -07:00
|
|
|
name: (identifier) @property)
|
2022-01-18 22:15:26 +01:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(dot_index_expression
|
|
|
|
|
field: (identifier) @variable.member)
|
2022-01-18 22:15:26 +01:00
|
|
|
|
|
|
|
|
(table_constructor
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"{"
|
|
|
|
|
"}"
|
|
|
|
|
] @constructor)
|
2020-09-08 17:59:16 +02:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Functions
|
|
|
|
|
(parameters
|
|
|
|
|
(identifier) @variable.parameter)
|
2021-07-07 08:49:36 -05: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
|
|
|
(vararg_expression) @variable.parameter.builtin
|
2023-10-23 19:19:12 -07:00
|
|
|
|
2023-06-08 04:12:54 +06:00
|
|
|
(function_declaration
|
2024-03-21 20:44:35 +09:00
|
|
|
name: [
|
|
|
|
|
(identifier) @function
|
|
|
|
|
(dot_index_expression
|
|
|
|
|
field: (identifier) @function)
|
|
|
|
|
])
|
2024-01-06 15:05:50 +09:00
|
|
|
|
|
|
|
|
(function_declaration
|
2024-03-21 20:44:35 +09:00
|
|
|
name: (method_index_expression
|
|
|
|
|
method: (identifier) @function.method))
|
2024-01-06 15:05:50 +09:00
|
|
|
|
|
|
|
|
(assignment_statement
|
|
|
|
|
(variable_list
|
|
|
|
|
.
|
2024-03-21 20:44:35 +09:00
|
|
|
name: [
|
|
|
|
|
(identifier) @function
|
|
|
|
|
(dot_index_expression
|
|
|
|
|
field: (identifier) @function)
|
|
|
|
|
])
|
2024-01-06 15:05:50 +09:00
|
|
|
(expression_list
|
|
|
|
|
.
|
2023-06-08 04:12:54 +06:00
|
|
|
value: (function_definition)))
|
2020-09-05 09:27:13 -05:00
|
|
|
|
2023-06-08 04:12:54 +06:00
|
|
|
(table_constructor
|
|
|
|
|
(field
|
|
|
|
|
name: (identifier) @function
|
|
|
|
|
value: (function_definition)))
|
|
|
|
|
|
|
|
|
|
(function_call
|
2024-03-21 20:44:35 +09:00
|
|
|
name: [
|
|
|
|
|
(identifier) @function.call
|
|
|
|
|
(dot_index_expression
|
|
|
|
|
field: (identifier) @function.call)
|
|
|
|
|
(method_index_expression
|
|
|
|
|
method: (identifier) @function.method.call)
|
|
|
|
|
])
|
2020-09-05 09:27:13 -05:00
|
|
|
|
2021-08-29 14:53:52 -05:00
|
|
|
(function_call
|
|
|
|
|
(identifier) @function.builtin
|
|
|
|
|
(#any-of? @function.builtin
|
2024-01-05 03:19:54 +09:00
|
|
|
; built-in functions in Lua 5.1
|
2024-02-23 17:42:01 +09:00
|
|
|
"assert" "collectgarbage" "dofile" "error" "getfenv" "getmetatable" "ipairs" "load" "loadfile"
|
|
|
|
|
"loadstring" "module" "next" "pairs" "pcall" "print" "rawequal" "rawget" "rawlen" "rawset"
|
|
|
|
|
"require" "select" "setfenv" "setmetatable" "tonumber" "tostring" "type" "unpack" "xpcall"
|
|
|
|
|
"__add" "__band" "__bnot" "__bor" "__bxor" "__call" "__concat" "__div" "__eq" "__gc" "__idiv"
|
|
|
|
|
"__index" "__le" "__len" "__lt" "__metatable" "__mod" "__mul" "__name" "__newindex" "__pairs"
|
|
|
|
|
"__pow" "__shl" "__shr" "__sub" "__tostring" "__unm"))
|
2021-08-29 14:53:52 -05:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Others
|
2022-09-26 10:19:02 +01:00
|
|
|
(comment) @comment @spell
|
2022-01-18 22:15:26 +01:00
|
|
|
|
2023-03-02 08:06:35 -05:00
|
|
|
((comment) @comment.documentation
|
|
|
|
|
(#lua-match? @comment.documentation "^[-][-][-]"))
|
|
|
|
|
|
|
|
|
|
((comment) @comment.documentation
|
|
|
|
|
(#lua-match? @comment.documentation "^[-][-](%s?)@"))
|
|
|
|
|
|
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
|
|
|
(hash_bang_line) @keyword.directive
|
2022-01-18 22:15:26 +01:00
|
|
|
|
2020-04-20 19:13:24 +02:00
|
|
|
(number) @number
|
2022-01-18 22:15:26 +01:00
|
|
|
|
2023-08-07 15:20:09 +02:00
|
|
|
(string) @string
|
2020-04-20 16:18:02 +02:00
|
|
|
|
2023-05-03 19:07:59 +09:00
|
|
|
(escape_sequence) @string.escape
|
2023-12-21 15:31:40 -08:00
|
|
|
|
|
|
|
|
; string.match("123", "%d+")
|
|
|
|
|
(function_call
|
|
|
|
|
(dot_index_expression
|
|
|
|
|
field: (identifier) @_method
|
|
|
|
|
(#any-of? @_method "find" "match" "gmatch" "gsub"))
|
2024-03-21 20:44:35 +09:00
|
|
|
arguments: (arguments
|
|
|
|
|
.
|
|
|
|
|
(_)
|
|
|
|
|
.
|
|
|
|
|
(string
|
|
|
|
|
content: (string_content) @string.regexp)))
|
2023-12-21 15:31:40 -08:00
|
|
|
|
|
|
|
|
;("123"):match("%d+")
|
|
|
|
|
(function_call
|
|
|
|
|
(method_index_expression
|
|
|
|
|
method: (identifier) @_method
|
|
|
|
|
(#any-of? @_method "find" "match" "gmatch" "gsub"))
|
2024-03-21 20:44:35 +09:00
|
|
|
arguments: (arguments
|
|
|
|
|
.
|
|
|
|
|
(string
|
|
|
|
|
content: (string_content) @string.regexp)))
|