feat: universal selector (#1877)

This commit is contained in:
yetone
2025-04-15 16:40:47 +08:00
committed by GitHub
parent 0d26590389
commit 756d1f1e24
14 changed files with 452 additions and 316 deletions

View File

@@ -0,0 +1,21 @@
local M = {}
---@param selector avante.ui.Selector
function M.show(selector)
local items = {}
for _, item in ipairs(selector.items) do
if not vim.list_contains(selector.selected_item_ids, item.id) then table.insert(items, item) end
end
vim.ui.select(items, {
prompt = selector.title,
format_item = function(item) return item.title end,
}, function(item)
if item then
selector.on_select({ item.id })
else
selector.on_select(nil)
end
end)
end
return M