mirror of
https://github.com/folke/snacks.nvim
synced 2025-12-23 08:47:57 +00:00
feat(notifier): added backward compatibility for nvim-notify's replace option
This commit is contained in:
parent
7e6ea65f5f
commit
9b9777ec3b
1 changed files with 9 additions and 2 deletions
|
|
@ -307,8 +307,15 @@ function N:add(opts)
|
|||
local now = ts()
|
||||
local notif = vim.deepcopy(opts) --[[@as snacks.notifier.Notif]]
|
||||
notif.msg = notif.msg or ""
|
||||
-- FIXME: normalize title, icon, etc to remove newlines
|
||||
notif.title = notif.title or ""
|
||||
|
||||
-- NOTE: support nvim-notify style replace
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
if not notif.id and notif.replace then
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
notif.id = type(notif.replace) == "table" and notif.replace.id or notif.replace
|
||||
end
|
||||
|
||||
notif.title = (notif.title or ""):gsub("\n", " ")
|
||||
notif.id = notif.id or next_id()
|
||||
notif.level = normlevel(notif.level)
|
||||
notif.icon = notif.icon or self.opts.icons[notif.level]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue