From 349c5f895c24a46fd297de8c3736158ac98bb89e Mon Sep 17 00:00:00 2001 From: Adam Sherwood Date: Mon, 3 Feb 2025 15:13:37 +0100 Subject: [PATCH] fix: allow single or multi selection with mini.pick. (#1169) --- lua/avante/file_selector.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lua/avante/file_selector.lua b/lua/avante/file_selector.lua index 4767b26..6da117f 100644 --- a/lua/avante/file_selector.lua +++ b/lua/avante/file_selector.lua @@ -226,12 +226,16 @@ function FileSelector:fzf_ui(handler) end function FileSelector:mini_pick_ui(handler) - local success, mini_pick = pcall(require, "mini.pick") - if not success then - Utils.error("mini.pick is not installed. Please install mini.pick to use it as a file selector.") + -- luacheck: globals MiniPick + if not _G.MiniPick then + Utils.error("mini.pick is not set up. Please install and set up mini.pick to use it as a file selector.") return end - handler(mini_pick.builtin.files()) + local choose = function(item) handler(type(item) == "string" and { item } or item) end + local choose_marked = function(items_marked) handler(items_marked) end + local source = { choose = choose, choose_marked = choose_marked } + local result = MiniPick.builtin.files(nil, { source = source }) + if result == nil then handler(nil) end end function FileSelector:snacks_picker_ui(handler)