Repository navigation
feat: load keybindings from config file (#5 phase 2) - #31
Merged
Merged
Conversation
…phase 2) Phase 2 of #5. The TUI now reads an optional config file at `$XDG_CONFIG_HOME/markdown-browser/config.toml` (default `~/.config/...`) and layers it onto the built-in defaults. Each `[keys.<mode>]` table maps a chord string to an action name. Modes: normal / yank / toc / help / dir. Action names are the snake_case form of the `Action` enum (`cursor_down`, `history_back`, ...). Bindings merge into the defaults rather than replacing them — no way to unbind a default yet, deferred until the need shows up. Chord parser accepts `ctrl+` / `alt+` / `shift+` prefixes (any order, case-insensitive), single characters case-sensitive, named keys case-insensitive (`esc`, `enter`, `tab`, `backtab`, `space`, `left`/`right`/`up`/`down`, `home`/`end`, `pageup`/`pagedown`, `f1`–`f12`). `shift+tab` collapses to `BackTab` and `shift+<lower>` to the uppercase char before the existing SHIFT normalization runs. Parse failures are non-fatal: unknown keys, unknown actions, and unknown modes accumulate as warnings; the first warning surfaces in the status bar at startup (with a `+N more` suffix when there are more), TUI starts normally with the defaults left intact. Adds `serde` + `toml` (parse + serde features only). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.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.
Phase 2 of #5. Builds on #30 (action-map refactor): the TUI now reads an optional config file and merges user bindings onto the built-in defaults.
Closes #5.
Summary
\$XDG_CONFIG_HOME/markdown-browser/config.toml(default~/.config/markdown-browser/config.toml). Missing file is silent.[keys.normal]/[keys.yank]/[keys.toc]/[keys.help]/[keys.dir]. Each row is\"<chord>\" = \"<action_name>\".Actionenum (cursor_down,history_back,dir_go_up, ...). A test enforces the name table is complete so every shipped default round-trips throughfrom_name.ctrl+/alt+/shift+prefixes (any order, case-insensitive), single characters case-sensitive, and named keys /f1–f12case-insensitive.shift+tabcollapses toBackTabandshift+<lower>to the uppercase char before the existingSHIFTnormalization step runs.LoadedKeymaps::warnings. The TUI surfaces the first one in the status bar at startup with a(+N more)suffix when there are extras; defaults stay intact when a binding fails.\"shift+h\" = \"history_back\", bothHand[step back through history. Unbinding a default needs a future syntax (\"[\" = \"none\") — left out until requested.Deps added:
serde(derive) andtoml(parse + serde features, no rest of the surface area).Example
```toml
~/.config/markdown-browser/config.toml
[keys.normal]
"shift+h" = "history_back"
"shift+l" = "history_forward"
"ctrl+e" = "toggle_shortcodes"
[keys.dir]
"backspace" = "dir_go_up"
```
Test plan
Hnavigates back while[still does too (intentional merge). With deliberately broken config, status bar shows the parse warning and the TUI starts with defaults.🤖 Generated with Claude Code