Skip to content

feat: make diff keymaps adjustable via LazyVim spec #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 18, 2025

Conversation

ThomasK33
Copy link
Member

Summary

This implements adjustable diff keymaps by moving them from hardcoded buffer-local keymaps to the LazyVim spec configuration, allowing users to customize or disable diff handling keymaps that may conflict with debugger mappings.

Key Changes

  • Added user commands: ClaudeCodeDiffAccept and ClaudeCodeDiffDeny to provide the underlying diff functionality
  • Moved keymaps to LazyVim spec: Users can now customize diff keymaps in their plugin configuration instead of being stuck with hardcoded <leader>da/<leader>dq
  • Updated documentation: Added examples showing how to customize or disable diff keymaps to avoid conflicts
  • Fixed test infrastructure: Added vim.b mock to resolve test failures when diff operations store buffer-local variables
  • Updated dev config: Changed to non-conflicting keymaps (<leader>aa/<leader>ad) as an example

Usage

Users can now customize like this:

-- Avoid debugger conflicts
{ "<leader>ya", "<cmd>ClaudeCodeDiffAccept<cr>", desc = "Accept diff" },
{ "<leader>yn", "<cmd>ClaudeCodeDiffDeny<cr>", desc = "Deny diff" },

Or disable entirely by omitting the keymaps from their configuration.

Closes #44

blink-so bot and others added 3 commits June 17, 2025 16:57
- Add ClaudeCodeDiffAccept and ClaudeCodeDiffDeny user commands to init.lua
- Implement accept_current_diff() and deny_current_diff() functions in diff.lua
- Refactor keymaps to use new commands instead of inline functions
- Store diff context in buffer variables for command access
- Update README.md with new commands and customization examples
- Maintain backward compatibility with existing <leader>da and <leader>dq keymaps

Resolves issue #44 by allowing users to customize diff keymaps without conflicts

Co-authored-by: ThomasK33 <2198487+ThomasK33@users.noreply.github.com>
Signed-off-by: Thomas Kosiewski <tk@coder.com>
- Remove hardcoded keymaps from diff.lua
- Add diff keymaps to LazyVim specs in README.md and dev-config.lua
- Update documentation to reflect LazyVim spec configuration approach
- Provide clear examples for customizing diff keymaps
- Maintain backward compatibility with default <leader>da and <leader>dq

This allows users to easily customize or disable diff keymaps by modifying
their LazyVim plugin configuration instead of needing to override hardcoded
keymaps.

Co-authored-by: ThomasK33 <2198487+ThomasK33@users.noreply.github.com>
Signed-off-by: Thomas Kosiewski <tk@coder.com>
Fixes #44 - test failures were caused by missing vim.b mock in test environment.

Changes:
- Add vim.b metatable mock to handle buffer-local variables in tests
- Update dev config diff keymaps to avoid conflicts (<leader>aa/<leader>ad)
- Remove outdated keymap comments from diff.lua
- Fix minor formatting issues in README.md

Tests now pass: 278 successes / 0 failures / 0 errors

Change-Id: I3af59441d9940869e3ed0f7566a09892908bd16b
Signed-off-by: Thomas Kosiewski <tk@coder.com>
@ThomasK33 ThomasK33 requested a review from Copilot June 17, 2025 16:31
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors diff keymaps to be user-configurable via the LazyVim spec instead of hardcoded mappings, adds dedicated user commands for accepting or rejecting diffs, updates test mocks, and refreshes documentation.

  • Introduce ClaudeCodeDiffAccept and ClaudeCodeDiffDeny user commands
  • Remove buffer-local hardcoded <leader>da/<leader>dq mappings and move them into the LazyVim spec
  • Update test mocks (vim.b) and documentation with examples and default keymaps

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/mocks/vim.lua Add vim.b buffer-local variable support for diff context tests
lua/claudecode/init.lua Register new diff management user commands
lua/claudecode/diff.lua Remove hardcoded keymaps, store diff context in buffer variables; implement command handlers
dev-config.lua Example dev config with non-conflicting <leader>aa/<leader>ad mappings
README.md Update default keymap examples and add customization instructions
Comments suppressed due to low confidence (3)

