mirror of https://github.com/mickael-menu/zk-nvim
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1015 B
Lua
48 lines
1015 B
Lua
local M = {}
|
|
|
|
M.note_picker_list_api_selection = { "title", "path", "absPath" }
|
|
|
|
function M.show_note_picker(notes, options, cb)
|
|
options = options or {}
|
|
local select_options = vim.tbl_extend("force", {
|
|
prompt = options.title,
|
|
format_item = function(item)
|
|
return item.title or item.path
|
|
end,
|
|
}, options.select or {})
|
|
vim.ui.select(notes, select_options, function(item)
|
|
if not item then
|
|
-- user aborted
|
|
return
|
|
end
|
|
if options.multi_select then
|
|
cb({ item })
|
|
else
|
|
cb(item)
|
|
end
|
|
end)
|
|
end
|
|
|
|
function M.show_tag_picker(tags, options, cb)
|
|
options = options or {}
|
|
local select_options = vim.tbl_extend("force", {
|
|
prompt = "Zk Tags",
|
|
format_item = function(item)
|
|
return item.name
|
|
end,
|
|
}, options.select or {})
|
|
vim.ui.select(tags, select_options, function(item)
|
|
if not item then
|
|
-- user aborted
|
|
return
|
|
end
|
|
if options.multi_select then
|
|
cb({ item })
|
|
else
|
|
cb(item)
|
|
end
|
|
end)
|
|
end
|
|
|
|
return M
|