Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lua/opencode/commands/handlers/workflow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ function M.actions.mention_file()
local context = require('opencode.context')
require('opencode.ui.mention').mention(function(mention_cb)
picker.pick(function(file)
if not file then
return
end
mention_cb(file.path)
context.add_file(file.path)
end)
Expand Down
18 changes: 14 additions & 4 deletions lua/opencode/ui/base_picker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,17 @@ local function snacks_picker_ui(opts)
Snacks.picker.pick(snack_opts)
end

---vim.ui.select UI implementation
---@param opts PickerOptions The picker options
local function select_picker_ui(opts)
vim.ui.select(opts.items, {
format_item = function(item)
return opts.format_fn(item, opts.width):to_string()
end,
prompt = opts.title --[[@as string]]
}, opts.callback)
end

---@param text? string
---@param width integer
---@param opts? {align?: "left" | "right" | "center", truncate?: boolean}
Expand Down Expand Up @@ -856,10 +867,6 @@ end
function M.pick(opts)
local picker_type = picker.get_best_picker()

if not picker_type then
return false
end

if not opts.width then
opts.width = config.ui.picker_width
end
Expand Down Expand Up @@ -927,6 +934,9 @@ function M.pick(opts)
elseif picker_type == 'snacks' then
opts.title = build_title(title_str, opts.actions)
snacks_picker_ui(opts)
elseif picker_type == 'select' then
opts.title = title_str
select_picker_ui(opts)
else
opts.callback(nil)
end
Expand Down
4 changes: 0 additions & 4 deletions lua/opencode/ui/file_picker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,6 @@ end
function M.pick(callback, path)
local picker_type = picker.get_best_picker()

if not picker_type then
return
end

local wrapped_callback = function(selected_file)
local file_name = format_file(selected_file)
callback(file_name)
Expand Down
4 changes: 0 additions & 4 deletions lua/opencode/ui/picker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ local picker_aliases = {
}

local function normalize_picker_name(name)
if name == 'select' then
return nil
end

return picker_aliases[name] or name
end

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/picker_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ describe('opencode.ui.picker', function()
end)

it('keeps select as the explicit vim.ui.select fallback', function()
assert.is_nil(get_best_picker('select'))
assert.equal('select', get_best_picker('select'))
end)
end)
Loading