User config file for keybindings and comment file path#7
Conversation
rockorager
left a comment
There was a problem hiding this comment.
Reviewed locally. go test ./... passes on the PR branch, and a local merge with current origin/main was clean + tests passed.
Two small issues I noticed:
-
loadConfig()silently ignores config read errors and JSON unmarshal errors, so malformed config or a permission problem falls back to defaults without telling the user. Since this config can change the comment storage path, a typo could unexpectedly make comments load/save from the default path. I’d prefer returning an error from config loading and surfacing it fromRun. -
The PR description example uses
"comment_file": "~/.local/share/comview/comments.json", but the implementation passes the string directly toreview.LoadFile/SaveFile; Go won’t expand~, so that would be treated as a relative./~/.local/...path. Either expand leading~or update the docs/example to require a real absolute path.
No blockers beyond those UX/config correctness concerns.
|
Update: I missed the new |
|
Heh, those were ai generated. No worries about them - i'll push a follow up commit to expand "~" Thanks! |
Summary
Adds
~/.config/comview/config.json(respects$XDG_CONFIG_HOME) for user-local settings.comment_file— override the default.comview/comments.jsonpath with any absolute pathkeybindings— remap named actions to custom key strings using vaxisMatchStringformatConfigurable actions
cursor_down,cursor_up,cursor_left,cursor_right,half_page_down,half_page_up,cursor_bottom,next_commit,prev_commit,toggle_layout,search,next_result,prev_result,open_editor,yank,fuzzy_next,fuzzy_prevKey string format
Uses vaxis
MatchStringformat — modifier names joined by+, then the key name or character. Examples:"ctrl+d","shift+j","Page_Down","super+c","j".A non-empty list in config replaces the defaults for that action.
Example config
{ "comment_file": "~/.local/share/comview/comments.json", "keybindings": { "half_page_down": ["ctrl+d", "ctrl+f", "Page_Down"], "half_page_up": ["ctrl+u", "ctrl+b", "Page_Up"], "fuzzy_next": ["Down", "ctrl+n"], "fuzzy_prev": ["Up", "ctrl+p"] } }Implementation notes
loadConfig()intui/config.goBindings.Matchesfalls back todefaultKeybindingswhen no user config is present, so zero-valueBindingsworks correctly (no init required in tests)🤖 Generated with Claude Code