kylechui / nvim-surround

Add/change/delete surrounding delimiter pairs with ease. Written with :heart: in Lua.
MIT License
3.19k stars 62 forks source link

Add support targets.vim #1

Closed CRAG666 closed 2 years ago

CRAG666 commented 2 years ago

Add support for https://github.com/wellle/targets.vim: Example of what could be achieved if using targets in this plugin:

csq" change any quote for "" csq' change any quote for '

csb{ change any bracket for {} dsb delete any bracket

etc..

This is much faster than using the default way. This will open many possibilities. I would like to have this. Thank you very much. It's an excellent plugin :)

kylechui commented 2 years ago

Hmm... this project looks quite interesting---I'll definitely take some time to check it out. However, I'm still working out how to clean up the code and make it more maintainable, as well as patch some unintended behavior. Thanks for the kind words!

kylechui commented 2 years ago

After looking into it a bit more, I think that I might not implement everything that targets.vim does, but I'll try to at least add the aliases feature (i.e. q representing both ' and "). Behind the scenes, the plugin is running largely off of operatorfunc and not much more, so if I were to try adding things like ci, I would probably have to write a lot of text parsing myself, which I don't really have the time for at the moment.

If you have any ideas as to how things could be implemented, feel free to drop a reply or fork the project! Until then, I'll keep thinking about other ways this could be done.

CRAG666 commented 2 years ago

The alias approach might be the best; my point is to streamline the use of commands eg b = {, [, etc. or q = ` ' ", etc. or t = any tag( etc.). This gives the possibility to delete, change etc. As I said, it is easier to do this:

cst csq' dsq dst dsb csb[ etc.

kylechui commented 2 years ago

Yeah, that makes sense, I was mainly saying that I was going to put off implementing motions like 2cib and ci, for now, as they seem more involved. Looking through the code more closely, it looks like everything is parsed manually and does not use operatorfunc. I'll try my hand at implementing aliases soon, once I have the time.

kylechui commented 2 years ago

Honestly, I might just start rewriting the code base now since I think operatorfunc is getting in the way of me trying to accomplish other things. Hopefully it doesn't take too long so I can focus on implementing new features (i.e. aliasing, HTML tags, etc).

kylechui commented 2 years ago

Just as a small update: I've started work on another plugin called nvim-targets which tries to give access to a few more textobjects, i.e. aliasing different quotes via q or being able to refer to , as a surrounding delimiter. I've been a bit busy lately with school and stuff, but hopefully I'll have more time to work on this once summer break starts. I also want to try my hand at using Treesitter to implement changing/deleting surrounding HTML tags.

I'll try to be more transparent about what I'm working on by updating here

CRAG666 commented 2 years ago

This is incredible, I hope you can dedicate time to it, by the way, good luck with your studies. I already finished the race but I know how difficult it is. Greetings

kylechui commented 2 years ago

Hello! I think I've finished recovering from last quarter, I'll probably try to work on implementing this tomorrow!

CRAG666 commented 2 years ago

Great I would like to be able to use this complement already by card

kylechui commented 2 years ago

I've written a very basic version of aliasing over on the add-aliasing branch, so far all it supports is deleting quotes via dsq. If you want, feel free to give it a try and let me know what you think

CRAG666 commented 2 years ago

awesome, more funtions please

kylechui commented 2 years ago

Since I think it's probably better to let another plugin handle creating/managing custom text-objects, I'll be closing this issue.