Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .tsqueryrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@
"script": "Also captures the script name (for different purposes)",
"RUBY_TEST_NAME": "A ruby test name",
"_ruby-test": "A ruby test name"
},
"textobjects": {
"function.around": "An entire function definition or equivalent small section of a file.",
"function.inside": "The function body (the stuff within the braces).",
"class.around": "An entire class definition or equivalent large section of a file.",
"class.inside": "The contents of a class definition.",
"comment.around": "An entire comment (e.g. all adjacent line comments, or a block comment).",
"comment.inside": "The contents of a comment."
}
}
}
16 changes: 16 additions & 0 deletions languages/ruby/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
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

(module
body: (_)? @class.inside) @class.around

Expand All @@ -17,5 +25,13 @@
(method
body: (_)? @function.inside) @function.around

(do_block
body: (_)? @function.inside) @function.around

(block
body: (_)? @function.inside) @function.around

; Comments
(comment) @comment.inside

(comment)+ @comment.around
Loading