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

Add functions to swap panes / windows across tmux / nvim #128

Open
voskresenie opened this issue Oct 25, 2024 · 1 comment
Open

Add functions to swap panes / windows across tmux / nvim #128

voskresenie opened this issue Oct 25, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@voskresenie
Copy link
Contributor

I realized the other day that it would be nice to have a feature that allows swapping tmux panes and nvim windows (splits) with the same keybinding without conflicting. This can't work perfectly seamlessly the way move does, because you can't intermix tmux panes with nvim windows, so I would understand if it's not something you're interested in adding to the plugin, but it could at least enable using the same binding for swapping panes as swapping windows.

Here is how I was thinking the logic would work:

swap_[direction]:
- if current pane is not nvim, then swap with pane in [direction] (if present) using tmux swap-pane
Example:
    From PaneA, call swap_right()
    -----------------      -----------------
    | Tmux  | Tmux  | ---> | Tmux  | Tmux  |
    | PaneA | PaneB | ---> | PaneB | PaneA |
    -----------------      -----------------

- if current pane /is/ nvim, and [direction] is another window inside the same nvim instance, swap the two windows, mimicking functionality of tmux pane swapping as closely as possible (not built in to nvim afaik)
Example:
    From WinA, call swap_right()
    ----------------------      ----------------------
    | Nvim | Nvim | Tmux | ---> | Nvim | Nvim | Tmux |
    | WinA | WinB | Pane | ---> | WinB | WinA | Pane |
    ----------------------      ----------------------

- if current pane is /nvim/, and [direction] is a different tmux pane (ie current nvim window is on the [direction] border of the current pane), swap current pane with [direction] pane using tmux swap-pane
Example:
    From WinB, call swap_right()
    ----------------------      ----------------------
    | Nvim | Nvim | Tmux | ---> | Tmux | Nvim | Nvim |
    | WinA | WinB | Pane | ---> | Pane | WinA | WinB |
    ----------------------      ----------------------

So, it would be pretty much how you would expect swapping to behave if nvim windows and tmux panes were all the same thing, except that instead of swapping an nvim window and tmux pane when on the border, it would have to swap the entire pane the nvim window is a part of (which may appear, visually, as if several panes were swapped at once). I realize that this aspect may be a poor experience and understand if it's not something you'd be interested in having in this plugin, but if you are interested, I have a version I can tidy up and send for PR.

@aserowy aserowy added the enhancement New feature or request label Oct 28, 2024
@aserowy
Copy link
Owner

aserowy commented Oct 30, 2024

to be clear: pr are welcome! It would be cool, to get unit tests up and running and an extended readme.

tyvm
Alexander

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

No branches or pull requests

2 participants