Skip to content

Conversation

@xeon826
Copy link

@xeon826 xeon826 commented Jan 19, 2026

File picker using fzf-lua to select git files or open buffers to add to the prompt. Use it like so:

		vim.keymap.set("t", "<C-f>", function()
			require("opencode").fzf.select_files()
		end, opts)
		vim.keymap.set("t", "<C-b>", function()
			require("opencode").fzf.select_buffers()
		end, opts)
image

@nickjvandyke
Copy link
Owner

Neat, thank you! I have thought about something like this.

I think it'd be more powerful and reusable the way sidekick.nvim does it. Is that possible in fzf-lua? That could get us started on supporting other pickers too. 🙂

@xeon826
Copy link
Author

xeon826 commented Jan 20, 2026

I created another branch using my fork that more resembles the functionality you're referring to but it seems opencode is lacking an endpoint for submitting file paths so I created an issue and rough draft branch of opencode for adding that.

@nickjvandyke
Copy link
Owner

nickjvandyke commented Jan 20, 2026

I think that missing feature is fine for now - it's an optimization, not a requirement. And is consistent with other filepath references anyway.

@naowalrahman
Copy link

Neat, thank you! I have thought about something like this.

I think it'd be more powerful and reusable the way sidekick.nvim does it. Is that possible in fzf-lua? That could get us started on supporting other pickers too. 🙂

Just came up with a neat snacks.picker() action to send context from snacks.picker to opencode, similar to the sidekick.nvim integration:

return {
  "folke/snacks.nvim",
  opts = {
    picker = {
      actions = {
        ---@param picker snacks.Picker
        opencode_send = function(picker)
          local context = {}

          for _, item in ipairs(picker:selected { fallback = true }) do
            local entry = ""

            -- Build file reference with optional line range
            if item.file then
              entry = "@" .. item.file
              if item.pos then
                local has_range = item.end_pos and item.end_pos[1] ~= item.pos[1]
                entry = entry .. (" L%d"):format(item.pos[1])
                if has_range then entry = entry .. ("-L%d"):format(item.end_pos[1]) end
              end
            end

            -- Append text content
            if item.text and item.text ~= "" then
              entry = entry .. (item.file and "\n  " or "") .. item.text
            end

            context[#context + 1] = entry
          end

          require("opencode").prompt(table.concat(context, "\n") .. "\n")
        end,
      },
      win = {
        input = {
          keys = {
            ["<a-a>"] = {
              "opencode_send",
              mode = { "n", "i" },
            },
          },
        },
      },
    },
  },
}

Press Alt+A on current item/selected items in snacks.picker to send context to opencode.

Not sure if fzf-lua supports actions like snacks.picker, but I think picker integrations can be handled on the picker-side like this instead of plugin-side.

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.

3 participants