Skip to content

Commit aa4f4ca

Browse files
committed
feat: add nvim-tree and neotree integration
Change-Id: I22a048a068ce66e6f6ee8c4177a2a78178ab6616 Signed-off-by: Thomas Kosiewski <[email protected]>
1 parent c1cdcd5 commit aa4f4ca

File tree

11 files changed

+1661
-48
lines changed

11 files changed

+1661
-48
lines changed

Makefile

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,13 @@ all: check format
66
# Check for syntax errors
77
check:
88
@echo "Checking Lua files for syntax errors..."
9-
@find lua -name "*.lua" -type f -exec lua -e "assert(loadfile('{}'))" \;
9+
nix develop .#ci -c find lua -name "*.lua" -type f -exec lua -e "assert(loadfile('{}'))" \;
1010
@echo "Running luacheck..."
11-
@luacheck lua/ tests/ --no-unused-args --no-max-line-length
11+
nix develop .#ci -c luacheck lua/ tests/ --no-unused-args --no-max-line-length
1212

1313
# Format all files
1414
format:
15-
@echo "Formatting files..."
16-
@if command -v nix >/dev/null 2>&1; then \
17-
nix fmt; \
18-
elif command -v stylua >/dev/null 2>&1; then \
19-
stylua lua/; \
20-
else \
21-
echo "Neither nix nor stylua found. Please install one of them."; \
22-
exit 1; \
23-
fi
15+
nix fmt
2416

2517
# Run tests
2618
test:

README.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,15 @@ Using [lazy.nvim](https://github.com/folke/lazy.nvim):
4949
"coder/claudecode.nvim",
5050
config = true,
5151
keys = {
52+
{ "<leader>a", nil, desc = "AI/Claude Code" },
5253
{ "<leader>ac", "<cmd>ClaudeCode<cr>", desc = "Toggle Claude" },
5354
{ "<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+
},
5461
},
5562
}
5663
```
@@ -60,13 +67,37 @@ That's it! For more configuration options, see [Advanced Setup](#advanced-setup)
6067
## Usage
6168

6269
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
6473
3. **Let Claude work**: Claude can now:
6574
- See your current file and selections in real-time
6675
- Open files in your editor
6776
- Show diffs with proposed changes
6877
- Access diagnostics and workspace info
6978

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+
85+
### Tree Integration
86+
87+
The `<leader>as` keybinding has context-aware behavior:
88+
89+
- **In normal buffers (visual mode)**: Sends selected text to Claude
90+
- **In nvim-tree/neo-tree buffers**: Adds the file under cursor (or selected files) to Claude's context
91+
92+
This allows you to quickly add entire files to Claude's context for review, refactoring, or discussion.
93+
94+
#### Features
95+
96+
- **Single file**: Place cursor on any file and press `<leader>as`
97+
- **Multiple files**: Select multiple files (using tree plugin's selection features) and press `<leader>as`
98+
- **Smart detection**: Automatically detects whether you're in nvim-tree or neo-tree
99+
- **Error handling**: Clear feedback if no files are selected or if tree plugins aren't available
100+
70101
## How It Works
71102

72103
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 +163,15 @@ See [DEVELOPMENT.md](./DEVELOPMENT.md) for build instructions and development gu
132163
},
133164
config = true,
134165
keys = {
166+
{ "<leader>a", nil, desc = "AI/Claude Code" },
135167
{ "<leader>ac", "<cmd>ClaudeCode<cr>", desc = "Toggle Claude" },
136168
{ "<leader>as", "<cmd>ClaudeCodeSend<cr>", mode = "v", desc = "Send to Claude" },
169+
{
170+
"<leader>as",
171+
"<cmd>ClaudeCodeTreeAdd<cr>",
172+
desc = "Add file",
173+
ft = { "NvimTree", "neo-tree" },
174+
},
137175
{ "<leader>ao", "<cmd>ClaudeCodeOpen<cr>", desc = "Open Claude" },
138176
{ "<leader>ax", "<cmd>ClaudeCodeClose<cr>", desc = "Close Claude" },
139177
},

flake.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
luajitPackages.luacov
4141
neovim
4242
treefmt.config.build.wrapper
43+
findutils
4344
];
4445

4546
# Development packages (additional tools for development)
@@ -49,7 +50,7 @@
4950
gnumake
5051
websocat
5152
jq
52-
claude-code
53+
# claude-code
5354
];
5455
in
5556
{

0 commit comments

Comments
 (0)