feat(picker): added notifications picker. Closes #738

This commit is contained in:
Folke Lemaitre 2025-01-28 17:16:30 +01:00
parent 0cb5bdf4ee
commit 32cffd2e60
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
5 changed files with 71 additions and 2 deletions

View file

@ -0,0 +1,23 @@
local M = {}
---@param opts snacks.picker.notifications.Config
function M.notifier(opts)
local notifs = Snacks.notifier.get_history({ filter = opts.filter })
local items = {} ---@type snacks.picker.finder.Item[]
for _, notif in ipairs(notifs) do
items[#items + 1] = {
text = Snacks.picker.util.text(notif, { "level", "title", "msg" }),
item = notif,
severity = notif.level,
preview = {
text = notif.msg,
ft = "markdown",
},
}
end
return items
end
return M