feat(notifier): notification history option (#297)

## Description

<!-- Describe the big picture of your changes to communicate to the
maintainers
  why we should accept this pull request. -->

Option to exclude some notifications from notification history,
for example, when dealing with spinners.

## Related Issue(s)

<!--
  If this PR fixes any issues, please link to the issue here.
  - Fixes #<issue_number>
-->

## Screenshots

<!-- Add screenshots of the changes if applicable. -->
This commit is contained in:
Marcin 2024-12-15 07:46:27 +01:00 committed by GitHub
parent 7db0cc9281
commit 8f56e19f91
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -34,6 +34,7 @@ local uv = vim.uv or vim.loop
---@field style? snacks.notifier.style
---@field opts? fun(notif: snacks.notifier.Notif) -- dynamic opts
---@field hl? snacks.notifier.hl -- highlight overrides
---@field history? boolean
--- Notification object
---@class snacks.notifier.Notif: snacks.notifier.Notif.opts
@ -395,7 +396,9 @@ function N:add(opts)
if numlevel(notif.level) >= numlevel(self.opts.level) then
self.queue[notif.id] = notif
end
self.history[notif.id] = notif
if opts.history ~= false then
self.history[notif.id] = notif
end
if self:is_blocking() then
pcall(function()
self:process()