Skip to content

Conversation

@TheoBrigitte
Copy link

@TheoBrigitte TheoBrigitte commented Sep 30, 2025

Pull Request

Description

This PR provide the capability to set custom key mapping for window_navigation and scrolling configuration sections.
This helps keep a consistent motion when one is using different key mapping for motion as the default one provided here.

Type of Change

Please check the options that are relevant:

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Other (please describe):

Checklist

Please check all that apply:

  • I have read the CONTRIBUTING document
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have tested with the actual Claude Code CLI tool
  • I have tested in different environments (if applicable)

Additional Notes

Add any other context about the PR here.

Summary by CodeRabbit

  • New Features
    • Key bindings for window navigation and scrolling are now fully configurable with per-feature enable/disable and explicit directional/page mappings.
  • Refactor
    • Configuration format changed: window navigation and scrolling moved from simple toggles to structured settings with an enabled flag and explicit key mappings.
  • Documentation
    • README updated to demonstrate the new keymap configuration format.
  • Tests
    • Tests updated to validate the new nested keymap fields and enabled flags.

@coderabbitai
Copy link

coderabbitai bot commented Sep 30, 2025

Walkthrough

Window navigation and scrolling keymap configs changed from booleans to nested tables with an enabled flag and explicit key bindings; defaults, validation, parsing, keymap application, tests, and README examples were updated to use the new nested shapes.

Changes

Cohort / File(s) Change summary
Config schema & defaults
lua/claude-code/config.lua
Converted keymaps.window_navigation and keymaps.scrolling from booleans to tables with enabled plus directional/page mapping fields; updated M.default_config, parsing fallback behavior, and validation to enforce the new shapes.
Keymap application logic
lua/claude-code/keymaps.lua
Switched feature checks to use .enabled and replaced hard-coded mapping strings with values read from keymaps.window_navigation.{left,down,up,right} and keymaps.scrolling.{page_down,page_up} for terminal/normal contexts.
Tests
tests/spec/config_validation_spec.lua
Adjusted tests to validate keymaps.window_navigation.enabled and nested field paths; updated invalid-config mutations and assertions to the new structure.
Docs / Examples
README.md
Replaced boolean keymap examples with structured tables showing enabled and explicit key bindings for window navigation and scrolling.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant User
  participant Config as Config Parser
  participant Keymaps as Keymaps Module
  participant Neovim as Neovim API

  User->>Config: supply config (may include nested keymaps)
  Config->>Config: merge with default_config
  Config->>Config: validate keymaps.window_navigation & keymaps.scrolling shapes
  Config-->>Keymaps: return parsed config

  alt window_navigation.enabled == true
    Keymaps->>Neovim: set mappings (left, down, up, right) from config
  else window_navigation.disabled
    Keymaps-->>Neovim: skip window navigation mappings
  end

  alt scrolling.enabled == true
    Keymaps->>Neovim: set terminal mappings (page_down, page_up) from config
  else scrolling.disabled
    Keymaps-->>Neovim: skip scrolling mappings
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I hopped from bools into a map,
With tiny paws I set each cap.
Left and right, page up, page down—
Enabled now, I rule the town.
A rabbit's tweak — concise and bright. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly communicates the core enhancement of the pull request by specifying that users can now configure custom keymaps for window_navigation and scrolling, which directly aligns with the detailed changes made.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@TheoBrigitte TheoBrigitte force-pushed the window-navigation-keymap branch from 8ea546f to 90532ef Compare September 30, 2025 17:46
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c9a31e5 and 90532ef.

📒 Files selected for processing (4)
  • README.md (1 hunks)
  • lua/claude-code/config.lua (3 hunks)
  • lua/claude-code/keymaps.lua (2 hunks)
  • tests/spec/config_validation_spec.lua (2 hunks)
🔇 Additional comments (7)
README.md (1)

149-160: LGTM! Documentation clearly reflects the new keymap structure.

The documentation accurately describes the new nested configuration with enabled flags and explicit key bindings for both window_navigation and scrolling.

tests/spec/config_validation_spec.lua (1)

150-162: LGTM! Test correctly validates the new nested structure.

The test properly validates that keymaps.window_navigation.enabled must be a boolean and correctly mutates the nested property path.

lua/claude-code/keymaps.lua (2)

112-141: LGTM! Window navigation keymaps correctly use the new config structure.

The enabled check and terminal mode mappings properly reference the nested config.keymaps.window_navigation fields.


174-190: LGTM! Scrolling keymaps correctly use the new config structure.

The enabled check and scrolling mappings properly reference the nested config.keymaps.scrolling fields.

