From d59cc45ea21e06070c940f1f01a0eb60c86a120a Mon Sep 17 00:00:00 2001 From: Aaron Weisberg Date: Mon, 12 Jan 2026 09:29:37 -0800 Subject: [PATCH 1/2] docs: add Snacks picker integration for sending files to opencode Show how to configure a custom action in Snacks pickers to send selected files directly to opencode as context. Works with files, git_files, buffers, git_status, and other file-based pickers. --- README.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/README.md b/README.md index dacbcc63..3f62dfe6 100644 --- a/README.md +++ b/README.md @@ -393,6 +393,60 @@ Available icon keys (see implementation at lua/opencode/ui/icons.lua lines 7-29) You can customize the layout of the picker used for history, session, references, and timeline +#### Snacks Picker Integration with Opencode + +You can configure a custom action in Snacks pickers to send selected files directly to opencode as context. This works with any file-based picker (files, git_files, buffers, git_status, etc.). + +```lua +-- In your snacks.nvim configuration +{ + "folke/snacks.nvim", + opts = { + picker = { + actions = { + opencode_send = function(picker) + local selected = picker:selected({ fallback = true }) + if selected and #selected > 0 then + local files = {} + for _, item in ipairs(selected) do + if item.file then + table.insert(files, item.file) + end + end + picker:close() + + -- Open opencode and add files as context + require("opencode.core").open({ + new_session = false, -- set to true to start a new session + focus = "input", + start_insert = true, + }) + + local context = require("opencode.context") + for _, file in ipairs(files) do + context.add_file(file) + end + end + end, + }, + win = { + input = { + keys = { + -- Use o or any preferred key to send files to opencode + ["o"] = { "opencode_send", mode = { "n", "i" } }, + }, + }, + }, + }, + }, +} +``` + +This allows you to: +1. Open any Snacks file picker (`:Snacks picker files`, `:Snacks picker git_files`, etc.) +2. Select one or more files using multi-select +3. Press `o` to send those files to opencode as context + #### Snacks Picker Layout There's 3 main ways on how to change the snacks picker layout From 299ee156c90ad068ad9db6b2007daf1506fd0efe Mon Sep 17 00:00:00 2001 From: Aaron Weisberg Date: Mon, 12 Jan 2026 09:30:31 -0800 Subject: [PATCH 2/2] fix(docs): remove commented code from README example - eliminated unnecessary commented line for clarity - streamlines README to enhance readability --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 3f62dfe6..2d66429d 100644 --- a/README.md +++ b/README.md @@ -415,9 +415,8 @@ You can configure a custom action in Snacks pickers to send selected files direc end picker:close() - -- Open opencode and add files as context require("opencode.core").open({ - new_session = false, -- set to true to start a new session + new_session = false, focus = "input", start_insert = true, })