-
Notifications
You must be signed in to change notification settings - Fork 10
Conversation
Do you know about the vimscript-based plugin vim-exchange ? |
I did not know about vim-exchange, that looks cool, thanks. This does allow swapping any TS nodes. The hold key just grabs the current node, and the swap key calls |
FYI vim-exchange uses the same key for hold and swap, Basically it works like this: (And other variants for different modes) |
Oh, that makes sense. I'll implement that when I have a minute. |
@bew, I added that as I ended up having it clear the held node when it's swapped, as it behaved poorly when swapped twice. I'm considering removing |
Hi @spiderforrest , thank you for opening the PR. I wonder if you can add Visual Mode support for the feature as well. I ran into this example upon testing the PR: vim.keymap.set("n", "vx", "<cmd>STSSelectMasterNode<cr>")
local something = "something else"
vim.keymap.set("n", "vd", function()
vim.opt.opfunc = "v:lua.STSSwapCurrentNodeNextNormal_Dot"
return "g@l"
end, { silent = true, expr = true }) If the user wants to swap the |
I'd really like that functionality, I think it'd expand a lot on the use cases. This would be a really quick way to restructure code arbitrarily. I'm looking into implementing it now. |
That seems to work mostly alright. I just moved the other visual code from |
It works just fine on my end. I'll merge the PR for now, then I'll format with stylua and add "exit visual mode" after using |
I found myself needing to swap two nodes a far enough distance apart that sibling swapping was tedious, so I wrote small functions to 'hold' a node and then swap it with the focused node.
Notes: