2024-01-06 15:05:50 +09:00
|
|
|
; Primitives
|
2021-03-23 16:06:02 -05:00
|
|
|
(boolean) @boolean
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2022-09-26 10:19:02 +01:00
|
|
|
(comment) @comment @spell
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2023-03-02 08:06:35 -05:00
|
|
|
((comment) @comment.documentation
|
|
|
|
|
(#lua-match? @comment.documentation "^[-][-][-]"))
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2023-03-02 08:06:35 -05:00
|
|
|
((comment) @comment.documentation
|
|
|
|
|
(#lua-match? @comment.documentation "^[-][-](%s?)@"))
|
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
|
|
|
(shebang_comment) @keyword.directive
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2021-03-23 16:06:02 -05:00
|
|
|
(identifier) @variable
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2021-03-23 16:06:02 -05:00
|
|
|
((identifier) @variable.builtin
|
|
|
|
|
(#eq? @variable.builtin "self"))
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2021-03-23 16:06:02 -05:00
|
|
|
(nil) @constant.builtin
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2021-03-23 16:06:02 -05:00
|
|
|
(number) @number
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2021-03-23 16:06:02 -05:00
|
|
|
(string) @string
|
2024-01-06 15:05:50 +09:00
|
|
|
|
|
|
|
|
(table_constructor
|
|
|
|
|
[
|
|
|
|
|
"{"
|
|
|
|
|
"}"
|
|
|
|
|
] @constructor)
|
|
|
|
|
|
|
|
|
|
(varargs
|
|
|
|
|
"..." @constant.builtin)
|
|
|
|
|
|
|
|
|
|
[
|
|
|
|
|
","
|
|
|
|
|
"."
|
|
|
|
|
":"
|
|
|
|
|
";"
|
|
|
|
|
] @punctuation.delimiter
|
2021-03-23 16:06:02 -05:00
|
|
|
|
|
|
|
|
(escape_sequence) @string.escape
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2021-03-23 16:06:02 -05:00
|
|
|
(format_specifier) @string.escape
|
|
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Basic statements/Keywords
|
|
|
|
|
[
|
|
|
|
|
"if"
|
|
|
|
|
"then"
|
|
|
|
|
"elseif"
|
|
|
|
|
"else"
|
|
|
|
|
] @keyword.conditional
|
|
|
|
|
|
|
|
|
|
[
|
|
|
|
|
"for"
|
|
|
|
|
"while"
|
|
|
|
|
"repeat"
|
|
|
|
|
"until"
|
|
|
|
|
] @keyword.repeat
|
|
|
|
|
|
2021-07-04 20:24:25 +03:00
|
|
|
"return" @keyword.return
|
2024-01-06 15:05:50 +09:00
|
|
|
|
|
|
|
|
[
|
|
|
|
|
"in"
|
|
|
|
|
"local"
|
|
|
|
|
(break)
|
|
|
|
|
(goto)
|
|
|
|
|
"do"
|
|
|
|
|
"end"
|
|
|
|
|
] @keyword
|
|
|
|
|
|
2020-10-04 19:39:12 -05:00
|
|
|
(label) @label
|
|
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Global isn't a real keyword, but it gets special treatment in these places
|
|
|
|
|
(var_declaration
|
|
|
|
|
"global" @keyword)
|
|
|
|
|
|
|
|
|
|
(type_declaration
|
|
|
|
|
"global" @keyword)
|
|
|
|
|
|
|
|
|
|
(function_statement
|
|
|
|
|
"global" @keyword)
|
|
|
|
|
|
|
|
|
|
(record_declaration
|
|
|
|
|
"global" @keyword)
|
|
|
|
|
|
|
|
|
|
(enum_declaration
|
|
|
|
|
"global" @keyword)
|
|
|
|
|
|
|
|
|
|
; Ops
|
|
|
|
|
(bin_op
|
|
|
|
|
(op) @operator)
|
2020-10-04 19:39:12 -05:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(unary_op
|
|
|
|
|
(op) @operator)
|
2020-10-04 19:39:12 -05:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"="
|
|
|
|
|
"as"
|
|
|
|
|
] @operator
|
|
|
|
|
|
|
|
|
|
; Functions
|
2020-12-16 16:42:33 -06:00
|
|
|
(function_statement
|
|
|
|
|
"function" @keyword.function
|
2024-01-06 15:05:50 +09:00
|
|
|
.
|
|
|
|
|
name: (_) @function)
|
|
|
|
|
|
2020-12-16 16:42:33 -06:00
|
|
|
(anon_function
|
|
|
|
|
"function" @keyword.function)
|
2020-10-04 19:39:12 -05:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(function_body
|
|
|
|
|
"end" @keyword.function)
|
|
|
|
|
|
|
|
|
|
(arg
|
|
|
|
|
name: (identifier) @variable.parameter)
|
2020-10-04 19:39:12 -05:00
|
|
|
|
2020-12-16 16:42:33 -06:00
|
|
|
(function_signature
|
|
|
|
|
(arguments
|
2024-01-06 15:05:50 +09:00
|
|
|
.
|
|
|
|
|
(arg
|
|
|
|
|
name: (identifier) @variable.builtin))
|
2020-12-16 16:42:33 -06:00
|
|
|
(#eq? @variable.builtin "self"))
|
2020-10-04 19:39:12 -05:00
|
|
|
|
2020-12-16 16:42:33 -06:00
|
|
|
(typeargs
|
|
|
|
|
"<" @punctuation.bracket
|
2024-01-06 15:05:50 +09:00
|
|
|
.
|
|
|
|
|
(_) @variable.parameter
|
|
|
|
|
.
|
|
|
|
|
(","
|
|
|
|
|
.
|
|
|
|
|
(_) @variable.parameter)*
|
|
|
|
|
.
|
|
|
|
|
">" @punctuation.bracket)
|
2020-10-04 19:39:12 -05:00
|
|
|
|
|
|
|
|
(function_call
|
2024-01-06 15:05:50 +09:00
|
|
|
(identifier) @function
|
|
|
|
|
.
|
|
|
|
|
(arguments))
|
|
|
|
|
|
2020-12-16 16:42:33 -06:00
|
|
|
(function_call
|
2024-01-06 15:05:50 +09:00
|
|
|
(index
|
|
|
|
|
(_)
|
|
|
|
|
key: (identifier) @function)
|
|
|
|
|
.
|
|
|
|
|
(arguments))
|
|
|
|
|
|
2020-12-16 16:42:33 -06:00
|
|
|
(function_call
|
2024-01-06 15:05:50 +09:00
|
|
|
(method_index
|
|
|
|
|
(_)
|
|
|
|
|
key: (identifier) @function)
|
|
|
|
|
.
|
|
|
|
|
(arguments))
|
2020-10-04 19:39:12 -05:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Types
|
2020-12-16 16:42:33 -06:00
|
|
|
(record_declaration
|
2024-01-06 15:05:50 +09:00
|
|
|
.
|
2024-04-23 12:23:15 -07:00
|
|
|
"record" @keyword.type
|
2020-12-16 16:42:33 -06:00
|
|
|
name: (identifier) @type)
|
2024-01-06 15:05:50 +09:00
|
|
|
|
|
|
|
|
(anon_record
|
|
|
|
|
.
|
2024-04-23 12:23:15 -07:00
|
|
|
"record" @keyword.type)
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2020-12-16 16:42:33 -06:00
|
|
|
(record_body
|
2021-07-25 15:27:51 +02:00
|
|
|
(record_declaration
|
2024-01-06 15:05:50 +09:00
|
|
|
.
|
2024-04-23 12:23:15 -07:00
|
|
|
"record" @keyword.type
|
2024-01-06 15:05:50 +09:00
|
|
|
.
|
|
|
|
|
name: (identifier) @type))
|
|
|
|
|
|
2021-07-25 15:27:51 +02:00
|
|
|
(record_body
|
|
|
|
|
(enum_declaration
|
2024-01-06 15:05:50 +09:00
|
|
|
.
|
2024-04-23 12:23:15 -07:00
|
|
|
"enum" @keyword.type
|
2024-01-06 15:05:50 +09:00
|
|
|
.
|
|
|
|
|
name: (identifier) @type))
|
|
|
|
|
|
2021-01-05 09:33:11 -06:00
|
|
|
(record_body
|
2021-07-25 15:27:51 +02:00
|
|
|
(typedef
|
2024-01-06 15:05:50 +09:00
|
|
|
.
|
|
|
|
|
"type" @keyword
|
|
|
|
|
.
|
|
|
|
|
name: (identifier) @type
|
|
|
|
|
.
|
|
|
|
|
"="))
|
|
|
|
|
|
2021-01-05 09:33:11 -06:00
|
|
|
(record_body
|
2024-01-06 15:05:50 +09:00
|
|
|
(metamethod
|
|
|
|
|
"metamethod" @keyword))
|
|
|
|
|
|
2021-01-05 09:33:11 -06:00
|
|
|
(record_body
|
|
|
|
|
(userdata) @keyword)
|
2020-12-16 16:42:33 -06:00
|
|
|
|
|
|
|
|
(enum_declaration
|
2024-04-23 12:23:15 -07:00
|
|
|
"enum" @keyword.type
|
2020-12-16 16:42:33 -06:00
|
|
|
name: (identifier) @type)
|
2020-10-04 19:39:12 -05:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(type_declaration
|
|
|
|
|
"type" @keyword)
|
|
|
|
|
|
|
|
|
|
(type_declaration
|
|
|
|
|
(identifier) @type)
|
|
|
|
|
|
|
|
|
|
(simple_type
|
|
|
|
|
name: (identifier) @type)
|
|
|
|
|
|
|
|
|
|
(type_index
|
|
|
|
|
(identifier) @type)
|
2020-10-04 19:39:12 -05:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(type_union
|
|
|
|
|
"|" @operator)
|
|
|
|
|
|
|
|
|
|
(function_type
|
|
|
|
|
"function" @type)
|
|
|
|
|
|
|
|
|
|
; The rest of it
|
2020-12-16 16:42:33 -06:00
|
|
|
(var_declaration
|
2024-03-21 20:44:35 +09:00
|
|
|
declarators: (var_declarators
|
|
|
|
|
(var
|
|
|
|
|
name: (identifier) @variable)))
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2020-12-16 16:42:33 -06:00
|
|
|
(var_declaration
|
2024-03-21 20:44:35 +09:00
|
|
|
declarators: (var_declarators
|
|
|
|
|
(var
|
|
|
|
|
"<" @punctuation.bracket
|
|
|
|
|
.
|
|
|
|
|
attribute: (attribute) @attribute
|
|
|
|
|
.
|
|
|
|
|
">" @punctuation.bracket)))
|
2024-01-06 15:05:50 +09:00
|
|
|
|
|
|
|
|
[
|
|
|
|
|
"("
|
|
|
|
|
")"
|
|
|
|
|
"["
|
|
|
|
|
"]"
|
|
|
|
|
"{"
|
|
|
|
|
"}"
|
|
|
|
|
] @punctuation.bracket
|