diff options
Diffstat (limited to 'helix-22.03-x86_64-windows/runtime/queries/ruby')
5 files changed, 264 insertions, 0 deletions
diff --git a/helix-22.03-x86_64-windows/runtime/queries/ruby/highlights.scm b/helix-22.03-x86_64-windows/runtime/queries/ruby/highlights.scm new file mode 100644 index 0000000..898f8f7 --- /dev/null +++ b/helix-22.03-x86_64-windows/runtime/queries/ruby/highlights.scm @@ -0,0 +1,146 @@ +; 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) + +; Identifiers + +[ + (class_variable) + (instance_variable) +] @variable.other.member + +((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 + +[ + (string) + (bare_string) + (subshell) + (heredoc_body) + (heredoc_beginning) +] @string + +[ + (simple_symbol) + (delimited_symbol) + (hash_key_symbol) + (bare_symbol) +] @string.special.symbol + +(regex) @string.regexp +(escape_sequence) @constant.character.escape + +[ + (integer) + (float) +] @constant.numeric.integer + +[ + (nil) + (true) + (false) +]@constant.builtin + +(interpolation + "#{" @punctuation.special + "}" @punctuation.special) @embedded + +(comment) @comment + +; Operators + +[ +"=" +"=>" +"->" +] @operator + +[ + "," + ";" + "." +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" + "%w(" + "%i(" +] @punctuation.bracket diff --git a/helix-22.03-x86_64-windows/runtime/queries/ruby/indents.toml b/helix-22.03-x86_64-windows/runtime/queries/ruby/indents.toml new file mode 100644 index 0000000..b417751 --- /dev/null +++ b/helix-22.03-x86_64-windows/runtime/queries/ruby/indents.toml @@ -0,0 +1,25 @@ +indent = [ + "argument_list", + "array", + "begin", + "block", + "call", + "class", + "case", + "do_block", + "elsif", + "if", + "hash", + "method", + "module", + "singleton_class", + "singleton_method", +] + +outdent = [ + ")", + "}", + "]", + "end", + "when", +] diff --git a/helix-22.03-x86_64-windows/runtime/queries/ruby/injections.scm b/helix-22.03-x86_64-windows/runtime/queries/ruby/injections.scm new file mode 100644 index 0000000..321c90a --- /dev/null +++ b/helix-22.03-x86_64-windows/runtime/queries/ruby/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/helix-22.03-x86_64-windows/runtime/queries/ruby/locals.scm b/helix-22.03-x86_64-windows/runtime/queries/ruby/locals.scm new file mode 100644 index 0000000..393caaf --- /dev/null +++ b/helix-22.03-x86_64-windows/runtime/queries/ruby/locals.scm @@ -0,0 +1,27 @@ +((method) @local.scope + (#set! local.scope-inherits false)) + +[ + (lambda) + (block) + (do_block) +] @local.scope + +(block_parameter (identifier) @local.definition) +(block_parameters (identifier) @local.definition) +(destructured_parameter (identifier) @local.definition) +(hash_splat_parameter (identifier) @local.definition) +(lambda_parameters (identifier) @local.definition) +(method_parameters (identifier) @local.definition) +(splat_parameter (identifier) @local.definition) + +(keyword_parameter name: (identifier) @local.definition) +(optional_parameter name: (identifier) @local.definition) + +(identifier) @local.reference + +(assignment left: (identifier) @local.definition) +(operator_assignment left: (identifier) @local.definition) +(left_assignment_list (identifier) @local.definition) +(rest_assignment (identifier) @local.definition) +(destructured_left_assignment (identifier) @local.definition) diff --git a/helix-22.03-x86_64-windows/runtime/queries/ruby/tags.scm b/helix-22.03-x86_64-windows/runtime/queries/ruby/tags.scm new file mode 100644 index 0000000..47ba1eb --- /dev/null +++ b/helix-22.03-x86_64-windows/runtime/queries/ruby/tags.scm @@ -0,0 +1,64 @@ +; Method definitions + +( + (comment)* @doc + . + [ + (method + name: (_) @name) @definition.method + (singleton_method + name: (_) @name) @definition.method + ] + (#strip! @doc "^#\\s*") + (#select-adjacent! @doc @definition.method) +) + +(alias + name: (_) @name) @definition.method + +(setter + (identifier) @ignore) + +; Class definitions + +( + (comment)* @doc + . + [ + (class + name: [ + (constant) @name + (scope_resolution + name: (_) @name) + ]) @definition.class + (singleton_class + value: [ + (constant) @name + (scope_resolution + name: (_) @name) + ]) @definition.class + ] + (#strip! @doc "^#\\s*") + (#select-adjacent! @doc @definition.class) +) + +; Module definitions + +( + (module + name: [ + (constant) @name + (scope_resolution + name: (_) @name) + ]) @definition.module +) + +; Calls + +(call method: (identifier) @name) @reference.call + +( + [(identifier) (constant)] @name @reference.call + (#is-not? local) + (#not-match? @name "^(lambda|load|require|require_relative|__FILE__|__LINE__)$") +) |