Skip to content

feat: Support custom keybindings via config.toml#46

Merged
bakayu merged 2 commits intomasterfrom
feat-custom-keybinding
Feb 28, 2026
Merged

feat: Support custom keybindings via config.toml#46
bakayu merged 2 commits intomasterfrom
feat-custom-keybinding

Conversation

@shatrughantwt
Copy link
Contributor

Fixes: #45

Summary

This PR adds support for user-configurable keybindings via config.toml with safe fallback to existing defaults.

Previously, all keybindings were hardcoded in internal/tui/keys.go.
Now users can override specific actions in [keybindings] without modifying source code.

What Changed

  • Added [keybindings] support in config parsing:
    • Extended config struct to include Keybindings map[string]string.
  • Added keybinding merge logic:
    • New KeyMapFromConfig(...) applies user overrides on top of DefaultKeyMap().
    • If a keybinding is missing, default is used.
    • Empty/invalid values are ignored and default remains.
    • Unknown actions are ignored (logged).
  • Wired keybinding resolution at startup:
    • initialModel() now loads config and initializes global keys from merged config + defaults.
  • Updated default generated config file:
    • Includes:
      theme = "GitHub Dark"
      
      [keybindings]

Example

theme = "GitHub Dark"

[keybindings]
quit = "x,ctrl+c"
up = "w,up"
down = "s,down"
toggle_help = "h"
open = "enter"

Notes

  • open is supported as an alias for checkout.
  • Keybindings are loaded on startup (restart required after config edits).

Tests

  • Added tests for:
    • override behavior
    • fallback behavior
    • multi-key parsing ("x,ctrl+c")
    • invalid/empty override fallback

Manual Verification

  • Verified remap works (quit = "x"):
    • q no longer quits
    • x quits
  • Verified fallback works when override is removed:
    • default q quits again.

Signed-off-by: shatrughan mishra <shatrughanm485@gmail.com>
@shatrughantwt shatrughantwt requested a review from bakayu February 25, 2026 15:14
Signed-off-by: shatrughan mishra <shatrughanm485@gmail.com>
@bakayu bakayu merged commit 524bc52 into master Feb 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Support custom keybindings via config.toml

2 participants