diff options
| author | Pham Huy Hoang <hoangtun0810@gmail.com> | 2024-01-06 15:05:50 +0900 |
|---|---|---|
| committer | Christian Clason <c.clason@uni-graz.at> | 2024-01-19 16:58:37 +0100 |
| commit | 57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9 (patch) | |
| tree | 70bf645539882b88e6fa129cefd30986b89bbac3 /queries/ruby | |
| parent | ci: add query lint job (diff) | |
| download | nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.tar nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.tar.gz nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.tar.bz2 nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.tar.lz nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.tar.xz nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.tar.zst nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.zip | |
chore: query formatting
Diffstat (limited to 'queries/ruby')
| -rw-r--r-- | queries/ruby/highlights.scm | 337 | ||||
| -rw-r--r-- | queries/ruby/injections.scm | 14 | ||||
| -rw-r--r-- | queries/ruby/locals.scm | 84 |
3 files changed, 253 insertions, 182 deletions
diff --git a/queries/ruby/highlights.scm b/queries/ruby/highlights.scm index d68c11847..6b8bb591c 100644 --- a/queries/ruby/highlights.scm +++ b/queries/ruby/highlights.scm @@ -1,32 +1,31 @@ ; Variables - (identifier) @variable + (global_variable) @variable.global ; Keywords - [ - "alias" - "begin" - "class" - "do" - "end" - "ensure" - "module" - "rescue" - "then" - ] @keyword + "alias" + "begin" + "class" + "do" + "end" + "ensure" + "module" + "rescue" + "then" +] @keyword [ - "return" - "yield" + "return" + "yield" ] @keyword.return [ - "and" - "or" - "in" - "not" + "and" + "or" + "in" + "not" ] @keyword.operator [ @@ -38,139 +37,170 @@ "end" @keyword.function) [ - "case" - "else" - "elsif" - "if" - "unless" - "when" - "then" - ] @keyword.conditional + "case" + "else" + "elsif" + "if" + "unless" + "when" + "then" +] @keyword.conditional (if "end" @keyword.conditional) [ - "for" - "until" - "while" - "break" - "redo" - "retry" - "next" - ] @keyword.repeat + "for" + "until" + "while" + "break" + "redo" + "retry" + "next" +] @keyword.repeat (constant) @constant ((identifier) @type.qualifier - (#any-of? @type.qualifier "private" "protected" "public")) + (#any-of? @type.qualifier "private" "protected" "public")) [ - "rescue" - "ensure" - ] @keyword.exception + "rescue" + "ensure" +] @keyword.exception ((identifier) @keyword.exception - (#any-of? @keyword.exception "fail" "raise")) + (#any-of? @keyword.exception "fail" "raise")) ; Function calls - "defined?" @function (call - receiver: (constant)? @type - method: [ - (identifier) - (constant) - ] @function.call - ) + receiver: (constant)? @type + method: + [ + (identifier) + (constant) + ] @function.call) (program - (call - (identifier) @keyword.import) - (#any-of? @keyword.import "require" "require_relative" "load")) + (call + (identifier) @keyword.import) + (#any-of? @keyword.import "require" "require_relative" "load")) ; Function definitions +(alias + (identifier) @function) + +(setter + (identifier) @function) + +(method + name: + [ + (identifier) @function + (constant) @type + ]) -(alias (identifier) @function) -(setter (identifier) @function) +(singleton_method + name: + [ + (identifier) @function + (constant) @type + ]) -(method name: [ - (identifier) @function - (constant) @type - ]) +(class + name: (constant) @type) -(singleton_method name: [ - (identifier) @function - (constant) @type - ]) +(module + name: (constant) @type) -(class name: (constant) @type) -(module name: (constant) @type) -(superclass (constant) @type) +(superclass + (constant) @type) ; Identifiers [ - (class_variable) - (instance_variable) - ] @label + (class_variable) + (instance_variable) +] @label ((identifier) @constant.builtin - (#match? @constant.builtin "^__(callee|dir|id|method|send|ENCODING|FILE|LINE)__$")) + (#match? @constant.builtin "^__(callee|dir|id|method|send|ENCODING|FILE|LINE)__$")) ((constant) @type - (#not-lua-match? @type "^[A-Z0-9_]+$")) + (#not-lua-match? @type "^[A-Z0-9_]+$")) [ - (self) - (super) - ] @variable.builtin + (self) + (super) +] @variable.builtin + +(method_parameters + (identifier) @variable.parameter) + +(lambda_parameters + (identifier) @variable.parameter) + +(block_parameters + (identifier) @variable.parameter) -(method_parameters (identifier) @variable.parameter) -(lambda_parameters (identifier) @variable.parameter) -(block_parameters (identifier) @variable.parameter) -(splat_parameter (identifier) @variable.parameter) -(hash_splat_parameter (identifier) @variable.parameter) -(optional_parameter (identifier) @variable.parameter) -(destructured_parameter (identifier) @variable.parameter) -(block_parameter (identifier) @variable.parameter) -(keyword_parameter (identifier) @variable.parameter) +(splat_parameter + (identifier) @variable.parameter) + +(hash_splat_parameter + (identifier) @variable.parameter) + +(optional_parameter + (identifier) @variable.parameter) + +(destructured_parameter + (identifier) @variable.parameter) + +(block_parameter + (identifier) @variable.parameter) + +(keyword_parameter + (identifier) @variable.parameter) ; TODO: Re-enable this once it is supported ; ((identifier) @function ; (#is-not? local)) - ; Literals - [ - (string) - (bare_string) - (subshell) - (heredoc_body) - ] @string + (string) + (bare_string) + (subshell) + (heredoc_body) +] @string [ - (heredoc_beginning) - (heredoc_end) - ] @constant + (heredoc_beginning) + (heredoc_end) +] @constant [ - (bare_symbol) - (simple_symbol) - (delimited_symbol) - (hash_key_symbol) - ] @string.special.symbol + (bare_symbol) + (simple_symbol) + (delimited_symbol) + (hash_key_symbol) +] @string.special.symbol + +(pair + key: (hash_key_symbol) + ":" @constant) -(pair key: (hash_key_symbol) ":" @constant) (regex) @string.regexp + (escape_sequence) @string.escape + (integer) @number + (float) @number.float [ - (true) - (false) - ] @boolean + (true) + (false) +] @boolean (nil) @constant.builtin @@ -182,75 +212,76 @@ (module (comment)+ @comment.documentation - (body_statement (class))) + (body_statement + (class))) (class (comment)+ @comment.documentation - (body_statement (method))) + (body_statement + (method))) (body_statement (comment)+ @comment.documentation (method)) ; Operators - [ - "!" - "=" - "==" - "===" - "<=>" - "=>" - "->" - ">>" - "<<" - ">" - "<" - ">=" - "<=" - "**" - "*" - "/" - "%" - "+" - "-" - "&" - "|" - "^" - "&&" - "||" - "||=" - "&&=" - "!=" - "%=" - "+=" - "-=" - "*=" - "/=" - "=~" - "!~" - "?" - ":" - ".." - "..." - ] @operator + "!" + "=" + "==" + "===" + "<=>" + "=>" + "->" + ">>" + "<<" + ">" + "<" + ">=" + "<=" + "**" + "*" + "/" + "%" + "+" + "-" + "&" + "|" + "^" + "&&" + "||" + "||=" + "&&=" + "!=" + "%=" + "+=" + "-=" + "*=" + "/=" + "=~" + "!~" + "?" + ":" + ".." + "..." +] @operator [ - "," - ";" - "." - ] @punctuation.delimiter + "," + ";" + "." +] @punctuation.delimiter [ - "(" - ")" - "[" - "]" - "{" - "}" - "%w(" - "%i(" - ] @punctuation.bracket + "(" + ")" + "[" + "]" + "{" + "}" + "%w(" + "%i(" +] @punctuation.bracket (interpolation "#{" @punctuation.special diff --git a/queries/ruby/injections.scm b/queries/ruby/injections.scm index 381d96b2f..7d8be5b23 100644 --- a/queries/ruby/injections.scm +++ b/queries/ruby/injections.scm @@ -1,11 +1,11 @@ -((comment) @injection.content - (#set! injection.language "comment")) +((comment) @injection.content + (#set! injection.language "comment")) (heredoc_body - (heredoc_content) @injection.content - (heredoc_end) @injection.language - (#downcase! @injection.language)) + (heredoc_content) @injection.content + (heredoc_end) @injection.language + (#downcase! @injection.language)) -(regex - (string_content) @injection.content +(regex + (string_content) @injection.content (#set! injection.language "regex")) diff --git a/queries/ruby/locals.scm b/queries/ruby/locals.scm index f08dcd49f..2a27c93a2 100644 --- a/queries/ruby/locals.scm +++ b/queries/ruby/locals.scm @@ -19,37 +19,77 @@ ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ; SOFTWARE. - -;;; DECLARATIONS AND SCOPES +; DECLARATIONS AND SCOPES (method) @local.scope + (class) @local.scope [ - (block) - (do_block) - ] @local.scope + (block) + (do_block) +] @local.scope (identifier) @local.reference + (constant) @local.reference + (instance_variable) @local.reference -(module name: (constant) @local.definition.namespace) -(class name: (constant) @local.definition.type) -(method name: [(identifier) (constant)] @local.definition.function) -(singleton_method name: [(identifier) (constant)] @local.definition.function) +(module + name: (constant) @local.definition.namespace) + +(class + name: (constant) @local.definition.type) + +(method + name: + [ + (identifier) + (constant) + ] @local.definition.function) + +(singleton_method + name: + [ + (identifier) + (constant) + ] @local.definition.function) + +(method_parameters + (identifier) @local.definition.var) + +(lambda_parameters + (identifier) @local.definition.var) + +(block_parameters + (identifier) @local.definition.var) + +(splat_parameter + (identifier) @local.definition.var) + +(hash_splat_parameter + (identifier) @local.definition.var) + +(optional_parameter + name: (identifier) @local.definition.var) + +(destructured_parameter + (identifier) @local.definition.var) + +(block_parameter + name: (identifier) @local.definition.var) + +(keyword_parameter + name: (identifier) @local.definition.var) + +(assignment + left: (_) @local.definition.var) -(method_parameters (identifier) @local.definition.var) -(lambda_parameters (identifier) @local.definition.var) -(block_parameters (identifier) @local.definition.var) -(splat_parameter (identifier) @local.definition.var) -(hash_splat_parameter (identifier) @local.definition.var) -(optional_parameter name: (identifier) @local.definition.var) -(destructured_parameter (identifier) @local.definition.var) -(block_parameter name: (identifier) @local.definition.var) -(keyword_parameter name: (identifier) @local.definition.var) +(left_assignment_list + (identifier) @local.definition.var) -(assignment left: (_) @local.definition.var) +(rest_assignment + (identifier) @local.definition.var) -(left_assignment_list (identifier) @local.definition.var) -(rest_assignment (identifier) @local.definition.var) -(destructured_left_assignment (identifier) @local.definition.var) +(destructured_left_assignment + (identifier) @local.definition.var) |
