hop.nvim icon indicating copy to clipboard operation
hop.nvim copied to clipboard

Feature: Use treesitter textobject awarness for the current context as where to jump

Open quantumfate opened this issue 1 year ago • 3 comments

Sup smoka! I would finally like to contribute to hop. I mostly use t and T to jump on the current line for faster navigation. Let me quickly brush over what's bugging me.

Lets consider the following line:

    compact_success_msg "Plugins cloned successfully."

Often you use motions such as ciw to quickly change a word and lets say I want to change the word success from the line above unfortunately ciw wont to the trick here neither does b or e as compact_success_msg is the whole node and none of these motions are aware of the substring success. So the simple solution is to use something like hop current line to quickly jump where you want the cursor to be.

Now my cursor is on the first s of the substring success and invoking my jump will leave me with the following options:

image

Depending on the length of the line this won't allow me to consistently establish a muscle memory for selecting the current actual word success because the hop selection counts all occurrences of the substring s on the current line and in case of the substring Plugins I'm presented with the jumptarget v instead of t.

image

This got me thinking that it could be useful to implement text object awarness to assign jumptargets in the current context to have a more consisten set of jump targets. Note: this enavitibly opens up a variety of new features of jumping behaviours such incremental adding of jump targets or a range of jump targets where the user is supposed to define two jump targets instead of one to make a selection for example.

This also opens up a variety of ways this could be implemented I wanted to know how you envision the future of hop and what I can do to help. Would be great if we could discuss the details. One possible way is to provide different schema queries from treesitter for different languages for example.

quantumfate avatar Aug 13 '23 14:08 quantumfate