zed/extensions/ruby/languages/ruby/highlights.scm
狐狸 f05b440572
Improve syntax highlights (#18728)
Closes #18722

- Replace the `@escape` capture name with `@string.escape` for escape
sequences in Go, Python, Regex, Racket, Ruby, and Scheme.
- Rust
  - Add syntax highlighting for escape sequences. Close #18722
- Fix the issue where `@punctuation.delimiter` is being overwritten by
`@operator`.
  - Add the period (".") to `@punctuation.delimiter`.

Release Notes:

- N/A
2024-10-09 19:25:46 +02:00

202 lines
2.5 KiB
Scheme

; Keywords
[
"alias"
"and"
"begin"
"break"
"case"
"class"
"def"
"do"
"else"
"elsif"
"end"
"ensure"
"for"
"if"
"in"
"module"
"next"
"or"
"rescue"
"retry"
"return"
"then"
"unless"
"until"
"when"
"while"
"yield"
] @keyword
((identifier) @keyword
(#match? @keyword "^(private|protected|public)$"))
; Function calls
((identifier) @function.method.builtin
(#eq? @function.method.builtin "require"))
"defined?" @function.method.builtin
(call
method: [(identifier) (constant)] @function.method)
; Function definitions
(alias (identifier) @function.method)
(setter (identifier) @function.method)
(method name: [(identifier) (constant)] @function.method)
(singleton_method name: [(identifier) (constant)] @function.method)
(method_parameters [
(identifier) @variable.parameter
(optional_parameter name: (identifier) @variable.parameter)
(keyword_parameter [name: (identifier) (":")] @variable.parameter)
])
(block_parameters (identifier) @variable.parameter)
; Identifiers
((identifier) @constant.builtin
(#match? @constant.builtin "^__(FILE|LINE|ENCODING)__$"))
(file) @constant.builtin
(line) @constant.builtin
(encoding) @constant.builtin
(hash_splat_nil
"**" @operator
) @constant.builtin
(global_variable) @constant
(constant) @type
((constant) @constant
(#match? @constant "^[A-Z\\d_]+$"))
(superclass
(constant) @type.super)
(superclass
(scope_resolution
(constant) @type.super))
(superclass
(scope_resolution
(scope_resolution
(constant) @type.super)))
(self) @variable.special
(super) @variable.special
[
(class_variable)
(instance_variable)
] @variable.member
; Literals
[
(string)
(bare_string)
(subshell)
(heredoc_body)
(heredoc_beginning)
] @string
[
(simple_symbol)
(delimited_symbol)
(hash_key_symbol)
(bare_symbol)
] @string.special.symbol
(regex) @string.regex
(escape_sequence) @string.escape
[
(integer)
(float)
] @number
[
(nil)
(true)
(false)
] @constant.builtin
(comment) @comment
; Operators
[
"!"
"~"
"+"
"-"
"**"
"*"
"/"
"%"
"<<"
">>"
"&"
"|"
"^"
">"
"<"
"<="
">="
"=="
"!="
"=~"
"!~"
"<=>"
"||"
"&&"
".."
"..."
"="
"**="
"*="
"/="
"%="
"+="
"-="
"<<="
">>="
"&&="
"&="
"||="
"|="
"^="
"=>"
"->"
(operator)
] @operator
[
","
";"
"."
"::"
] @punctuation.delimiter
[
"("
")"
"["
"]"
"{"
"}"
"%w("
"%i("
] @punctuation.bracket
(interpolation
"#{" @punctuation.special
"}" @punctuation.special) @embedded