ziontee113 / syntax-tree-surfer

A plugin for Neovim that helps you surf through your document and move elements around using the nvim-treesitter API.
MIT License
472 stars 10 forks source link

Repetitions? #2

Closed fsouza closed 2 years ago

fsouza commented 2 years ago

When swapping elements, it'd be cool to be able to support repetitions (so if I swap a block with the next one and want to continue moving it down I could just press .).

If this is reasonable, we could either integrate with vim-repeat or figure out repetition in some other way, let me know what you think!

ziontee113 commented 2 years ago

Ah shoot. I don't know how to implement that atm. Do you have any example / tutorial that I can follow? Ty :)

ziontee113 commented 2 years ago

I also want to add "Jump to next sibling" in Normal Mode as well. If I have some simple example on how to . repreat then I will do them all at once.

fsouza commented 2 years ago

I do not, sorry. I'd either integrate with vim-repeat or figure out how they do it.

ziontee113 commented 2 years ago

I wonder you you're using swapping? Do you use syntax-tree-surfer to swap primarily in normal mode or in visual mode?

fsouza commented 2 years ago

I wonder you you're using swapping? Do you use syntax-tree-surfer to swap primarily in normal mode or in visual mode?

I use swap in normal mode, but to be honest not as often. Just tried it in a file and realized that repetition would be really helpful.

One thing that would be great with swapping in normal mode is figuring out a better way to find the nodes that we want to swap. Maybe add support for custom queries or a filter closure.

ziontee113 commented 2 years ago

Well, in normal mode, you can only swap things vertically right now. Can check the node you want to swap with <cmd>lua require("syntax-tree-surfer").select()<cr>, you'll get used to the normal mode swapping behavior.

I think the strongest feature of syntax-tree-surfer right now is in Visual Mode, where you can see what you selecting and swapping. I personally use and to swap elements in visual mode. So I didn't had a plan to do dot repeat functionality.

fsouza commented 2 years ago

Well, in normal mode, you can only swap things vertically right now. Can check the node you want to swap with <cmd>lua require("syntax-tree-surfer").select()<cr>, you'll get used to the normal mode swapping behavior.

You can swap horizontally with require("syntax-tree-surfer").surf(direction, "normal", true).

What I want is not getting used to what gets swapped, but being able to customize it 😁 I find that using visual mode is inefficient and not repetition friendly (assuming repetition is available).

I'll try to think of a better idea and can send as a proposal if that's ok with you.

ziontee113 commented 2 years ago

Yeah cool man! I'll probably rewrite the plugin when I'm getter at Computer Science :) The current state of the .surf function is really not extendable. It's a lot of spagetti code in there.

ziontee113 commented 2 years ago

Close this issue since now the User can use Dot Repeat :) @fsouza