lua/claude-code/config.lua (3)

45-48: LGTM! Type annotations accurately reflect the new structure.

The documentation clearly describes the nested table structure with enabled flags and key bindings.


136-147: LGTM! Default configuration properly initializes the new nested structures.

The default values provide sensible keybindings that match standard Vim navigation patterns.


366-404: Validation logic is comprehensive.

After fixing the error messages mentioned in separate comments, the validation correctly covers all required fields for both window_navigation and scrolling configurations.

Comment on lines 370 to 372
if type(keymaps.window_navigation.enabled) ~= 'boolean' then
return false, 'keymaps.window_navigation.enabled must be a table'
end
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Fix incorrect error message.

Line 371 validates that enabled must be a boolean, but the error message incorrectly states "must be a table".

Apply this diff to fix the error message:

   if type(keymaps.window_navigation.enabled) ~= 'boolean' then
-    return false, 'keymaps.window_navigation.enabled must be a table'
+    return false, 'keymaps.window_navigation.enabled must be a boolean'
   end
🤖 Prompt for AI Agents
In lua/claude-code/config.lua around lines 370 to 372, the validation checks
whether keymaps.window_navigation.enabled is a boolean but the error message
incorrectly says "must be a table"; update the returned error string to state
"keymaps.window_navigation.enabled must be a boolean" so the message matches the
validation and aids correct debugging.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
lua/claude-code/config.lua (2)

370-372: Fix incomplete error message.

Line 371 validates that enabled must be a boolean, but the error message is incomplete - it says just "boolean" instead of following the pattern used elsewhere ("must be a boolean").

Apply this diff to fix the error message:

   if type(keymaps.window_navigation.enabled) ~= 'boolean' then
-    return false, 'keymaps.window_navigation.enabled boolean'
+    return false, 'keymaps.window_navigation.enabled must be a boolean'
   end

390-392: Fix typo in error message.

Line 391 has a typo: "btable" should be "table".

Apply this diff to fix the typo:

   if type(keymaps.scrolling) ~= 'table' then
-    return false, 'keymaps.scrolling must be a btable'
+    return false, 'keymaps.scrolling must be a table'
   end
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b32bd39 and b7d9971.

📒 Files selected for processing (1)
  • lua/claude-code/config.lua (3 hunks)
🔇 Additional comments (4)
lua/claude-code/config.lua (4)

136-142: LGTM!

The default window navigation keymaps are well-chosen, using standard vim motion keys that users expect.


143-147: LGTM!

The default scrolling keymaps use standard vim scroll keys that users expect.


374-388: LGTM!

The validation logic correctly checks all four directional key bindings with consistent error messages.


394-404: LGTM!

The validation logic correctly checks the enabled flag and both scrolling key bindings with consistent error messages.

Comment on lines +45 to +48
-- @field window_navigation table|nil Window navigation keymaps
-- @field window_navigation.enabled boolean Enable window navigation keymaps
-- @field scrolling table|nil Scrolling keymaps
-- @field scrolling.enabled boolean Enable scrolling keymaps
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Documentation is incomplete for window_navigation and scrolling fields.

The documentation only mentions the enabled field but omits the actual key binding fields. Users need to know about left, down, up, right for window_navigation and page_down, page_up for scrolling.

Apply this diff to complete the documentation:

 -- @field window_navigation table|nil Window navigation keymaps
 -- @field window_navigation.enabled boolean Enable window navigation keymaps
+-- @field window_navigation.left string Keymap to move to left window
+-- @field window_navigation.down string Keymap to move to down window
+-- @field window_navigation.up string Keymap to move to up window
+-- @field window_navigation.right string Keymap to move to right window
 -- @field scrolling table|nil Scrolling keymaps
 -- @field scrolling.enabled boolean Enable scrolling keymaps
+-- @field scrolling.page_down string Keymap to scroll down one page
+-- @field scrolling.page_up string Keymap to scroll up one page
🤖 Prompt for AI Agents
In lua/claude-code/config.lua around lines 45 to 48, the docblock for
window_navigation and scrolling only documents the enabled boolean; update the
documentation to list the actual key binding fields: for window_navigation add
@field window_navigation.left string|nil, @field window_navigation.down
string|nil, @field window_navigation.up string|nil and @field
window_navigation.right string|nil; for scrolling add @field scrolling.page_down
string|nil and @field scrolling.page_up string|nil. Keep the existing enabled
fields and ensure the types and brief descriptions mirror the style of the
surrounding docs (e.g., indicate they are keymap strings and optional).

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.

1 participant