Skip to content

User config file for keybindings and comment file path#7

Merged
rockorager merged 1 commit into
rockorager:mainfrom
carsonjones:feat/config-system
May 18, 2026
Merged

User config file for keybindings and comment file path#7
rockorager merged 1 commit into
rockorager:mainfrom
carsonjones:feat/config-system

Conversation

@carsonjones
Copy link
Copy Markdown
Contributor

Summary

Adds ~/.config/comview/config.json (respects $XDG_CONFIG_HOME) for user-local settings.

  • comment_file — override the default .comview/comments.json path with any absolute path
  • keybindings — remap named actions to custom key strings using vaxis MatchString format

Configurable 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_prev

Key string format

Uses vaxis MatchString format — 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

  • Config is loaded once at startup via loadConfig() in tui/config.go
  • Bindings.Matches falls back to defaultKeybindings when no user config is present, so zero-value Bindings works correctly (no init required in tests)
  • Existing behavior is fully preserved when no config file exists

🤖 Generated with Claude Code

@carsonjones carsonjones changed the title feat(tui): user config file for keybindings and comment file path User config file for keybindings and comment file path May 18, 2026
Copy link
Copy Markdown
Owner

@rockorager rockorager left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. 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 from Run.

  2. The PR description example uses "comment_file": "~/.local/share/comview/comments.json", but the implementation passes the string directly to review.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.

@rockorager
Copy link
Copy Markdown
Owner

Update: I missed the new mise.toml because this PR branch predates those commits. I tested a local merge with current origin/main and ran mise run check; it passes (check-multiline-functions, gofumpt, golangci-lint run ./..., and go test ./...).

@rockorager rockorager merged commit 2e301a1 into rockorager:main May 18, 2026
@rockorager
Copy link
Copy Markdown
Owner

Heh, those were ai generated. No worries about them - i'll push a follow up commit to expand "~"

Thanks!

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.

2 participants