2020-09-12 20:57:01 +02:00
|
|
|
; Variables
|
2024-03-03 11:00:11 +01:00
|
|
|
[
|
|
|
|
|
(identifier)
|
|
|
|
|
(global_variable)
|
|
|
|
|
] @variable
|
2020-09-12 20:57:01 +02:00
|
|
|
|
2020-04-24 08:48:18 -04:00
|
|
|
; Keywords
|
2020-06-19 09:59:27 -04:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"alias"
|
|
|
|
|
"begin"
|
|
|
|
|
"do"
|
|
|
|
|
"end"
|
|
|
|
|
"ensure"
|
|
|
|
|
"module"
|
|
|
|
|
"rescue"
|
|
|
|
|
"then"
|
|
|
|
|
] @keyword
|
2020-06-19 09:59:27 -04:00
|
|
|
|
2024-04-23 12:23:15 -07:00
|
|
|
"class" @keyword.type
|
|
|
|
|
|
2021-07-04 19:55:59 +03:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"return"
|
|
|
|
|
"yield"
|
2021-07-04 20:24:25 +03:00
|
|
|
] @keyword.return
|
2021-07-04 19:55:59 +03:00
|
|
|
|
2020-09-13 15:08:11 +02:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"and"
|
|
|
|
|
"or"
|
|
|
|
|
"in"
|
|
|
|
|
"not"
|
2020-09-13 15:08:11 +02:00
|
|
|
] @keyword.operator
|
|
|
|
|
|
2023-02-24 06:38:02 -05:00
|
|
|
[
|
|
|
|
|
"def"
|
|
|
|
|
"undef"
|
|
|
|
|
] @keyword.function
|
|
|
|
|
|
|
|
|
|
(method
|
|
|
|
|
"end" @keyword.function)
|
|
|
|
|
|
2020-06-19 09:59:27 -04:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"case"
|
|
|
|
|
"else"
|
|
|
|
|
"elsif"
|
|
|
|
|
"if"
|
|
|
|
|
"unless"
|
|
|
|
|
"when"
|
|
|
|
|
"then"
|
|
|
|
|
] @keyword.conditional
|
2020-06-19 09:59:27 -04:00
|
|
|
|
2023-02-24 06:38:02 -05:00
|
|
|
(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
|
|
|
"end" @keyword.conditional)
|
2023-02-24 06:38:02 -05:00
|
|
|
|
2020-06-19 09:59:27 -04:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"for"
|
|
|
|
|
"until"
|
|
|
|
|
"while"
|
|
|
|
|
"break"
|
|
|
|
|
"redo"
|
|
|
|
|
"retry"
|
|
|
|
|
"next"
|
|
|
|
|
] @keyword.repeat
|
2020-06-19 09:59:27 -04:00
|
|
|
|
2023-08-23 14:09:30 +03:00
|
|
|
(constant) @constant
|
2020-04-24 08:48:18 -04:00
|
|
|
|
2024-03-08 19:09:51 +09:00
|
|
|
((identifier) @keyword.modifier
|
|
|
|
|
(#any-of? @keyword.modifier "private" "protected" "public"))
|
2020-04-24 08:48:18 -04:00
|
|
|
|
2020-12-04 19:02:42 +00:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"rescue"
|
|
|
|
|
"ensure"
|
|
|
|
|
] @keyword.exception
|
2020-12-04 19:02:42 +00:00
|
|
|
|
2020-04-24 08:48:18 -04:00
|
|
|
; Function calls
|
|
|
|
|
"defined?" @function
|
|
|
|
|
|
|
|
|
|
(call
|
2024-01-06 15:05:50 +09:00
|
|
|
receiver: (constant)? @type
|
2024-03-21 20:44:35 +09:00
|
|
|
method: [
|
|
|
|
|
(identifier)
|
|
|
|
|
(constant)
|
|
|
|
|
] @function.call)
|
2020-04-24 08:48:18 -04:00
|
|
|
|
2020-09-20 15:48:48 +10:00
|
|
|
(program
|
2024-01-06 15:05:50 +09:00
|
|
|
(call
|
|
|
|
|
(identifier) @keyword.import)
|
|
|
|
|
(#any-of? @keyword.import "require" "require_relative" "load"))
|
2020-09-20 15:48:48 +10:00
|
|
|
|
2020-04-24 08:48:18 -04:00
|
|
|
; Function definitions
|
2024-01-06 15:05:50 +09:00
|
|
|
(alias
|
|
|
|
|
(identifier) @function)
|
|
|
|
|
|
|
|
|
|
(setter
|
|
|
|
|
(identifier) @function)
|
2020-04-24 08:48:18 -04:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(method
|
2024-03-21 20:44:35 +09:00
|
|
|
name: [
|
|
|
|
|
(identifier) @function
|
|
|
|
|
(constant) @type
|
|
|
|
|
])
|
2024-01-06 15:05:50 +09:00
|
|
|
|
|
|
|
|
(singleton_method
|
2024-03-21 20:44:35 +09:00
|
|
|
name: [
|
|
|
|
|
(identifier) @function
|
|
|
|
|
(constant) @type
|
|
|
|
|
])
|
2020-06-19 09:59:27 -04:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(class
|
|
|
|
|
name: (constant) @type)
|
2020-06-19 09:59:27 -04:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(module
|
|
|
|
|
name: (constant) @type)
|
2020-06-19 09:59:27 -04:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(superclass
|
|
|
|
|
(constant) @type)
|
2020-04-24 08:48:18 -04:00
|
|
|
|
|
|
|
|
; Identifiers
|
2020-06-19 09:59:27 -04:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
(class_variable)
|
|
|
|
|
(instance_variable)
|
2024-01-10 18:05:37 +02:00
|
|
|
] @variable.member
|
2020-04-24 08:48:18 -04:00
|
|
|
|
2020-05-11 11:54:59 -04:00
|
|
|
((identifier) @constant.builtin
|
2024-02-23 17:42:01 +09:00
|
|
|
(#any-of? @constant.builtin
|
|
|
|
|
"__callee__" "__dir__" "__id__" "__method__" "__send__" "__ENCODING__" "__FILE__" "__LINE__"))
|
2020-04-24 08:48:18 -04:00
|
|
|
|
2024-07-07 18:24:57 +03:00
|
|
|
((identifier) @function.builtin
|
2024-09-11 05:45:19 -07:00
|
|
|
(#any-of? @function.builtin "attr_reader" "attr_writer" "attr_accessor" "module_function"))
|
|
|
|
|
|
|
|
|
|
((call
|
|
|
|
|
!receiver
|
|
|
|
|
method: (identifier) @function.builtin)
|
|
|
|
|
(#any-of? @function.builtin "include" "extend" "prepend" "refine" "using"))
|
2024-07-07 18:24:57 +03:00
|
|
|
|
|
|
|
|
((identifier) @keyword.exception
|
|
|
|
|
(#any-of? @keyword.exception "raise" "fail" "catch" "throw"))
|
|
|
|
|
|
2020-12-18 13:51:18 +00:00
|
|
|
((constant) @type
|
2024-01-06 15:05:50 +09:00
|
|
|
(#not-lua-match? @type "^[A-Z0-9_]+$"))
|
2020-04-24 08:48:18 -04:00
|
|
|
|
2020-06-19 09:59:27 -04:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
(self)
|
|
|
|
|
(super)
|
|
|
|
|
] @variable.builtin
|
|
|
|
|
|
|
|
|
|
(method_parameters
|
|
|
|
|
(identifier) @variable.parameter)
|
|
|
|
|
|
|
|
|
|
(lambda_parameters
|
|
|
|
|
(identifier) @variable.parameter)
|
|
|
|
|
|
|
|
|
|
(block_parameters
|
|
|
|
|
(identifier) @variable.parameter)
|
|
|
|
|
|
|
|
|
|
(splat_parameter
|
|
|
|
|
(identifier) @variable.parameter)
|
|
|
|
|
|
|
|
|
|
(hash_splat_parameter
|
|
|
|
|
(identifier) @variable.parameter)
|
|
|
|
|
|
|
|
|
|
(optional_parameter
|
|
|
|
|
(identifier) @variable.parameter)
|
|
|
|
|
|
|
|
|
|
(destructured_parameter
|
|
|
|
|
(identifier) @variable.parameter)
|
|
|
|
|
|
|
|
|
|
(block_parameter
|
|
|
|
|
(identifier) @variable.parameter)
|
|
|
|
|
|
|
|
|
|
(keyword_parameter
|
|
|
|
|
(identifier) @variable.parameter)
|
2020-04-24 08:48:18 -04:00
|
|
|
|
2020-06-07 18:15:02 -04:00
|
|
|
; TODO: Re-enable this once it is supported
|
|
|
|
|
; ((identifier) @function
|
|
|
|
|
; (#is-not? local))
|
2020-04-24 08:48:18 -04:00
|
|
|
; Literals
|
2020-06-19 09:59:27 -04:00
|
|
|
[
|
2024-08-25 15:12:57 -07:00
|
|
|
(string_content)
|
|
|
|
|
(heredoc_content)
|
|
|
|
|
"\""
|
|
|
|
|
"`"
|
2024-01-06 15:05:50 +09:00
|
|
|
] @string
|
2020-06-19 09:59:27 -04:00
|
|
|
|
|
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
(heredoc_beginning)
|
|
|
|
|
(heredoc_end)
|
2024-01-10 18:05:37 +02:00
|
|
|
] @label
|
2021-01-25 13:49:39 -05:00
|
|
|
|
|
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
(bare_symbol)
|
|
|
|
|
(simple_symbol)
|
|
|
|
|
(delimited_symbol)
|
|
|
|
|
(hash_key_symbol)
|
|
|
|
|
] @string.special.symbol
|
|
|
|
|
|
2024-08-25 15:12:57 -07:00
|
|
|
(regex
|
|
|
|
|
(string_content) @string.regexp)
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2020-05-11 11:54:59 -04:00
|
|
|
(escape_sequence) @string.escape
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2020-04-24 08:48:18 -04:00
|
|
|
(integer) @number
|
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
|
|
|
(float) @number.float
|
2020-04-24 08:48:18 -04:00
|
|
|
|
2020-06-19 09:59:27 -04:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
(true)
|
|
|
|
|
(false)
|
|
|
|
|
] @boolean
|
2020-04-24 08:48:18 -04:00
|
|
|
|
2023-03-02 08:06:35 -05:00
|
|
|
(nil) @constant.builtin
|
|
|
|
|
|
|
|
|
|
(comment) @comment @spell
|
|
|
|
|
|
2024-09-11 04:20:29 -07:00
|
|
|
((program
|
|
|
|
|
.
|
|
|
|
|
(comment) @keyword.directive @nospell)
|
|
|
|
|
(#lua-match? @keyword.directive "^#!/"))
|
|
|
|
|
|
2023-03-02 08:06:35 -05:00
|
|
|
(program
|
|
|
|
|
(comment)+ @comment.documentation
|
|
|
|
|
(class))
|
|
|
|
|
|
|
|
|
|
(module
|
|
|
|
|
(comment)+ @comment.documentation
|
2024-01-06 15:05:50 +09:00
|
|
|
(body_statement
|
|
|
|
|
(class)))
|
2023-03-02 08:06:35 -05:00
|
|
|
|
|
|
|
|
(class
|
|
|
|
|
(comment)+ @comment.documentation
|
2024-01-06 15:05:50 +09:00
|
|
|
(body_statement
|
|
|
|
|
(method)))
|
2023-03-02 08:06:35 -05:00
|
|
|
|
|
|
|
|
(body_statement
|
|
|
|
|
(comment)+ @comment.documentation
|
|
|
|
|
(method))
|
|
|
|
|
|
2020-04-24 08:48:18 -04:00
|
|
|
; Operators
|
2020-06-19 09:59:27 -04:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"!"
|
|
|
|
|
"="
|
|
|
|
|
"=="
|
|
|
|
|
"==="
|
|
|
|
|
"<=>"
|
|
|
|
|
"=>"
|
|
|
|
|
"->"
|
|
|
|
|
">>"
|
|
|
|
|
"<<"
|
|
|
|
|
">"
|
|
|
|
|
"<"
|
|
|
|
|
">="
|
|
|
|
|
"<="
|
|
|
|
|
"**"
|
|
|
|
|
"*"
|
|
|
|
|
"/"
|
|
|
|
|
"%"
|
|
|
|
|
"+"
|
|
|
|
|
"-"
|
|
|
|
|
"&"
|
|
|
|
|
"|"
|
|
|
|
|
"^"
|
|
|
|
|
"&&"
|
|
|
|
|
"||"
|
|
|
|
|
"||="
|
|
|
|
|
"&&="
|
|
|
|
|
"!="
|
|
|
|
|
"%="
|
|
|
|
|
"+="
|
|
|
|
|
"-="
|
|
|
|
|
"*="
|
|
|
|
|
"/="
|
|
|
|
|
"=~"
|
|
|
|
|
"!~"
|
|
|
|
|
"?"
|
|
|
|
|
":"
|
|
|
|
|
".."
|
|
|
|
|
"..."
|
|
|
|
|
] @operator
|
2020-06-19 09:59:27 -04:00
|
|
|
|
|
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
","
|
|
|
|
|
";"
|
|
|
|
|
"."
|
2024-07-08 15:58:24 +02:00
|
|
|
"&."
|
2024-08-25 15:12:57 -07:00
|
|
|
"::"
|
2024-01-06 15:05:50 +09:00
|
|
|
] @punctuation.delimiter
|
2020-06-19 09:59:27 -04:00
|
|
|
|
2024-08-25 15:12:57 -07:00
|
|
|
(regex
|
|
|
|
|
"/" @punctuation.bracket)
|
|
|
|
|
|
|
|
|
|
(pair
|
|
|
|
|
":" @punctuation.delimiter)
|
|
|
|
|
|
2020-06-19 09:59:27 -04:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"("
|
|
|
|
|
")"
|
|
|
|
|
"["
|
|
|
|
|
"]"
|
|
|
|
|
"{"
|
|
|
|
|
"}"
|
|
|
|
|
"%w("
|
|
|
|
|
"%i("
|
|
|
|
|
] @punctuation.bracket
|
2020-05-11 11:54:59 -04:00
|
|
|
|
2024-08-25 15:12:57 -07:00
|
|
|
(block_parameters
|
|
|
|
|
"|" @punctuation.bracket)
|
|
|
|
|
|
2021-11-08 14:07:10 +01:00
|
|
|
(interpolation
|
|
|
|
|
"#{" @punctuation.special
|
2024-08-25 15:12:57 -07:00
|
|
|
"}" @punctuation.special)
|