zellij-org / zellij

A terminal workspace with batteries included
https://zellij.dev
MIT License
21.95k stars 666 forks source link

Colliding keybindings as a config option #3724

Open blackxored opened 2 weeks ago

blackxored commented 2 weeks ago

Was very excited to hear about non-colliding keymaps, except I can't try them easily (I have a workaround) since it's only accessed through a configuration screen and there's not an actual configuration option that defines this behavior. My Zellij config is managed through Home Manager which has some support for KDL but not to the point I can copy the keybindings from non_colliding_default_keybinds into it. Would it be possible to have a simple boolean config option that I could toggle on and (while respecting any prior keybind modifications) sets this default keymap by default?

imsnif commented 2 weeks ago

Hey, glad you like the new non-colliding preset!

The preset includes a specific set of keybindings and a default mode in order to achieve this. If you press <Ctrl a> while selecting the config, it will save everything to your config file. I'm not a nix person and don't know how home manager works, but surely it can manage configuration in a language it does not know? Even if only making sure a configuration file is there verbatim?

blackxored commented 2 weeks ago

The config file with home manager turns read only, so it couldn't save the config.

batusai513 commented 2 weeks ago

Maybe related to this issue, when trying to save from the new configuration screen using <Ctrl a>, if the configuration file is a symlink (I'm using Stow to create the symlinks to my dotfiles), the changes are not being saved at all (the config.kdl file is not modified).

macintacos commented 2 weeks ago

Yeah I'm having some trouble here as well. I use the ZELLIJ_CONFIG_DIR variable to set my config file, and for whatever reason the presets are not being saved across sessions.

tlinford commented 2 weeks ago

Yeah I'm having some trouble here as well. I use the ZELLIJ_CONFIG_DIR variable to set my config file, and for whatever reason the presets are not being saved across sessions.

Just tested this out and:

mkdir zellij-config-test
env ZELLIJ_CONFIG_DIR=zellij-config-test zellij

then "apply & save" with unlock first selected.

then:

env ZELLIJ_CONFIG_DIR=zellij-config-test zellij

worked out alright for me, could there be something else going on?

Note that the first run screen is different than what you get with the config plugin, you have to use Ctrl a to update the config rather than enter to just apply it to the current session: screenshot-2024-11-06T21-15-12

screenshot-2024-11-06T21-13-04

tlinford commented 2 weeks ago

Maybe related to this issue, when trying to save from the new configuration screen using <Ctrl a>, if the configuration file is a symlink (I'm using Stow to create the symlinks to my dotfiles), the changes are not being saved at all (the config.kdl file is not modified).

Did you see the Configuration applied and saved to disk message.?

batusai513 commented 2 weeks ago

@tlinford I see no message when trying to save, just a blinking cursor for a split second

tlinford commented 2 weeks ago

@tlinford I see no message when trying to save, just a blinking cursor for a split second

I did a test with a symlinked config and it worked out alright, so something else must be up.

Do you have any errors in the log? did you by chance first apply and then apply and save? (i noticed the selected item looses focus in that case after doing apply which was a bit confusing).

batusai513 commented 2 weeks ago

@tlinford I just found out that the terminal app I use had that key combo already in use, that is why it was not saving, after removing that keybinding from the terminal, the save config worked, one weird thing is that the theme for current session is reset tho.

blackxored commented 1 week ago

There also seems to be an issue with the keybindings, I'm assuming related to being unable to write to the config file, but after 0.41 landed in nixpkgs the default keybindings don't work at all. I can see them on the UI but pressing them does nothing, I'm assuming there's a bug somewhere that assumes you would have gone through that configuration state. EDIT: running on a nix shell with no config throws, right after hitting enter on default keybinds. image This is definitely broken on Nix at this point, and I'm assuming not specific to home manager.

imsnif commented 1 week ago

There also seems to be an issue with the keybindings [...]

This is all fixed in main. Until it's released you can use a different terminal emulator (eg. Alacritty) and it should be fine.

blackxored commented 1 week ago

I’m pretty sure I tested git version as well, admittedly very early in my debugging. I couldn’t get through the setup phase. —On Nov 10, 2024, at 10:59 PM, Aram Drevekenin @.***> wrote:

There also seems to be an issue with the keybindings [...]

This is all fixed in main. Until it's released you can use a different terminal emulator (eg. Alacritty) and it should be fine.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

ThePaulMcBride commented 4 days ago

It's very possible I'm missing in in the docs, but what is the configuration option to set in the kdl file for this new non-colliding mode? It is such a good improvement!

imsnif commented 4 days ago

I wrote this higher in this thread, but the conversation kind of went elsewhere. So respectfully asking people: please don't use this thread for other stuff so that people can find this answer:

The preset includes a specific set of keybindings and a default mode in order to achieve this and cannot be reduced to just one option. If you press <Ctrl a> while selecting the config, it will save everything to your config file so you don't need to do anything extra.

basbebe commented 4 days ago

I, too, would find such a preset very helpful (for the same reasons as OP: Declarative config via Nix which creates a read-only generated config file).

austinbutler commented 3 days ago

I also thought there would be an option for this after seeing the release announcement.

Seems like this is what gets written to the config file by the TUI to enable it:

keybinds clear-defaults=true {
    locked {
        bind "Ctrl g" { SwitchToMode "normal"; }
    }
    pane {
        bind "left" { MoveFocus "left"; }
        bind "down" { MoveFocus "down"; }
        bind "up" { MoveFocus "up"; }
        bind "right" { MoveFocus "right"; }
        bind "c" { SwitchToMode "renamepane"; PaneNameInput 0; }
        bind "d" { NewPane "down"; SwitchToMode "locked"; }
        bind "e" { TogglePaneEmbedOrFloating; SwitchToMode "locked"; }
        bind "f" { ToggleFocusFullscreen; SwitchToMode "locked"; }
        bind "h" { MoveFocus "left"; }
        bind "j" { MoveFocus "down"; }
        bind "k" { MoveFocus "up"; }
        bind "l" { MoveFocus "right"; }
        bind "n" { NewPane; SwitchToMode "locked"; }
        bind "p" { SwitchToMode "normal"; }
        bind "r" { NewPane "right"; SwitchToMode "locked"; }
        bind "w" { ToggleFloatingPanes; SwitchToMode "locked"; }
        bind "x" { CloseFocus; SwitchToMode "locked"; }
        bind "z" { TogglePaneFrames; SwitchToMode "locked"; }
        bind "tab" { SwitchFocus; }
    }
    tab {
        bind "left" { GoToPreviousTab; }
        bind "down" { GoToNextTab; }
        bind "up" { GoToPreviousTab; }
        bind "right" { GoToNextTab; }
        bind "1" { GoToTab 1; SwitchToMode "locked"; }
        bind "2" { GoToTab 2; SwitchToMode "locked"; }
        bind "3" { GoToTab 3; SwitchToMode "locked"; }
        bind "4" { GoToTab 4; SwitchToMode "locked"; }
        bind "5" { GoToTab 5; SwitchToMode "locked"; }
        bind "6" { GoToTab 6; SwitchToMode "locked"; }
        bind "7" { GoToTab 7; SwitchToMode "locked"; }
        bind "8" { GoToTab 8; SwitchToMode "locked"; }
        bind "9" { GoToTab 9; SwitchToMode "locked"; }
        bind "[" { BreakPaneLeft; SwitchToMode "locked"; }
        bind "]" { BreakPaneRight; SwitchToMode "locked"; }
        bind "b" { BreakPane; SwitchToMode "locked"; }
        bind "h" { GoToPreviousTab; }
        bind "j" { GoToNextTab; }
        bind "k" { GoToPreviousTab; }
        bind "l" { GoToNextTab; }
        bind "n" { NewTab; SwitchToMode "locked"; }
        bind "r" { SwitchToMode "renametab"; TabNameInput 0; }
        bind "s" { ToggleActiveSyncTab; SwitchToMode "locked"; }
        bind "t" { SwitchToMode "normal"; }
        bind "x" { CloseTab; SwitchToMode "locked"; }
        bind "tab" { ToggleTab; }
    }
    resize {
        bind "left" { Resize "Increase left"; }
        bind "down" { Resize "Increase down"; }
        bind "up" { Resize "Increase up"; }
        bind "right" { Resize "Increase right"; }
        bind "+" { Resize "Increase"; }
        bind "-" { Resize "Decrease"; }
        bind "=" { Resize "Increase"; }
        bind "H" { Resize "Decrease left"; }
        bind "J" { Resize "Decrease down"; }
        bind "K" { Resize "Decrease up"; }
        bind "L" { Resize "Decrease right"; }
        bind "h" { Resize "Increase left"; }
        bind "j" { Resize "Increase down"; }
        bind "k" { Resize "Increase up"; }
        bind "l" { Resize "Increase right"; }
        bind "r" { SwitchToMode "normal"; }
    }
    move {
        bind "left" { MovePane "left"; }
        bind "down" { MovePane "down"; }
        bind "up" { MovePane "up"; }
        bind "right" { MovePane "right"; }
        bind "h" { MovePane "left"; }
        bind "j" { MovePane "down"; }
        bind "k" { MovePane "up"; }
        bind "l" { MovePane "right"; }
        bind "m" { SwitchToMode "normal"; }
        bind "n" { MovePane; }
        bind "p" { MovePaneBackwards; }
        bind "tab" { MovePane; }
    }
    scroll {
        bind "Alt left" { MoveFocusOrTab "left"; SwitchToMode "locked"; }
        bind "Alt down" { MoveFocus "down"; SwitchToMode "locked"; }
        bind "Alt up" { MoveFocus "up"; SwitchToMode "locked"; }
        bind "Alt right" { MoveFocusOrTab "right"; SwitchToMode "locked"; }
        bind "e" { EditScrollback; SwitchToMode "locked"; }
        bind "f" { SwitchToMode "entersearch"; SearchInput 0; }
        bind "Alt h" { MoveFocusOrTab "left"; SwitchToMode "locked"; }
        bind "Alt j" { MoveFocus "down"; SwitchToMode "locked"; }
        bind "Alt k" { MoveFocus "up"; SwitchToMode "locked"; }
        bind "Alt l" { MoveFocusOrTab "right"; SwitchToMode "locked"; }
        bind "s" { SwitchToMode "normal"; }
    }
    search {
        bind "c" { SearchToggleOption "CaseSensitivity"; }
        bind "n" { Search "down"; }
        bind "o" { SearchToggleOption "WholeWord"; }
        bind "p" { Search "up"; }
        bind "w" { SearchToggleOption "Wrap"; }
    }
    session {
        bind "c" {
            LaunchOrFocusPlugin "configuration" {
                floating true
                move_to_focused_tab true
            }
            SwitchToMode "locked"
        }
        bind "d" { Detach; }
        bind "o" { SwitchToMode "normal"; }
        bind "p" {
            LaunchOrFocusPlugin "plugin-manager" {
                floating true
                move_to_focused_tab true
            }
            SwitchToMode "locked"
        }
        bind "w" {
            LaunchOrFocusPlugin "session-manager" {
                floating true
                move_to_focused_tab true
            }
            SwitchToMode "locked"
        }
    }
    shared_among "normal" "locked" {
        bind "Alt left" { MoveFocusOrTab "left"; }
        bind "Alt down" { MoveFocus "down"; }
        bind "Alt up" { MoveFocus "up"; }
        bind "Alt right" { MoveFocusOrTab "right"; }
        bind "Alt +" { Resize "Increase"; }
        bind "Alt -" { Resize "Decrease"; }
        bind "Alt =" { Resize "Increase"; }
        bind "Alt [" { PreviousSwapLayout; }
        bind "Alt ]" { NextSwapLayout; }
        bind "Alt f" { ToggleFloatingPanes; }
        bind "Alt h" { MoveFocusOrTab "left"; }
        bind "Alt i" { MoveTab "left"; }
        bind "Alt j" { MoveFocus "down"; }
        bind "Alt k" { MoveFocus "up"; }
        bind "Alt l" { MoveFocusOrTab "right"; }
        bind "Alt n" { NewPane; }
        bind "Alt o" { MoveTab "right"; }
    }
    shared_except "locked" "renametab" "renamepane" {
        bind "Ctrl g" { SwitchToMode "locked"; }
        bind "Ctrl q" { Quit; }
    }
    shared_except "locked" "entersearch" {
        bind "enter" { SwitchToMode "locked"; }
    }
    shared_except "locked" "entersearch" "renametab" "renamepane" {
        bind "esc" { SwitchToMode "locked"; }
    }
    shared_except "locked" "entersearch" "renametab" "renamepane" "move" {
        bind "m" { SwitchToMode "move"; }
    }
    shared_except "locked" "entersearch" "search" "renametab" "renamepane" "session" {
        bind "o" { SwitchToMode "session"; }
    }
    shared_except "locked" "tab" "entersearch" "renametab" "renamepane" {
        bind "t" { SwitchToMode "tab"; }
    }
    shared_except "locked" "tab" "scroll" "entersearch" "renametab" "renamepane" {
        bind "s" { SwitchToMode "scroll"; }
    }
    shared_among "normal" "resize" "tab" "scroll" "prompt" "tmux" {
        bind "p" { SwitchToMode "pane"; }
    }
    shared_except "locked" "resize" "pane" "tab" "entersearch" "renametab" "renamepane" {
        bind "r" { SwitchToMode "resize"; }
    }
    shared_among "scroll" "search" {
        bind "PageDown" { PageScrollDown; }
        bind "PageUp" { PageScrollUp; }
        bind "left" { PageScrollUp; }
        bind "down" { ScrollDown; }
        bind "up" { ScrollUp; }
        bind "right" { PageScrollDown; }
        bind "Ctrl b" { PageScrollUp; }
        bind "Ctrl c" { ScrollToBottom; SwitchToMode "locked"; }
        bind "d" { HalfPageScrollDown; }
        bind "Ctrl f" { PageScrollDown; }
        bind "h" { PageScrollUp; }
        bind "j" { ScrollDown; }
        bind "k" { ScrollUp; }
        bind "l" { PageScrollDown; }
        bind "u" { HalfPageScrollUp; }
    }
    entersearch {
        bind "Ctrl c" { SwitchToMode "scroll"; }
        bind "esc" { SwitchToMode "scroll"; }
        bind "enter" { SwitchToMode "search"; }
    }
    renametab {
        bind "esc" { UndoRenameTab; SwitchToMode "tab"; }
    }
    shared_among "renametab" "renamepane" {
        bind "Ctrl c" { SwitchToMode "locked"; }
    }
    renamepane {
        bind "esc" { UndoRenamePane; SwitchToMode "pane"; }
    }
}

default_mode "locked"