Skip to content

Commit ea9c8ce

Browse files
committed
feat: supply record to events
See #200
1 parent f3024b9 commit ea9c8ce

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

lua/notify/instance.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ return function(user_config, inherit, global_config)
2222

2323
local animator_stages = instance_config.stages()
2424
local direction = instance_config.top_down() and stage_util.DIRECTION.TOP_DOWN
25-
or stage_util.DIRECTION.BOTTOM_UP
25+
or stage_util.DIRECTION.BOTTOM_UP
2626

2727
animator_stages = type(animator_stages) == "string" and stages[animator_stages](direction)
28-
or animator_stages
28+
or animator_stages
2929
local animator = WindowAnimator(animator_stages, instance_config)
3030
local service = NotificationService(instance_config, animator)
3131

@@ -99,7 +99,7 @@ return function(user_config, inherit, global_config)
9999
end
100100
local buf = opts.buffer or vim.api.nvim_create_buf(false, true)
101101
local notif_buf =
102-
NotificationBuf(buf, notif, vim.tbl_extend("keep", opts, { config = instance_config }))
102+
NotificationBuf(buf, notif, vim.tbl_extend("keep", opts, { config = instance_config }))
103103
notif_buf:render()
104104
return {
105105
buffer = buf,

lua/notify/service/buffer/init.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ local NotifyBufHighlights = require("notify.service.buffer.highlights")
55
---@class NotificationBuf
66
---@field highlights NotifyBufHighlights
77
---@field _config table
8-
---@field _notif notify.Notification;q
8+
---@field _notif notify.Notification
99
---@field _state "open" | "closed"
1010
---@field _buffer number
1111
---@field _height number
@@ -51,11 +51,12 @@ function NotificationBuf:open(win)
5151
return
5252
end
5353
self._state = BufState.OPEN
54+
local record = self._notif:record()
5455
if self._notif.on_open then
55-
self._notif.on_open(win)
56+
self._notif.on_open(win, record)
5657
end
5758
if self._config.on_open() then
58-
self._config.on_open()(win)
59+
self._config.on_open()(win, record)
5960
end
6061
end
6162

lua/notify/service/notification.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
---@field animate boolean
1111
---@field hide_from_history boolean
1212
---@field keep fun(): boolean
13-
---@field on_open fun(win: number) | nil
14-
---@field on_close fun(win: number) | nil
13+
---@field on_open fun(win: number, record: notify.Record) | nil
14+
---@field on_close fun(win: number, record: notify.Record) | nil
1515
---@field render fun(buf: integer, notification: notify.Notification, highlights: table<string, string>)
1616
local Notification = {}
1717

0 commit comments

Comments
 (0)