Skip to content

feat: add nvim-tree and neotree integration #22

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 9 commits into from
Jun 9, 2025

Conversation

ThomasK33
Copy link
Member

@ThomasK33 ThomasK33 commented Jun 7, 2025

Fixes #14

Summary

  • Adds comprehensive integration with nvim-tree and neo-tree file explorers, enabling Claude to navigate and interact with project file structures
  • Implements three new commands: :ClaudeCodeSend, :ClaudeCodeTreeAdd, and :ClaudeCodeAdd for flexible file addition workflows
  • Provides @-mention functionality for files and directories, allowing Claude to quickly reference and work with specific paths in the project

Features

  • File Explorer Integration: Seamless support for both nvim-tree and neo-tree plugins
  • :ClaudeCodeTreeAdd @-mention Support: Add @filename or @directory/ reference to files and folders using the new command
  • :ClaudeCodeAdd Direct Path Support: Add files/directories by path with optional line range specification
  • Visual Commands: New visual mode commands for enhanced file interaction
  • Directory Navigation: Claude can now understand and work with project directory structures

Performance Improvements

  • Reduced visual selection delay from 200ms to 50ms for more responsive tree navigation
  • Optimized batch processing for multiple file selections

Command Examples

" Add entire files
:ClaudeCodeAdd src/main.lua
:ClaudeCodeAdd ~/.config/nvim/init.lua

" Add with line ranges (1-indexed)
:ClaudeCodeAdd src/main.lua 50 100    " Lines 50-100
:ClaudeCodeAdd config.lua 25          " From line 25 to end

" Add directories
:ClaudeCodeAdd tests/
:ClaudeCodeAdd ../other-project/

Test Coverage

  • Added comprehensive unit tests for @-mention functionality (at_mention_spec.lua)
  • Added directory-specific @-mention tests (directory_at_mention_spec.lua)
  • Updated build system and dependencies for improved development experience

Change-Id: I22a048a068ce66e6f6ee8c4177a2a78178ab6616

@ThomasK33 ThomasK33 marked this pull request as ready for review June 8, 2025 08:04
@ThomasK33 ThomasK33 force-pushed the thomask33/nvim-tree-integration branch from 993fc6d to 9952bd4 Compare June 8, 2025 08:07
ThomasK33 added 3 commits June 8, 2025 10:13
Change-Id: I22a048a068ce66e6f6ee8c4177a2a78178ab6616
Signed-off-by: Thomas Kosiewski <[email protected]>
Enable diff tool to handle file creation by displaying empty buffer comparison for non-existent files instead of erroring. Includes automatic parent directory creation and updated test expectations.

Change-Id: I0032117b04309c63b605e21390083abb9ec741b2
Signed-off-by: Thomas Kosiewski <[email protected]>
- Replace fallback to single-file selection with line-by-line node mapping
- Support visual line selection (V), character selection (v), and block selection (Ctrl-V)
- Add comprehensive test suite for nvim-tree visual selection scenarios
- Include deduplication and root-level file filtering
- Maintain compatibility with existing nvim-tree marks functionality

Fixes issue where multi-selection in nvim-tree only sent cursor file instead of all selected files.

Change-Id: Ida7b3154f0b6749903ff0e847752d5c263a09de7
Signed-off-by: Thomas Kosiewski <[email protected]>
@ThomasK33 ThomasK33 force-pushed the thomask33/nvim-tree-integration branch from 9952bd4 to 1ef01d3 Compare June 8, 2025 08:13
@tomaszferens
Copy link

Shouldn't we have just a regular ClaudeCodeAdd <file-path / dir-path> command? and then the users can use it to integrate with whatever picker / file-tree explorer they are using?

- Extract broadcast_at_mention() for single file broadcasts
- Extract add_paths_to_claude() for batch operations with optional delays
- Refactor all existing handlers to use centralized functions
- Add ClaudeCodeAdd <file-path> command for direct file addition
- Remove verbose comments that describe "what" instead of "why"
- Add comprehensive documentation to README with examples
- Add 13 test cases covering command registration, validation, and functionality
- Maintain all existing functionality and test compatibility (164 tests passing)

Change-Id: I171dbc0bcc82d72c5c9a4f3d891a71fc3c814dbc
Signed-off-by: Thomas Kosiewski <[email protected]>
@ThomasK33
Copy link
Member Author

Shouldn't we have just a regular ClaudeCodeAdd <file-path / dir-path> command? and then the users can use it to integrate with whatever picker / file-tree explorer they are using?

Great point. I'll add both direct integrations and a ClaudeCodeAdd <filepath> [optional start line] [optional end line].

- Add optional start-line and end-line arguments to ClaudeCodeAdd command
- Convert 1-indexed user input to 0-indexed for Claude compatibility
- Add comprehensive validation for line numbers (positive, start <= end)
- Ignore line numbers for directories with debug logging
- Remove redundant vim.notify calls (logger handles notifications)
- Update README with line range syntax and examples
- Add extensive test coverage for all line range scenarios
- Clean up chatty comments that describe obvious operations

Change-Id: Ied866de821628c6f274faac3c82e527a0eaf46e1
Signed-off-by: Thomas Kosiewski <[email protected]>
@ThomasK33 ThomasK33 force-pushed the thomask33/nvim-tree-integration branch from edccb60 to 03c159f Compare June 8, 2025 19:37
ThomasK33 added 2 commits June 8, 2025 22:32
- Remove comments that just describe what code does rather than why
- Keep valuable LuaDoc annotations and explanatory comments
- Remove obvious descriptive comments like "Create directory", "Write to file", etc.
- Preserve comments that explain business logic, error handling rationale, or complex algorithms
- All tests continue passing (181 successes)

Change-Id: Ia019bc6889b7ef969afd49e699d09b3ffaafd8e4
Signed-off-by: Thomas Kosiewski <[email protected]>
- Remove redundant code and comments in coverage generation
- Streamline coverage report workflow for better maintainability

Change-Id: I37ff03afa456e3350409646616f58c0791e63765
Signed-off-by: Thomas Kosiewski <[email protected]>
@ThomasK33 ThomasK33 force-pushed the thomask33/nvim-tree-integration branch from b9d7f44 to 648c90a Compare June 8, 2025 20:32
ThomasK33 added 2 commits June 8, 2025 22:50
- Enhanced error handling in diff.lua with proper return values
- Optimized debug logging to avoid string operations when disabled
- Documented timing configuration changes with rationale
- Removed redundant comments that added no value
- Added backward compatibility for test environments

Change-Id: Ic9ac0aa77506114955b740b42ee3d1af0bc7fea0
Signed-off-by: Thomas Kosiewski <[email protected]>
- Remove procedural comments that describe obvious code actions
- Eliminate redundant explanatory text in function documentation
- Replace repeated logger require calls with cached variables
- Fix luacheck warning about inefficient loop pattern
- Add comprehensive test coverage for edge cases and error handling
- Preserve valuable comments that explain "why" not "what"

All tests pass (215 successes) with 0 warnings/errors across 61 files.

Change-Id: I0c4a606f8508ecc98a6f4202f83bbf5b3599daf6
Signed-off-by: Thomas Kosiewski <[email protected]>
@ThomasK33 ThomasK33 merged commit 6f6b8d1 into main Jun 9, 2025
3 checks passed
@ThomasK33 ThomasK33 deleted the thomask33/nvim-tree-integration branch June 9, 2025 07:28
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] Add nvim-tree integration to add file in explorer to mention file name in claude code
2 participants