aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--book/src/generated/lang-support.md2
-rw-r--r--languages.toml2
-rw-r--r--runtime/queries/ruby/textobjects.scm54
3 files changed, 56 insertions, 2 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index 776febdf..55b92862 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -61,7 +61,7 @@
| rescript | ✓ | ✓ | | `rescript-language-server` |
| rmarkdown | ✓ | | ✓ | `R` |
| ron | ✓ | | ✓ | |
-| ruby | ✓ | | ✓ | `solargraph` |
+| ruby | ✓ | ✓ | ✓ | `solargraph` |
| rust | ✓ | ✓ | ✓ | `rust-analyzer` |
| scala | ✓ | | ✓ | `metals` |
| solidity | ✓ | | | `solc` |
diff --git a/languages.toml b/languages.toml
index fd14fc57..6e78e78a 100644
--- a/languages.toml
+++ b/languages.toml
@@ -399,7 +399,7 @@ source = { git = "https://github.com/cstrahan/tree-sitter-nix", rev = "50f38ceab
name = "ruby"
scope = "source.ruby"
injection-regex = "ruby"
-file-types = ["rb"]
+file-types = ["rb", "rake", "rakefile", "irb", "gemfile", "gemspec"]
shebangs = ["ruby"]
roots = []
comment-token = "#"
diff --git a/runtime/queries/ruby/textobjects.scm b/runtime/queries/ruby/textobjects.scm
new file mode 100644
index 00000000..34888c17
--- /dev/null
+++ b/runtime/queries/ruby/textobjects.scm
@@ -0,0 +1,54 @@
+; Class
+(class) @class.around
+
+(class [(constant) (scope_resolution)] !superclass
+ (_)+ @class.inside)
+
+(class [(constant) (scope_resolution)] (superclass)
+ (_)+ @class.inside)
+
+(singleton_class
+ value: (_)
+ (_)+ @class.inside) @class.around
+
+(call
+ receiver: (constant) @class_const
+ method: (identifier) @class_method
+ (#match? @class_const "Class")
+ (#match? @class_method "new")
+ (do_block (_)+ @class.inside)) @class.around
+
+; Functions
+(method) @function.around
+
+(method (identifier) (method_parameters)
+ (_)+ @function.inside)
+
+(do_block !parameters
+ (_)+ @function.inside)
+
+(do_block (block_parameters)
+ (_)+ @function.inside)
+
+(block (block_parameters)
+ (_)+ @function.inside)
+
+(block !parameters
+ (_)+ @function.inside)
+
+(method (identifier) !parameters
+ (_)+ @function.inside)
+
+; Parameters
+(method_parameters
+ (_) @parameter.inside)
+
+(block_parameters
+ (_) @parameter.inside)
+
+(lambda_parameters
+ (_) @parameter.inside)
+
+; Comments
+(comment) @comment.inside
+(comment)+ @comment.around