Skip to content

feat(integrations): support ClaudeCodeTreeAdd in snacks.nvim pickers (#192)#269

Merged
ThomasK33 merged 1 commit into
mainfrom
feat/snacks-picker-treeadd
Jun 8, 2026
Merged

feat(integrations): support ClaudeCodeTreeAdd in snacks.nvim pickers (#192)#269
ThomasK33 merged 1 commit into
mainfrom
feat/snacks-picker-treeadd

Conversation

@ThomasK33

Copy link
Copy Markdown
Member

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_list is a single filetype shared by Snacks.explorer() and the modal Snacks.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() + a snacks_picker_list dispatch branch. Reads the active picker via the documented Snacks.picker.get({ tab = true }), collects paths from picker:selected({ fallback = true }) (Tab multi-select, or the item under the cursor), resolves each via Snacks.picker.util.path with 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:ClaudeCodeSend now recognizes snacks_picker_list so 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.path failure 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 (adds snacks_picker_list to the keymap ft list; documents the modal-picker action workaround).

Notes / scope

  • For modal pickers (files()/grep()), focus defaults to the input box (insert mode), so the ergonomic path is a key-bound picker action calling the public require("claudecode").send_at_mention(...) — documented in the README (mirrors the community claude-fzf.nvim approach for fzf-lua).
  • Path-only @-mentions (no line range), matching every existing tree handler.
  • Visual-mode multi-row selection in a snacks picker is intentionally not wired here (modal pickers are insert-mode; picker:selected already covers Tab multi-select). A possible follow-up via visual_commands.lua.
  • The nerdtree +1 on [FEATURE] Support ClaudeCodeTreeAdd in snacks_picker_list #192 is a separate, independent follow-up.

Verification

  • mise run all — formatting, luacheck (0 warnings/0 errors), and tests.
  • New spec: 18/18 · full unit suite: 499/499.
  • Verified end-to-end against a real headless snacks picker via the included fixture (dispatch_files: 2, err: nil for a two-file multi-selection).

🤖 Generated with Claude Code

…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>
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@claude review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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

@ThomasK33 ThomasK33 merged commit 38b7084 into main Jun 8, 2026
2 checks passed
@ThomasK33 ThomasK33 deleted the feat/snacks-picker-treeadd branch June 8, 2026 19:31
@ThomasK33 ThomasK33 linked an issue Jun 9, 2026 that may be closed by this pull request
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] Support ClaudeCodeTreeAdd in snacks_picker_list

1 participant