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 | 253 |
1 files changed, 126 insertions, 127 deletions
diff --git a/runtime/queries/ruby/highlights.scm b/runtime/queries/ruby/highlights.scm index cd6f1723..7c69276b 100644 --- a/runtime/queries/ruby/highlights.scm +++ b/runtime/queries/ruby/highlights.scm @@ -1,98 +1,85 @@ -; Operators -[ -":" -"?" -"~" -"=>" -"->" -"!" -] @operator - -(assignment - "=" @operator) +; Keywords -(operator_assignment - operator: ["+=" "-=" "*=" "**=" "/=" "||=" "|=" "&&=" "&=" "%=" ">>=" "<<=" "^="] @operator) +[ + "BEGIN" + "END" + "alias" + "begin" + "class" + "do" + "end" + "module" + "in" + "rescue" + "ensure" +] @keyword -(binary - operator: ["/" "|" "==" "===" "||" "&&" ">>" "<<" "<" ">" "<=" ">=" "&" "^" "!~" "=~" "<=>" "**" "*" "!=" "%" "-" "+"] @operator) +[ + "if" + "else" + "elsif" + "when" + "case" + "unless" + "then" +] @keyword.control.conditional -(range - operator: [".." "..."] @operator) +[ + "for" + "while" + "retry" + "until" + "redo" +] @keyword.control.repeat [ - "," - ";" - "." - "&." -] @punctuation.delimiter + "yield" + "return" + "next" + "break" +] @keyword.control.return [ - "|" - "(" - ")" - "[" - "]" - "{" - "}" - "%w(" - "%i(" -] @punctuation.bracket + "def" + "undef" +] @keyword.function -; Literals +((identifier) @keyword.control.import + (#match? @keyword.control.import "^(require|require_relative|load|autoload)$")) [ - (string) - (bare_string) - (subshell) - (heredoc_body) - (heredoc_beginning) -] @string + "or" + "and" + "not" +] @keyword.operator -[ - (simple_symbol) - (delimited_symbol) - (bare_symbol) -] @string.special.symbol +((identifier) @keyword.control.exception + (#match? @keyword.control.exception "^(raise|fail)$")) -(pair key: ((_)":" @string.special.symbol) @string.special.symbol) +; Function calls -(regex) @string.regexp -(escape_sequence) @constant.character.escape +((identifier) @function.builtin + (#match? @function.builtin "^(attr|attr_accessor|attr_reader|attr_writer|include|prepend|refine|private|protected|public)$")) -[ - (integer) - (float) -] @constant.numeric.integer +"defined?" @function.builtin -[ - (nil) - (true) - (false) -] @constant.builtin +(call + method: [(identifier) (constant)] @function.method) -(interpolation - "#{" @punctuation.special - "}" @punctuation.special) @embedded +; Function definitions -(comment) @comment +(alias (identifier) @function.method) +(setter (identifier) @function.method) +(method name: [(identifier) (constant)] @function.method) +(singleton_method name: [(identifier) (constant)] @function.method) ; 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__)$")) @@ -102,6 +89,8 @@ ((constant) @constant (#match? @constant "^[A-Z\\d_]+$")) +(constant) @constructor + (self) @variable.builtin (super) @function.builtin @@ -115,77 +104,87 @@ (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) +((identifier) @function.method + (#is-not? local)) +[ + (identifier) +] @variable -; Function calls +; Literals -(call - method: [(identifier) (constant)] @function.method) +[ + (string) + (bare_string) + (subshell) + (heredoc_body) + (heredoc_beginning) +] @string -((identifier) @function.builtin - (#match? @function.builtin "^(attr|attr_accessor|attr_reader|attr_writer|include|prepend|refine|private|protected|public)$")) +[ + (simple_symbol) + (delimited_symbol) + (bare_symbol) +] @string.special.symbol -"defined?" @function.builtin +(pair key: ((_)":" @string.special.symbol) @string.special.symbol) -; Keywords +(regex) @string.regexp +(escape_sequence) @constant.character.escape [ - "BEGIN" - "END" - "alias" - "begin" - "class" - "do" - "end" - "module" - "in" - "rescue" - "ensure" -] @keyword + (integer) + (float) +] @constant.numeric.integer [ - "if" - "else" - "elsif" - "when" - "case" - "unless" - "then" -] @keyword.control.conditional + (nil) + (true) + (false) +] @constant.builtin -[ - "for" - "while" - "retry" - "until" - "redo" -] @keyword.control.repeat +(interpolation + "#{" @punctuation.special + "}" @punctuation.special) @embedded -[ - "yield" - "return" - "next" - "break" -] @keyword.control.return +(comment) @comment +; Operators [ - "def" - "undef" -] @keyword.function +":" +"?" +"~" +"=>" +"->" +"!" +] @operator -((identifier) @keyword.control.import - (#match? @keyword.control.import "^(require|require_relative|load|autoload)$")) +(assignment + "=" @operator) + +(operator_assignment + operator: ["+=" "-=" "*=" "**=" "/=" "||=" "|=" "&&=" "&=" "%=" ">>=" "<<=" "^="] @operator) + +(binary + operator: ["/" "|" "==" "===" "||" "&&" ">>" "<<" "<" ">" "<=" ">=" "&" "^" "!~" "=~" "<=>" "**" "*" "!=" "%" "-" "+"] @operator) + +(range + operator: [".." "..."] @operator) [ - "or" - "and" - "not" -] @keyword.operator + "," + ";" + "." + "&." +] @punctuation.delimiter -((identifier) @keyword.control.exception - (#match? @keyword.control.exception "^(raise|fail)$")) +[ + "|" + "(" + ")" + "[" + "]" + "{" + "}" + "%w(" + "%i(" +] @punctuation.bracket |