Skip to content

feat: add configurable keymaps for all views via opts.keymaps - #151

Open
ldhnam wants to merge 2 commits into
SuperBo:mainfrom
ldhnam:feat/keymap-remapping
Open

feat: add configurable keymaps for all views via opts.keymaps#151
ldhnam wants to merge 2 commits into
SuperBo:mainfrom
ldhnam:feat/keymap-remapping

Conversation

@ldhnam

@ldhnam ldhnam commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Introduce a central keymap registry (lua/fugit2/view/keymaps.lua) as the single source of truth for default bindings across all views. Every keymap in every view is now configurable via opts.keymaps.<group>.<action>.

Changes

  • New registry lua/fugit2/view/keymaps.lua with defaults for 17 view groups: file_tree, commit_log, patch_unstaged, patch_staged, rebase, graph_log, graph_branch, graph_select, diff, stash_list, pick, input, confirm, blame, blame_file, blame_popup, patch
  • Helpers bind / bind_buf / resolve_keys for binding views and raw buffers
  • Config opts.keymaps accepts a single key, a list, false (disable), or "" (no-op)
  • Backward compatible: the deprecated file_tree_maps.menu is translated into keymaps.file_tree.menu_<action>; file_tree_maps.direct handling preserved
  • Docs: docs/keymap-remapping.md with full defaults tables; linked from README
  • Tests: keymaps_spec.lua (registry/merge/conflict) + config_spec.lua (legacy translation); full suite 205 passing

Example

opts = {
  keymaps = {
    file_tree = { stage_file = "S", unstage_file = false, menu_commit = "C" },
    rebase = { drop = { "x", "d" } },
  },
}

Note

This resolves the README TODO "Allow remap default key binding".

ldhnam added 2 commits August 9, 2026 16:34
Introduce a central keymap registry (lua/fugit2/view/keymaps.lua) as the
single source of truth for default bindings across all views. Every view
now binds its keymaps through keymaps.bind/bind_buf, and users can remap,
disable (false) or no-op () any binding via opts.keymaps.<group>.<action>.

Groups: file_tree, commit_log, patch_unstaged, patch_staged, rebase,
graph_log, graph_branch, graph_select, diff, stash_list, pick, input,
confirm, blame, blame_file, blame_popup, patch.

Backward compatibility: the deprecated file_tree_maps.menu option is
translated into keymaps.file_tree.menu_<action> in config.merge; the
legacy file_tree_maps.direct handling is preserved.

Adds keymaps_spec and config_spec covering defaults, overrides, disable,
no-op, mode handling and legacy translation. 205 tests pass.
Document the opts.keymaps configuration surface: the per-view groups,
default keybindings, disable/no-op semantics, and backward compatibility
with the deprecated file_tree_maps.menu. Link it from the README and drop
the stale docs/feature reference in the keymap registry comment.
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.

1 participant