feat(integrations): support ClaudeCodeTreeAdd in snacks.nvim pickers (#192)#269
Merged
Conversation
…192) Add a `snacks_picker_list` handler so `:ClaudeCodeTreeAdd` (and `:ClaudeCodeSend`) can add the highlighted/selected file(s) from a snacks.nvim picker to Claude's context, matching the existing nvim-tree/neo-tree/oil/mini.files/netrw integrations. The handler reads the active picker via the documented `Snacks.picker.get({ tab = true })`, collects paths from `picker:selected({ fallback = true })` (multi-select via Tab, or the item under the cursor), and resolves each via `Snacks.picker.util.path` with a guarded manual fallback. It degrades gracefully when snacks is absent or only partially installed, and skips items without a string file path (registers/commands/ unsaved buffers). The single `snacks_picker_list` filetype covers both `Snacks.explorer()` and the modal `files()`/`grep()` pickers, since the explorer is built on the picker. For modal pickers (which keep focus in the input box) the README documents the idiomatic key-bound `opts.actions` workaround calling the public `require("claudecode").send_at_mention(...)`. - lua/claudecode/integrations.lua: `_get_snacks_picker_selection` + dispatch - lua/claudecode/init.lua: route `:ClaudeCodeSend` through the snacks handler - tests/unit/snacks_picker_integration_spec.lua: 18 unit tests - fixtures/snacks-picker/: reproduction/demo fixture - README.md: picker usage docs Closes #192 Change-Id: Ib2d6eb5adb0c6d5a73e5c103e192ce595fc854bf Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Thomas Kosiewski <tk@coder.com>
Member
Author
|
@codex review |
Member
Author
|
@claude review |
|
Codex Review: Didn't find any major issues. Swish! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements snacks.nvim picker support for
:ClaudeCodeTreeAdd, resolving #192. With a snacks picker's list focused, the command now adds the selected/highlighted file(s) to Claude's context, just like the existing nvim-tree / neo-tree / oil / mini.files / netrw integrations.snacks_picker_listis a single filetype shared bySnacks.explorer()and the modalSnacks.picker.files()/grep()pickers (the explorer is built on the picker), so this one handler covers both.What's included
lua/claudecode/integrations.lua— new_get_snacks_picker_selection()+ asnacks_picker_listdispatch branch. Reads the active picker via the documentedSnacks.picker.get({ tab = true }), collects paths frompicker:selected({ fallback = true })(Tab multi-select, or the item under the cursor), resolves each viaSnacks.picker.util.pathwith a guarded manual fallback, and validates existence. No-ops gracefully when snacks is absent/partially installed; skips items without a string file path (registers/commands/unsaved buffers).lua/claudecode/init.lua—:ClaudeCodeSendnow recognizessnacks_picker_listso it routes through the same handler as:ClaudeCodeTreeAdd(consistency between the two commands).tests/unit/snacks_picker_integration_spec.lua— 18 unit tests (single/multi-select, file-less items, directories/explorer, non-string guard,util.pathfailure fallback, window-match + fallback, dispatch, error branches).fixtures/snacks-picker/— reproduction/demo fixture showing both the built-in command path and the key-bound action workaround.README.md— picker usage docs (addssnacks_picker_listto the keymapftlist; documents the modal-picker action workaround).Notes / scope
files()/grep()), focus defaults to the input box (insert mode), so the ergonomic path is a key-bound picker action calling the publicrequire("claudecode").send_at_mention(...)— documented in the README (mirrors the communityclaude-fzf.nvimapproach for fzf-lua).picker:selectedalready covers Tab multi-select). A possible follow-up viavisual_commands.lua.Verification
mise run all— formatting, luacheck (0 warnings/0 errors), and tests.dispatch_files: 2, err: nilfor a two-file multi-selection).🤖 Generated with Claude Code