Skip to content

feat: make keymaps configurable via setup()#44

Merged
Cannon07 merged 1 commit intomainfrom
feat/configurable-keymaps
Apr 27, 2026
Merged

feat: make keymaps configurable via setup()#44
Cannon07 merged 1 commit intomainfrom
feat/configurable-keymaps

Conversation

@Cannon07
Copy link
Copy Markdown
Owner

@Cannon07 Cannon07 commented Apr 27, 2026

Summary

  • Adds a keys table to setup() so the previously hardcoded mappings (]c, [c, <leader>dq) can be customized or disabled
  • Always defines <Plug>(CodePreviewCloseAll) for users who prefer to bind the close action themselves
  • Defaults match the existing hardcoded values, so behavior is unchanged for current users

Closes #43

Usage

require("code-preview").setup({
  keys = {
    next_change = "]c",          -- inline diff: next change
    prev_change = "[c",          -- inline diff: previous change
    close_all   = "<leader>dq",  -- close diff and clear indicators
  },
})

Set any entry to false to skip that binding, or keys = false to skip them all and use <Plug>(CodePreviewCloseAll) directly.

Test plan

  • Defaults (]c/[c/<leader>dq) work unchanged across Claude Code, OpenCode, and GitHub Copilot CLI backends
  • Custom keys (e.g. <leader>cn/<leader>cp/<leader>cq) bind correctly and the original defaults no longer trigger
  • keys = false disables all defaults; <Plug>(CodePreviewCloseAll) still bindable manually
  • Per-key false (e.g. close_all = false) skips just that binding

The plugin previously hardcoded `]c`/`[c` (buffer-local in inline diff
buffers) and `<leader>dq` (global), which conflicted with users' own
mappings.

Add a `keys` table to setup() with the existing values as defaults so
behavior is unchanged. Each entry can be set to a different lhs or to
`false` to skip the binding; `keys = false` disables all defaults. Also
expose `<Plug>(CodePreviewCloseAll)` so users can bind the close action
even when defaults are disabled.

Closes #43

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@Cannon07 Cannon07 merged commit e834248 into main Apr 27, 2026
2 checks passed
@Cannon07 Cannon07 deleted the feat/configurable-keymaps branch April 27, 2026 20:10
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.

[Feature Request] Make hard-coded keymaps configurable via setup()

1 participant