feat(tui): add configurable keybindings via config#217
Open
jongio wants to merge 3 commits into
Open
Conversation
Add a "keybindings" config map that remaps keyboard shortcuts. Keys are action names (search, quit, cmd_palette, etc.) and values are comma-separated key lists. Listed actions replace their default keys; unlisted actions keep their defaults. Unknown action names and keys that collide with another action are skipped with a logged warning, so a bad entry never leaves an action unreachable. Refactor keys.go so the package key map is built by defaultKeyMap() and add a registry of remappable actions plus a pure applyKeybindingOverrides that resolves conflicts deterministically. NewModel applies user overrides to the global key map before the UI reads it. Closes #210 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The deadcode check flags helpers used only by tests. Derive the action name set directly from keybindingEntries in the test instead. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
keybindingsconfig map so users can remap any keyboard shortcut in the TUI. Closes #210.Keys in the map are action names (for example
search,quit,cmd_palette) and values are comma-separated key lists (for example/,ctrl+f). Listed actions replace their default keys; any action you do not list keeps its default.What changed
internal/config/config.go: newKeybindings map[string]stringfield (keybindingsin JSON, omitempty).internal/tui/keys.go: refactored the package key map so it is produced bydefaultKeyMap(). Added a registry of remappable actions (keybindingEntries,keybindingActionNames), aparseKeyListhelper, and a pureapplyKeybindingOverridesthat returns a new key map plus warnings.internal/tui/model.go:NewModelapplies user overrides to the global key map right after theme resolution and logs any warnings via slog.README.md: documents the option, adds a "Customizing Keybindings" section with the full action-name list, and updates the example config.docs/keybindings.md: note at the top pointing to the remap capability.Behavior and safety
Acceptance criteria
config.json.Testing
go build ./...go vet ./...golangci-lint run ./...(0 issues)go test ./... -count=1(all packages pass)New
internal/tui/keys_test.gocovers no-op overrides, simple remaps, description preservation, unknown actions, empty values, default-conflict reverts, conflict-free swaps, two-override conflicts, key de-duplication, base immutability, and an end-to-endkey.Matchescheck on a remapped binding.