helix-mods/runtime/queries/ruby/highlights.scm

191 lines
3.3 KiB
Scheme
Raw Normal View History

2021-04-09 10:42:49 +02:00
; Keywords
[
"BEGIN"
"END"
2021-04-09 10:42:49 +02:00
"alias"
"begin"
"class"
"do"
"end"
"module"
"in"
2021-04-09 10:42:49 +02:00
"rescue"
"ensure"
] @keyword
[
"if"
"else"
"elsif"
2021-04-09 10:42:49 +02:00
"when"
"case"
"unless"
"then"
] @keyword.control.conditional
[
"for"
2021-04-09 10:42:49 +02:00
"while"
"retry"
"until"
"redo"
] @keyword.control.repeat
[
2021-04-09 10:42:49 +02:00
"yield"
"return"
"next"
"break"
] @keyword.control.return
[
"def"
"undef"
] @keyword.function
((identifier) @keyword.control.import
(#match? @keyword.control.import "^(require|require_relative|load|autoload)$"))
[
"or"
"and"
"not"
] @keyword.operator
2021-04-09 10:42:49 +02:00
((identifier) @keyword.control.exception
(#match? @keyword.control.exception "^(raise|fail)$"))
2021-04-09 10:42:49 +02:00
; Function calls
((identifier) @function.builtin
(#match? @function.builtin "^(attr|attr_accessor|attr_reader|attr_writer|include|prepend|refine|private|protected|public)$"))
2021-04-09 10:42:49 +02:00
"defined?" @function.builtin
2021-04-09 10:42:49 +02:00
(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)
; Identifiers
[
(class_variable)
(instance_variable)
] @variable.other.member
2021-04-09 10:42:49 +02:00
((identifier) @constant.builtin
(#match? @constant.builtin "^(__FILE__|__LINE__|__ENCODING__)$"))
((constant) @constant.builtin
(#match? @constant.builtin "^(ENV|ARGV|ARGF|RUBY_PLATFORM|RUBY_RELEASE_DATE|RUBY_VERSION|STDERR|STDIN|STDOUT|TOPLEVEL_BINDING)$"))
2021-04-09 10:42:49 +02:00
((constant) @constant
(#match? @constant "^[A-Z\\d_]+$"))
(constant) @constructor
(self) @variable.builtin
(super) @function.builtin
2021-04-09 10:42:49 +02:00
[(forward_parameter)(forward_argument)] @variable.parameter
(keyword_parameter name:((_)":" @variable.parameter) @variable.parameter)
(optional_parameter name:((_)"=" @operator) @variable.parameter)
(optional_parameter name: (identifier) @variable.parameter)
(splat_parameter name: (identifier) @variable.parameter) @variable.parameter
(hash_splat_parameter name: (identifier) @variable.parameter) @variable.parameter
(method_parameters (identifier) @variable.parameter)
2021-04-09 10:42:49 +02:00
(block_parameter (identifier) @variable.parameter)
(block_parameters (identifier) @variable.parameter)
((identifier) @function.method
(#is-not? local))
[
(identifier)
] @variable
2021-04-09 10:42:49 +02:00
; Literals
[
(string)
(bare_string)
(subshell)
(heredoc_body)
(heredoc_beginning)
] @string
[
(simple_symbol)
(delimited_symbol)
(bare_symbol)
] @string.special.symbol
(pair key: ((_)":" @string.special.symbol) @string.special.symbol)
2021-09-03 03:39:30 +02:00
(regex) @string.regexp
(escape_sequence) @constant.character.escape
2021-04-09 10:42:49 +02:00
[
(integer)
(float)
] @constant.numeric.integer
2021-04-09 10:42:49 +02:00
[
(nil)
(true)
(false)
] @constant.builtin
2021-04-09 10:42:49 +02:00
(interpolation
"#{" @punctuation.special
"}" @punctuation.special) @embedded
(comment) @comment
; Operators
[
":"
"?"
"~"
2021-04-09 10:42:49 +02:00
"=>"
"->"
"!"
2021-04-09 10:42:49 +02:00
] @operator
(assignment
"=" @operator)
(operator_assignment
operator: ["+=" "-=" "*=" "**=" "/=" "||=" "|=" "&&=" "&=" "%=" ">>=" "<<=" "^="] @operator)
(binary
operator: ["/" "|" "==" "===" "||" "&&" ">>" "<<" "<" ">" "<=" ">=" "&" "^" "!~" "=~" "<=>" "**" "*" "!=" "%" "-" "+"] @operator)
(range
operator: [".." "..."] @operator)
2021-04-09 10:42:49 +02:00
[
","
";"
"."
"&."
2021-04-09 10:42:49 +02:00
] @punctuation.delimiter
[
"|"
2021-04-09 10:42:49 +02:00
"("
")"
"["
"]"
"{"
"}"
"%w("
"%i("
] @punctuation.bracket