mizlan / iswap.nvim

Interactively select and swap function arguments, list elements, and much more. Powered by tree-sitter.
MIT License
507 stars 22 forks source link

Feature: fallback to swapping lines if not in a list #80

Open IndianBoy42 opened 1 year ago

IndianBoy42 commented 1 year ago

I think it just makes sense, and I have found myself wanted to swap lines of code sometimes.

Could also fallback ISwap -> ISwapNode and ISwapWith -> ISwapNodeWith instead but I think this has much less utility.

mizlan commented 1 year ago

hmm.... why can't the user just call the right function? Also iswapnode would work with expressions spanning multiple lines while naively swapping lines wouldn't, and I'm not sure if the latter is in the scope of my plugin

IndianBoy42 commented 1 year ago

Maybe it's just my preference, I like having just one keybinding or as few keybindings as I can for similar functions. It's why ive moved from 10 hop keybindings with treesitter stuff to just using leap.nvim to go anywhere. The thought process then simplifies from "I want to swap these things, they are lines, click the right key sequence and then labels" to "I want to swap these things, click the key sequences and then labels", and hopefully if me and the plugin are in sync about where labels should go it works out.

My idea was to add that as a fallback when we're not in the list, so not changing anyone's workflow just trying to make a guess at what the user might want, they can always Esc and cancel it.

I might try and code it up as a user configurable fallback function, or even user configurable target selection, and see how it fits in my workflow