Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'runtime/queries/ruby/highlights.scm')
| -rw-r--r-- | runtime/queries/ruby/highlights.scm | 241 |
1 files changed, 98 insertions, 143 deletions
diff --git a/runtime/queries/ruby/highlights.scm b/runtime/queries/ruby/highlights.scm index cd6f1723..8617d6f0 100644 --- a/runtime/queries/ruby/highlights.scm +++ b/runtime/queries/ruby/highlights.scm @@ -1,43 +1,87 @@ -; Operators +; Keywords + [ -":" -"?" -"~" -"=>" -"->" -"!" -] @operator + "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 -(assignment - "=" @operator) +((identifier) @keyword + (#match? @keyword "^(private|protected|public)$")) -(operator_assignment - operator: ["+=" "-=" "*=" "**=" "/=" "||=" "|=" "&&=" "&=" "%=" ">>=" "<<=" "^="] @operator) +; Function calls -(binary - operator: ["/" "|" "==" "===" "||" "&&" ">>" "<<" "<" ">" "<=" ">=" "&" "^" "!~" "=~" "<=>" "**" "*" "!=" "%" "-" "+"] @operator) +((identifier) @function.method.builtin + (#eq? @function.method.builtin "require")) -(range - operator: [".." "..."] @operator) +"defined?" @function.method.builtin -[ - "," - ";" - "." - "&." -] @punctuation.delimiter +(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 [ - "|" - "(" - ")" - "[" - "]" - "{" - "}" - "%w(" - "%i(" -] @punctuation.bracket + (class_variable) + (instance_variable) +] @property + +((identifier) @constant.builtin + (#match? @constant.builtin "^__(FILE|LINE|ENCODING)__$")) + +((constant) @constant + (#match? @constant "^[A-Z\\d_]+$")) + +(constant) @constructor + +(self) @variable.builtin +(super) @variable.builtin + +(block_parameter (identifier) @variable.parameter) +(block_parameters (identifier) @variable.parameter) +(destructured_parameter (identifier) @variable.parameter) +(hash_splat_parameter (identifier) @variable.parameter) +(lambda_parameters (identifier) @variable.parameter) +(method_parameters (identifier) @variable.parameter) +(splat_parameter (identifier) @variable.parameter) + +(keyword_parameter name: (identifier) @variable.parameter) +(optional_parameter name: (identifier) @variable.parameter) + +((identifier) @function.method + (#is-not? local)) +(identifier) @variable ; Literals @@ -52,24 +96,23 @@ [ (simple_symbol) (delimited_symbol) + (hash_key_symbol) (bare_symbol) ] @string.special.symbol -(pair key: ((_)":" @string.special.symbol) @string.special.symbol) - (regex) @string.regexp -(escape_sequence) @constant.character.escape +(escape_sequence) @escape [ (integer) (float) -] @constant.numeric.integer +] @number [ (nil) (true) (false) -] @constant.builtin +]@constant.builtin (interpolation "#{" @punctuation.special @@ -77,115 +120,27 @@ (comment) @comment -; Identifiers - -((identifier) @function.method - (#is-not? local)) - -[ - (identifier) -] @variable - -[ - (class_variable) - (instance_variable) -] @variable.other.member - -(constant) @constructor - -((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)$")) - -((constant) @constant - (#match? @constant "^[A-Z\\d_]+$")) - -(self) @variable.builtin -(super) @function.builtin - -[(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) -(block_parameter (identifier) @variable.parameter) -(block_parameters (identifier) @variable.parameter) - -; Function definitions - -(alias (identifier) @function.method) -(setter (identifier) @function.method) -(method name: [(identifier) (constant)] @function.method) -(singleton_method name: [(identifier) (constant)] @function.method) - -; Function calls - -(call - method: [(identifier) (constant)] @function.method) - -((identifier) @function.builtin - (#match? @function.builtin "^(attr|attr_accessor|attr_reader|attr_writer|include|prepend|refine|private|protected|public)$")) - -"defined?" @function.builtin - -; Keywords - -[ - "BEGIN" - "END" - "alias" - "begin" - "class" - "do" - "end" - "module" - "in" - "rescue" - "ensure" -] @keyword - -[ - "if" - "else" - "elsif" - "when" - "case" - "unless" - "then" -] @keyword.control.conditional - -[ - "for" - "while" - "retry" - "until" - "redo" -] @keyword.control.repeat +; Operators [ - "yield" - "return" - "next" - "break" -] @keyword.control.return +"=" +"=>" +"->" +] @operator [ - "def" - "undef" -] @keyword.function - -((identifier) @keyword.control.import - (#match? @keyword.control.import "^(require|require_relative|load|autoload)$")) + "," + ";" + "." +] @punctuation.delimiter [ - "or" - "and" - "not" -] @keyword.operator - -((identifier) @keyword.control.exception - (#match? @keyword.control.exception "^(raise|fail)$")) + "(" + ")" + "[" + "]" + "{" + "}" + "%w(" + "%i(" +] @punctuation.bracket |