nvim-treehopper
nvim-treehopper copied to clipboard
Include trailing seperators/whitespace on `c` or `d`
First, thanks for your work on this plugin, I use it habitually at this point.
There's one thing I'm missing though, but I have no idea if it's possible.
With this keybind
onoremap m :lua require('tsht').nodes<cr>
Consider this line
local cursor_node = root:descendant_for_range(lnum, col, lnum, col)
cursor here ^
Here, let's say I'd like to delete lnum under the cursor with dma in normal mode, I get this
local cursor_node = root:descendant_for_range(, col, lnum, col)
cursor here ^
But what I'd really like, is deleting all the way up to the next argument like this
local cursor_node = root:descendant_for_range(col, lnum, col)
cursor here ^
I might give this a shot myself, but an approach could be to pass an argument to the nodes function, as to whether or not it should delete only around the current or up to the next node
I'd accept a PR that adds something like this. I've introduced a opts parameter that can take a source function (a function returning the nodes to hint on, a node is a table with 4 entries { start_row, start_col, end_row, end_col }.
An option would be to also support source being a string to address the functions by name.
You could then add a new function that generates nodes - ideally basing it on the existing functions. E.g. you could maybe even run them and then post-process the nodes to extend the end
Those are good suggestions. The only thing I'm really missing currently, is time :sweat_smile: So it might be a bit before I get to look at this. So if anyone else stumbles upon this, and wants to give it a shot, I'm not going to stop them :100: