Closed Deton8t closed 5 months ago
I'm fairly new to this but for example if I wanted to use the example of the PrintNotifier. How would I set a timer to use this Notifier after adding the init entry in the notifiers field? Thanks!
I figured it out.
Use it like normal: :TimerStart TIMELIMIT [NAME]
.
I hope this helps!
-- ~/.config/nvim/lua/plugins/pomo.lua
return {
"epwalsh/pomo.nvim",
version = "*",
lazy = true,
cmd = { "TimerStart", "TimerRepeat" },
dependencies = {
"rcarriga/nvim-notify",
},
opts = {
notifiers = {
{
init = function(timer, opts)
local PrintNotifier = {}
PrintNotifier.new = function(timer, opts)
local self = setmetatable({}, { __index = PrintNotifier })
self.timer = timer
self.hidden = false
self.opts = opts -- not used
return self
end
PrintNotifier.start = function(self)
print(
string.format(
"Starting timer #%d, %s, for %ds",
self.timer.id,
self.timer.name,
self.timer.time_limit
)
)
end
PrintNotifier.tick = function(self, time_left)
if not self.hidden then
print(
string.format(
"Timer #%d, %s, %ds remaining...",
self.timer.id,
self.timer.name,
time_left
)
)
end
end
PrintNotifier.done = function(self)
print(string.format("Timer #%d, %s, complete", self.timer.id, self.timer.name))
end
PrintNotifier.stop = function(self) end
PrintNotifier.show = function(self)
self.hidden = false
end
PrintNotifier.hide = function(self)
self.hidden = true
end
return PrintNotifier.new(timer, opts)
end,
opts = {},
},
},
},
}
Ah I was a little confused about where I would set the name of the timer. Thanks for the help.
📚 The doc issue
How do I access user created notifiers?
Suggest a potential alternative/fix
No response