README.md:144

  • Remove the stray commented-out line (-- **da**) to avoid confusion and keep the markdown clean.
- **`:w` (save)** - Accept the changes and apply them to your file

README.md:175

  • [nitpick] Align this example with the dev-config.lua example or vice versa—use consistent key names (either aa/ad or ya/yn) across documentation and configuration samples.
    { "<leader>ya", "<cmd>ClaudeCodeDiffAccept<cr>", desc = "Accept diff" },

lua/claudecode/diff.lua:891

  • Add unit tests for accept_current_diff() and deny_current_diff() to verify buffer-local context storage and warning behavior when no diff is active.
function M.accept_current_diff()

@ThomasK33 ThomasK33 merged commit d836f76 into main Jun 18, 2025
3 checks passed
@ThomasK33 ThomasK33 deleted the feature/refactor-diff-keymaps-to-commands branch June 18, 2025 10:07
ThomasK33 added a commit that referenced this pull request Jun 18, 2025
This release includes significant feature additions and bug fixes:

**Version Updates:**
- Updated main version table in lua/claudecode/init.lua (0.1.0-alpha → 0.2.0)
- Updated client versions in scripts/claude_interactive.sh (3 locations)
- Updated ClaudeCodeNvim version in scripts/lib_claude.sh
- Removed prerelease flag for stable release

**Documentation:**
- Added comprehensive CHANGELOG.md with v0.2.0 release notes
- Documented all merged PRs since v0.1.0 with proper references
- Updated CLAUDE.md with detailed release process documentation
- Fixed diff keymap references in README.md (<leader>da → <leader>aa)

**Features Added (since v0.1.0):**
- Diagnostics integration (#34)
- File explorer support for oil.nvim, nvim-tree, neotree (#27, #22)
- Enhanced terminal management with ClaudeCodeFocus command (#40)
- Auto terminal provider detection (#36)
- Customizable diff keymaps via LazyVim spec (#47)

**Bug Fixes:**
- Terminal focus errors when buffer hidden (#43)
- Improved diff acceptance behavior (#41)
- Fixed syntax highlighting in proposed diff view (#32)
- Visual selection range handling improvements (#26)
- Native terminal bufhidden behavior (#39)

All code quality checks pass and documentation is updated for maintainability.

Change-Id: I0e4e7c9bae98df922356dc8b8aa0acd7e8293a48
Signed-off-by: Thomas Kosiewski <tk@coder.com>
@ThomasK33 ThomasK33 mentioned this pull request Jun 18, 2025
ThomasK33 added a commit that referenced this pull request Jun 18, 2025
This release includes significant feature additions and bug fixes:

**Version Updates:**
- Updated main version table in lua/claudecode/init.lua (0.1.0-alpha → 0.2.0)
- Updated client versions in scripts/claude_interactive.sh (3 locations)
- Updated ClaudeCodeNvim version in scripts/lib_claude.sh
- Removed prerelease flag for stable release

**Documentation:**
- Added comprehensive CHANGELOG.md with v0.2.0 release notes
- Documented all merged PRs since v0.1.0 with proper references
- Updated CLAUDE.md with detailed release process documentation
- Fixed diff keymap references in README.md (<leader>da → <leader>aa)

**Features Added (since v0.1.0):**
- Diagnostics integration (#34)
- File explorer support for oil.nvim, nvim-tree, neotree (#27, #22)
- Enhanced terminal management with ClaudeCodeFocus command (#40)
- Auto terminal provider detection (#36)
- Customizable diff keymaps via LazyVim spec (#47)

**Bug Fixes:**
- Terminal focus errors when buffer hidden (#43)
- Improved diff acceptance behavior (#41)
- Fixed syntax highlighting in proposed diff view (#32)
- Visual selection range handling improvements (#26)
- Native terminal bufhidden behavior (#39)

All code quality checks pass and documentation is updated for maintainability.

Change-Id: I0e4e7c9bae98df922356dc8b8aa0acd7e8293a48
Signed-off-by: Thomas Kosiewski <tk@coder.com>
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] Adjustable keymaps for Diff handling
1 participant