Skip to content
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ local defaults = {
class = "{class}",
},
-- preferred picker for selecting files
---@alias sidekick.picker "snacks"|"telescope"|"fzf-lua"
---@alias sidekick.picker "snacks"|"telescope"|"fzf-lua"|"mini.pick"
picker = "snacks", ---@type sidekick.picker
},
copilot = {
Expand Down
2 changes: 1 addition & 1 deletion lua/sidekick/cli/picker/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function P.action(cb) end

---@param picker? string
function M.get(picker)
local pickers = picker and { picker } or { Config.cli.picker, "snacks", "telescope", "fzf-lua" }
local pickers = picker and { picker } or { Config.cli.picker, "snacks", "telescope", "fzf-lua", "mini.pick" }
for _, name in ipairs(pickers) do
---@type boolean, sidekick.Picker
local ok, mod = pcall(require, "sidekick.cli.picker." .. name)
Expand Down
43 changes: 43 additions & 0 deletions lua/sidekick/cli/picker/mini/pick.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---@type sidekick.Picker
local M = {}

local typeMapFn = {
-- MiniPick.builtin.files() deals with list of file paths
["string"] = function(value)
return { name = value }
end,
-- MiniPick.builtin.buffers() deals with list of tables that include buffer number and file name
["table"] = function(value)
return {
name = value.text,
bufnr = value.bufnr,
}
end,
}

---@param source string
---@param cb fun(items:sidekick.context.Loc[])
---@param opts? table
function M.open(source, cb, opts)
local choose_marked_fn = M.action(cb)
require("mini.pick").builtin[source]({}, {
source = {
choose = function(item)
choose_marked_fn({ item })
end,
choose_marked = choose_marked_fn,
},
})
end

---@param cb fun(items:sidekick.context.Loc[])
---@return fun(items:any[])
function M.action(cb)
return function(items)
cb(vim.tbl_map(function(value)
return typeMapFn[type(value)](value)
end, items))
end
end

return M
2 changes: 1 addition & 1 deletion lua/sidekick/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ local defaults = {
class = "{class}",
},
-- preferred picker for selecting files
---@alias sidekick.picker "snacks"|"telescope"|"fzf-lua"
---@alias sidekick.picker "snacks"|"telescope"|"fzf-lua"|"mini.pick"
picker = "snacks", ---@type sidekick.picker
},
copilot = {
Expand Down