Skip to content

Commit f5a87a9

Browse files
committed
refactor: extract broadcast functions and add ClaudeCodeAdd command
- 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]>
1 parent 1ef01d3 commit f5a87a9

File tree

4 files changed

+490
-161
lines changed

4 files changed

+490
-161
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.PHONY: check format test clean
22

33
# Default target
4-
all: check format
4+
all: format check test
55

66
# Check for syntax errors
77
check:

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ That's it! For more configuration options, see [Advanced Setup](#advanced-setup)
8181
- `:ClaudeCode` - Toggle the Claude Code terminal window
8282
- `:ClaudeCodeSend` - Send current visual selection to Claude, or add files from tree explorer
8383
- `:ClaudeCodeTreeAdd` - Add selected file(s) from tree explorer to Claude context (also available via ClaudeCodeSend)
84+
- `:ClaudeCodeAdd <file-path>` - Add a specific file or directory to Claude context by path
8485

8586
### Tree Integration
8687

@@ -98,6 +99,39 @@ This allows you to quickly add entire files to Claude's context for review, refa
9899
- **Smart detection**: Automatically detects whether you're in nvim-tree or neo-tree
99100
- **Error handling**: Clear feedback if no files are selected or if tree plugins aren't available
100101

102+
### Direct File Addition
103+
104+
The `:ClaudeCodeAdd` command allows you to add files or directories directly by path:
105+
106+
```vim
107+
:ClaudeCodeAdd src/main.lua
108+
:ClaudeCodeAdd ~/projects/myproject/
109+
:ClaudeCodeAdd ./README.md
110+
```
111+
112+
#### Features
113+
114+
- **Path completion**: Tab completion for file and directory paths
115+
- **Path expansion**: Supports `~` for home directory and relative paths
116+
- **Validation**: Checks that files and directories exist before adding
117+
- **Flexible**: Works with both individual files and entire directories
118+
119+
#### Examples
120+
121+
```vim
122+
" Add a specific file
123+
:ClaudeCodeAdd src/components/Header.tsx
124+
125+
" Add an entire directory
126+
:ClaudeCodeAdd tests/
127+
128+
" Add file in home directory
129+
:ClaudeCodeAdd ~/.config/nvim/init.lua
130+
131+
" Add relative path
132+
:ClaudeCodeAdd ../other-project/package.json
133+
```
134+
101135
## How It Works
102136

103137
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.

0 commit comments

Comments
 (0)