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

[Feature]: Support zellij #111

Open
1 task done
linux-cultist opened this issue May 8, 2023 · 20 comments
Open
1 task done

[Feature]: Support zellij #111

linux-cultist opened this issue May 8, 2023 · 20 comments
Assignees
Labels
enhancement New feature or request mux Issues relating to multiplexer backends PRs-welcome I'd love to see a PR for this

Comments

@linux-cultist
Copy link

Similar Issues

  • Before filing, I have searched for similar issues.

Description

Since this plugin has tmux support, could it also support zellij (https://zellij.dev/documentation)?

It's a popular and newer alternative to tmux and maybe it's easy to support it? Just posting this so you can see if it would be easy or hard.

@linux-cultist linux-cultist added the enhancement New feature or request label May 8, 2023
@mrjones2014 mrjones2014 added the mux Issues relating to multiplexer backends label May 8, 2023
@mrjones2014
Copy link
Owner

mrjones2014 commented May 8, 2023

Took a look at the docs to see if the CLI can implement our mux interface:

Lua method Zellij CLI support
is_in_session() Maybe possible with zellij list-sessions?
current_pane_id() No CLI command I could find. Is there an environment variable, maybe?
current_pane_at_edge(direction) No CLI command I could find. Can possibly be worked around with zellij cli move-focus back and forth.
current_pane_is_zoomed() zellij cli toggle-fullscreen exists, but no way to check if it is fullscreen. Not a critical component for the plugin, options may not work completely correctly.
next_pane(direction) zellij action move-focus [direction]
resize_pane(direction) zellij action resize [direction]
split_pane(direction) zellij action new-pane --direction [direction]

Unfortunately its not possible without current_pane_id(). Let me know if you know of a way to implement that I may have missed. is_in_session() could be shimmed by just checking if current_pane_id() returns nil or error.

@mrjones2014 mrjones2014 pinned this issue May 8, 2023
@linux-cultist
Copy link
Author

linux-cultist commented May 9, 2023

Thank you for checking! Maybe the author of zellij can add command line arguments for these things. I can check on their github page and ask, and point to this feature request above.

@towry
Copy link
Contributor

towry commented Nov 17, 2023

Can we just implement partially? Thanks.

@mrjones2014
Copy link
Owner

Unfortunately it's not possible without the ability to retrieve current pane ID, and it looks like the PR linked above has not merged yet to Zellij.

@mrjones2014 mrjones2014 removed the blocked This issue is blocked by another issue or some technical reason label May 2, 2024
@mrjones2014
Copy link
Owner

This is now unblocked!

@mrjones2014 mrjones2014 added PRs-welcome I'd love to see a PR for this blocked This issue is blocked by another issue or some technical reason and removed PRs-welcome I'd love to see a PR for this labels May 2, 2024
@mrjones2014
Copy link
Owner

Actually this is still blocked by Zellij not having conditional mappings. See zellij-org/zellij#967

@imsnif
Copy link

imsnif commented May 3, 2024

Actually this is still blocked by Zellij not having conditional mappings. See zellij-org/zellij#967

If I may - you can do this either with the Run keybinding and then insert conditionals in your favorite shell, or use a Zellij plugin (I think someone did this in the linked issue comment).

@mrjones2014
Copy link
Owner

From the linked plugin README:

Currently, I have not found a way to accomplish this, even through the zellij plugin system.

However, a Run keybind might work; do you know how that could be used to determine the foreground process name of the pane?

@imsnif
Copy link

imsnif commented May 3, 2024

I was referring to: zellij-org/zellij#967 (comment)

@mrjones2014
Copy link
Owner

Ah okay, I haven't tried that but maybe it will work.

@hiasr
Copy link

hiasr commented May 3, 2024

@mrjones2014 If I can help by making part of vim-zellij-navigator more generic, let me know!

@mrjones2014
Copy link
Owner

Thanks @hiasr ! Looking at the code, the only thing that jumps out at me is this:

https://github.com/hiasr/vim-zellij-navigator/blob/6dfb8c634de4478f9a1952700bce984ead3c8e5d/src/main.rs#L126-L132

Does this mean the user can't configure the keymaps? This is something all the other mux backends support.

@hiasr
Copy link

hiasr commented May 4, 2024

@mrjones2014 I just added configurable modifiers and the resize command in release 0.2.1, I think it now supports all the features necessary.

@mrjones2014 mrjones2014 added PRs-welcome I'd love to see a PR for this and removed blocked This issue is blocked by another issue or some technical reason labels May 6, 2024
@mrjones2014 mrjones2014 unpinned this issue May 6, 2024
@mrjones2014 mrjones2014 pinned this issue May 6, 2024
@mrjones2014
Copy link
Owner

Would someone be willing to contribute a simple Zellij config that sets up the required keymaps? Since I don't use Zellij, that will be quite a bit of work for me. If someone could help me with that, I can help with the Lua plugin changes.

Ideally the setup would be that we have a config stored in a directory like ./zellij/config.kdl, then I can update flake.nix to pull in zellij and in the flake's shellHook I can do alias zellij="zellij --config ./zellij/config.kdl"; that will make local development really easy

@mrjones2014
Copy link
Owner

also @hiasr does your plugin support resizing Zellij panes?

@hbiel
Copy link

hbiel commented May 7, 2024

I have never used these kind of plugins before so i don't know exactly what details may be needed in the configuration especially for the neovim integration.

The following configuration lets you

  • move focus or tab left / right on ctrl + h l
  • move focus down / up on ctrl + j k
  • resize panes on alt + h j k l

Just put it in your config.kdl. Hope this helps!

keybinds {
    shared_except "locked" {
        bind "Ctrl h" {
            MessagePlugin "https://github.com/hiasr/vim-zellij-navigator/releases/download/0.2.1/vim-zellij-navigator.wasm" {
                name "move_focus_or_tab";
                payload "left";
                move_mod "ctrl";
                resize_mod "alt";
            };
        }
        bind "Ctrl j" {
            MessagePlugin "https://github.com/hiasr/vim-zellij-navigator/releases/download/0.2.1/vim-zellij-navigator.wasm" {
                name "move_focus";
                payload "down";
                move_mod "ctrl";
                resize_mod "alt";
            };
        }
        bind "Ctrl k" {
            MessagePlugin "https://github.com/hiasr/vim-zellij-navigator/releases/download/0.2.1/vim-zellij-navigator.wasm" {
                name "move_focus";
                payload "up";
                move_mod "ctrl";
                resize_mod "alt";
            };
        }
        bind "Ctrl l" {
            MessagePlugin "https://github.com/hiasr/vim-zellij-navigator/releases/download/0.2.1/vim-zellij-navigator.wasm" {
                name "move_focus_or_tab";
                payload "right";
                move_mod "ctrl";
                resize_mod "alt";
            };
        }
        bind "Alt h" {
            MessagePlugin "https://github.com/hiasr/vim-zellij-navigator/releases/download/0.2.1/vim-zellij-navigator.wasm" {
                name "resize";
                payload "left";
                move_mod "ctrl";
                resize_mod "alt";
            };
        }
        bind "Alt j" {
            MessagePlugin "https://github.com/hiasr/vim-zellij-navigator/releases/download/0.2.1/vim-zellij-navigator.wasm" {
                name "resize";
                payload "down";
                move_mod "ctrl";
                resize_mod "alt";
            };
        }
        bind "Alt k" {
            MessagePlugin "https://github.com/hiasr/vim-zellij-navigator/releases/download/0.2.1/vim-zellij-navigator.wasm" {
                name "resize";
                payload "up";
                move_mod "ctrl";
                resize_mod "alt";
            };
        }
        bind "Alt l" {
            MessagePlugin "https://github.com/hiasr/vim-zellij-navigator/releases/download/0.2.1/vim-zellij-navigator.wasm" {
                name "resize";
                payload "right";
                move_mod "ctrl";
                resize_mod "alt";
            };
        }
    }
}

@mrjones2014
Copy link
Owner

Thanks @hbiel this helps a lot!

@nosduco
Copy link

nosduco commented Jul 12, 2024

Any updates on this integration or how I may be able to help? Would love to be able to use Zellij instead of tmux with smart-splits

@GrizzlT
Copy link

GrizzlT commented Jul 13, 2024

I like how this neovim plugin tells wezterm that neovim is active through a user variable. This brings a lot of robustness (no dependency on binary names, it's all in the application's behavior).

The latest version of zellij should make it possible to send something similar to a zellij plugin through pipes. I was thinking of creating a small plugin almost similar to https://github.com/hiasr/vim-zellij-navigator that would be specialized for this plugin but I haven't found the time yet to assess if a small contribution to vim-zellij-navigator would suffice to support all functionality featured by this neovim plugin.

Other than that I'm not entirely sure how to implement current_pane_at_edge(direction), is moving and checking if the pane stays the same enough? @mrjones2014 what does this function require exactly?

@mrjones2014
Copy link
Owner

Sorry yall, it’s been crazy at my day job, haven’t had time to dedicate to open source lately.

Other than that I'm not entirely sure how to implement current_pane_at_edge(direction), is moving and checking if the pane stays the same enough?

yeah, there’s another backend that does the same, with the caveat that the cursor should not have moved by the time the function returns (e.g. you can move to check, but then move it back to the original pane)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request mux Issues relating to multiplexer backends PRs-welcome I'd love to see a PR for this
Projects
None yet
Development

No branches or pull requests

8 participants