You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add comprehensive tree explorer integration with @-mention support
## Summary
- Add seamless integration with nvim-tree and neo-tree file explorers
- Implement @-mention functionality for files and directories via new ClaudeCodeTreeAdd and ClaudeCodeAdd commands
- Enable Claude to navigate and understand project file structures through visual selection
- Add support for new file creation in diff system with proper directory handling
## New Features
- **Tree Integration**: Context-aware <leader>as keybinding that sends text in normal buffers or adds files from tree explorers
- **@-mention Commands**:
- `:ClaudeCodeTreeAdd` - Add selected files from tree explorers to Claude context
- `:ClaudeCodeAdd <path> [start] [end]` - Add files/directories by path with optional line ranges
- **Enhanced Diff System**: Support for creating new files with automatic parent directory creation
- **Visual Selection**: Improved multi-file selection detection for both nvim-tree and neo-tree
## Technical Improvements
- Comprehensive test coverage with dedicated specs for @-mention functionality
- Improved error handling and user feedback for edge cases
- Enhanced build system with Nix integration for consistent development environment
- Code cleanup and maintainability improvements throughout codebase
## Breaking Changes
None - all changes are additive and backward compatible.
Fixes#14
Merge pull request #22 from coder/thomask33/nvim-tree-integration
{ "<leader>as", "<cmd>ClaudeCodeSend<cr>", mode="v", desc="Send to Claude" },
55
+
{
56
+
"<leader>as",
57
+
"<cmd>ClaudeCodeTreeAdd<cr>",
58
+
desc="Add file",
59
+
ft= { "NvimTree", "neo-tree" },
60
+
},
54
61
},
55
62
}
56
63
```
@@ -60,13 +67,80 @@ That's it! For more configuration options, see [Advanced Setup](#advanced-setup)
60
67
## Usage
61
68
62
69
1.**Launch Claude**: Run `:ClaudeCode` to open Claude in a split terminal
63
-
2.**Send context**: Select text and run `:'<,'>ClaudeCodeSend` to send it to Claude
70
+
2.**Send context**:
71
+
- Select text in visual mode and use `<leader>as` to send it to Claude
72
+
- In `nvim-tree` or `neo-tree`, press `<leader>as` on a file to add it to Claude's context
64
73
3.**Let Claude work**: Claude can now:
65
74
- See your current file and selections in real-time
66
75
- Open files in your editor
67
76
- Show diffs with proposed changes
68
77
- Access diagnostics and workspace info
69
78
79
+
## Commands
80
+
81
+
-`:ClaudeCode` - Toggle the Claude Code terminal window
82
+
-`:ClaudeCodeSend` - Send current visual selection to Claude, or add files from tree explorer
83
+
-`:ClaudeCodeTreeAdd` - Add selected file(s) from tree explorer to Claude context (also available via ClaudeCodeSend)
84
+
-`:ClaudeCodeAdd <file-path> [start-line] [end-line]` - Add a specific file or directory to Claude context by path with optional line range
85
+
86
+
### Tree Integration
87
+
88
+
The `<leader>as` keybinding has context-aware behavior:
89
+
90
+
-**In normal buffers (visual mode)**: Sends selected text to Claude
91
+
-**In nvim-tree/neo-tree buffers**: Adds the file under cursor (or selected files) to Claude's context
92
+
93
+
This allows you to quickly add entire files to Claude's context for review, refactoring, or discussion.
94
+
95
+
#### Features
96
+
97
+
-**Single file**: Place cursor on any file and press `<leader>as`
98
+
-**Multiple files**: Select multiple files (using tree plugin's selection features) and press `<leader>as`
99
+
-**Smart detection**: Automatically detects whether you're in nvim-tree or neo-tree
100
+
-**Error handling**: Clear feedback if no files are selected or if tree plugins aren't available
101
+
102
+
### Direct File Addition
103
+
104
+
The `:ClaudeCodeAdd` command allows you to add files or directories directly by path, with optional line range specification:
105
+
106
+
```vim
107
+
:ClaudeCodeAdd src/main.lua
108
+
:ClaudeCodeAdd ~/projects/myproject/
109
+
:ClaudeCodeAdd ./README.md
110
+
:ClaudeCodeAdd src/main.lua 50 100 " Lines 50-100 only
111
+
:ClaudeCodeAdd config.lua 25 " From line 25 to end of file
112
+
```
113
+
114
+
#### Features
115
+
116
+
-**Path completion**: Tab completion for file and directory paths
117
+
-**Path expansion**: Supports `~` for home directory and relative paths
118
+
-**Line range support**: Optionally specify start and end lines for files (ignored for directories)
119
+
-**Validation**: Checks that files and directories exist before adding, validates line numbers
120
+
-**Flexible**: Works with both individual files and entire directories
121
+
122
+
#### Examples
123
+
124
+
```vim
125
+
" Add entire files
126
+
:ClaudeCodeAdd src/components/Header.tsx
127
+
:ClaudeCodeAdd ~/.config/nvim/init.lua
128
+
129
+
" Add entire directories (line numbers ignored)
130
+
:ClaudeCodeAdd tests/
131
+
:ClaudeCodeAdd ../other-project/
132
+
133
+
" Add specific line ranges
134
+
:ClaudeCodeAdd src/main.lua 50 100 " Lines 50 through 100
135
+
:ClaudeCodeAdd config.lua 25 " From line 25 to end of file
136
+
:ClaudeCodeAdd utils.py 1 50 " First 50 lines
137
+
:ClaudeCodeAdd README.md 10 20 " Just lines 10-20
138
+
139
+
" Path expansion works with line ranges
140
+
:ClaudeCodeAdd ~/project/src/app.js 100 200
141
+
:ClaudeCodeAdd ./relative/path.lua 30
142
+
```
143
+
70
144
## How It Works
71
145
72
146
This plugin creates a WebSocket server that Claude Code CLI connects to, implementing the same protocol as the official VS Code extension. When you launch Claude, it automatically detects Neovim and gains full access to your editor.
@@ -132,8 +206,15 @@ See [DEVELOPMENT.md](./DEVELOPMENT.md) for build instructions and development gu
0 commit comments