Skip to content
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

Include trailing seperators/whitespace on c or d #13

Open
FredeEB opened this issue Apr 24, 2022 · 2 comments
Open

Include trailing seperators/whitespace on c or d #13

FredeEB opened this issue Apr 24, 2022 · 2 comments

Comments

@FredeEB
Copy link

FredeEB commented Apr 24, 2022

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

@mfussenegger
Copy link
Owner

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

@FredeEB
Copy link
Author

FredeEB commented Sep 5, 2022

Those are good suggestions. The only thing I'm really missing currently, is time 😅
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 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants