jesseduffield / jesseduffield/lazygit
Keybind Chording
- Dominant language
- Go
- Stars
- 82.4k
- Forks
- 3k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 19
Description
I was going to wait before posting this but I saw in there was going to be keybind structure changes in a recent commit so now might be a good time. I have been experimenting with chording in lazygit for a few weeks and it feels like a natural improvement of the keybind system.
## Chording Benefits / What it Addresses
- Centralize keybinds that create popups today under a chording system
- This simplifies the creation of menus, allowing them to be built dynamically and new ones created by users
- As a side effect, it allows all keybinds to be accessible for rebinding, including actions inside (currently) static sub-menus since they would go through the same chording system
- Reduces cognitive load by compartmentalizing keybinds into groups and using mnemonics to make them easier to remember
- If someone wanted to, they could have more than 2 levels of chording, with as many submenus as they would like (not that it makes sense to have a lot of nested menus)
- Frees up a ton of keybinds when using it, as you can push the keybind 'that makes sense' for the action further down in a menu
- You can use `gg` to go to the top, which vim users will appreciate ;)
- It would also meet the request from people wanting a 'leader' key, as a common prefix could be used for every single non-navigating action
- Examples:
- `c` for commit
- commitChanges: "cc"
- commitChangesWithoutHook: "cw"
- amendLastCommit: "cA"
- commitChangesWithEditor: "ce"
- `p` for pull request
- createPullRequest: "pc"
- viewPullRequestOptions: "po"
- openPullRequestInBrowser: "pb"
- copyPullRequestURL: "py"
- `c` for cherry-pick
- cherryPickCopy: "cy"
- pasteCommits: "cp"
- resetCherryPick: "cr"
## Questions / Thoughts
- It would be important to keep the current keybinds and config working as they are, so this would not be a breaking change
- It might be interesting to have a sample chording config in the repo that leverages it more, to keep it optional but all users to switch to a chording-first keybind
- While the chording system would add to the code base, it would simplify the currently static menus
- We could keep the same popup menu as is currently there, and add the ability dynamically set the parameters (items, title, disabled states, hidden states, etc.)
- I would be very much interested in creating a PR for this, though it would take some time as there are a lot of moving parts and would want to ensure things are well implemented
## Related Issues
- `https://github.com/jesseduffield/lazygit/issues/3792#issuecomment-3940953230`
- `m` could be the prefix key for all `mark` actions
- `https://github.com/jesseduffield/lazygit/issues/883`
- Shortcut conflicts can be resolved with chording
- `https://github.com/jesseduffield/lazygit/issues/1712`
- Discusses chording
Contributor guide
Assessment
This issue has not been assessed yet.