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(Config): Make Modes Configurable #248

Open
a-kenji opened this issue Apr 3, 2021 · 5 comments
Open

Feature(Config): Make Modes Configurable #248

a-kenji opened this issue Apr 3, 2021 · 5 comments
Labels
config Improvements to the configuration system enhancement New feature or request

Comments

@a-kenji
Copy link
Contributor

a-kenji commented Apr 3, 2021

Defining new modes via the config file (and keybinds to switch to them)

Originally posted by @khs26 in #224 (comment)

Would it be desirable, or even practical to let users create their own modes?
How would that look like?

@SaintFenix
Copy link
Contributor

I'm a definite +1 on this, this would give us alot more ability to allow different bindings, and allow those who use other multiplexers to move over to Zellij easily. It could also create a cottage industry of making configurations for Zellij.

@a-kenji a-kenji added the config Improvements to the configuration system label Apr 25, 2021
@Aidan-Chelig
Copy link

This! Custom modes is the one thing holding me back from using Zellij daily!

@wis
Copy link

wis commented Nov 18, 2023

here's my use case:

I want to be able to:

  • use modes and key sequences for everything you can do in Zellij (Vim style)
  • define keys sequences, ideally with built-in syntax, e.g. p with hjkl using e.g. bind "ph" {} / bind "pj" {} / bind "pk" {} / bind "pl" {} to e.g. open a pane in that direction
    • in a similar fashion to how you can do dw to delete a word in Vim
    • currently, in a hacky way, you can already define key sequences using modes, e.g. pane actions/sequences that start with p use the built-in pane mode that is entered with p by default. but this is not optimal for ease of use or readability, and we only have a couple of built-in modes.
      • the ability to have more modes, custom modes, can enable you to define more key sequences for other actions you can do in Zellij.
  • use the Lock mode of zellij as the "Insert" mode and only that mode to type text or use any shortcut for the program running inside Zellij and not worry about conflicts with Zellij's shortcuts.
    • this is similar to how Vimium, the browser extension, has an "Insert" mode that allows all input to pass through to the web page (except Esc).

here's my basic config.kdl:

// to override the default keybindings completely, set property "clear-defaults=true"
keybinds clear-defaults=true {
    shared {
        //bind "Esc" { SwitchToMode "Normal"; } //can't use it because vim uses it
        bind "Alt z" { SwitchToMode "Normal"; }
    }
    normal {
        // disable all keys
        bind "`" "1"    "2"    "3"    "4"    "5"    "6"    "7"    "8"    "9"    "0"    "-"  "="    "\\"  "Backspace" \
             "~" "!"    "@"    "#"    "$"    "%"    "^"    "&"    "*"    "("    ")"    "_"  "+"    "|" \
        "Tab" ";"    "q"    "w"    "f"    "p"    "b"    "'"    "l"    "u"    "y"    "j"    "]" \
        "Tab" ":"    "Q"    "W"    "F"    "P"    "B"    "\""    "L"    "U"    "Y"    "J"    "}" \
        "/"    "a"    "r"    "s"    "t"    "g"    "k"    "n"    "e"    "i"    "o"    "Enter" \
        "?"    "A"    "R"    "S"    "T"    "G"    "K"    "N"    "E"    "I"    "O" "Enter" \
        "z"    "x"    "c"    "v"    "d"    "["    "h"    "m"    ","    "." \
        "Z"    "X"    "C"    "V"    "D"    "{"    "H"    "M"    "<"    ">"  {}
        bind "Space" "Esc" {}
        bind "h" { MoveFocus "Left"; }
        bind "j" { MoveFocus "Down"; }
        bind "k" { MoveFocus "Up"; }
        bind "l" { MoveFocus "Right"; }
        bind "p" { SwitchToMode "Pane"; } // enter pane mode
    }
    locked {
    }
    pane {
        bind /*ph*/ "h" { NewPane "Left"; SwitchToMode "Normal"; MovePane "Left"; } 
        bind /*pj*/ "j" { NewPane "Down"; SwitchToMode "Normal"; } 
        bind /*pk*/ "k" { NewPane "Up"; SwitchToMode "Normal"; MovePane "Up"; } 
        bind /*pl*/ "l" { NewPane "Right"; SwitchToMode "Normal"; } 
        bind /*px*/ "x" { CloseFocus; SwitchToMode "Normal"; } 
        bind /*pc*/ "c" { MovePaneBackwards; }
        bind /*pf*/ "f" { ToggleFocusFullscreen; SwitchToMode "Normal"; }
    }
    shared_except "locked" {
        bind "i" { SwitchToMode "Locked"; } // enter insert mode
        bind "Ctrl q" { Quit; }
    }
}

EDIT: after posting this comment, and editing it over and over to improve readability, come to think of it, I realized that an issue should be opened for a feature request for binding key sequences, and I opened one (#2948), therefore, if you see this comment as off-topic, please mark it as such.

@diminishedprime
Copy link

I'd also like to express a desire to have custom modes. I'd like to put everything behind a "leader key" and while I can kind of get this behavior by using locked mode as the "leader" mode, that means I can't use locked mode as passthrough for input in emacs, etc.

Custom modes would allow me to create a top-level "mode" that can only be reached through one binding, and then everything else can be reached from there.

@Joseph-D-Bradshaw
Copy link

I think implementing something like this, or allowing me to set some "leader" options by setting the locked mode, and then after my input going back to unlocked would be great. I can set locked to ctrl space just fine, but then I find myself hitting it again to go back in and out of locked mode after I have done my desired input.

A "vim" approach to modes would be cool, as I am trying to step away from tmux which goes very well with neovim as I like the batteries included of zellij. After maintaining my own neovim setup for years, now I build ontop of LazyVim, to me Zellij is similar in that dynamic for me regarding multiplexers. Sane defaults, nice useful things out the box, easy to customize (LazyVim makes it trivial with the Lazy package manager and extras you can enable).

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

No branches or pull requests

6 participants