-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add treesitter textobjects #728
Conversation
3704d71
to
a6a3724
Compare
Only for Go, Python and Rust for now.
Only has functions and class objects as of now.
a6a3724
to
400af6f
Compare
Only parameter.inside is implemented now, parameter.around will probably require custom predicates akin to nvim' `make-range` since we want to select a trailing comma too (a comma will be an anonymous node and matching against them doesn't work similar to named nodes)
I've added |
The default binding for parameter object is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work on this! Just some minor comments
let selection = doc.selection(view.id).clone().transform(|range| { | ||
match ch { | ||
'w' => textobject::textobject_word(text, range, objtype, count), | ||
'c' => textobject_treesitter("class", range), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think we want a better name than class here, maybe type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a comment up here about the naming, and I think we should aim for an intuitive name. I think "type" might be a bit misleading ? Though I guess the same can be said for "class" :|
361841c
to
a652a1e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go ahead and merge this 👍🏻
I would still like to find a better keyword than class
but we can always replace that later.
f
for functions andc
for classes, so for examplemac
will select around the current class. Currently only queries for Rust, Python and Golang are included.TODO
Future Works