-
-
Notifications
You must be signed in to change notification settings - Fork 74
feat(fzf): add fzf-lua integration for buffer and file selection #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
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. 🙂 |
|
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. |
|
I think that missing feature is fine for now - it's an optimization, not a requirement. And is consistent with other filepath references anyway. |
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. |
|
Nice @naowalrahman! Could you PR that action function? Maybe to |
File picker using fzf-lua to select git files or open buffers to add to the prompt. Use it like so: