New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set notification frequence or possibly a DND mode? #210
Comments
The API is meant to be quite simple and to be extended by users. local notify = require("notify")
local dnd = false
vim.api.nvim_create_user_command("NotifyDND", function()
dnd = not dnd
end)
vim.notify = function(...)
if not dnd then
notify(...)
end
end but blanket silencing might be overkill. local notify = require("notify")
local buffered_messages = {
"Client %d+ quit",
}
local message_notifications = {}
vim.notify = function(msg, level, opts)
opts = opts or {}
for _, pattern in ipairs(buffered_messages) do
if string.find(msg, pattern) then
if message_notifications[pattern] then
opts.replace = message_notifications[pattern]
end
opts.on_close = function()
message_notifications[pattern] = nil
end
message_notifications[pattern] = notify.notify(msg, level, opts)
return
end
end
notify.notify(msg, level, opts)
end and if you wanted the noisy messages to also have a timeout: local notify = require("notify")
local MIN = 1000 * 60 * 60
local buffered_messages = {
["Client %d+ quit"] = false
}
local message_notifications = {}
vim.notify = function(msg, level, opts)
opts = opts or {}
for pattern, is_visible in pairs(buffered_messages) do
if string.find(msg, pattern) then
if message_notifications[pattern] then
if not is_visible then
return
end
opts.replace = message_notifications[pattern]
end
buffered_messages[pattern] = true
opts.on_close = function()
buffered_messages[pattern] = false
vim.defer_fn(function()
message_notifications[pattern] = nil
end, MIN * 15)
end
message_notifications[pattern] = notify.notify(msg, level, opts)
return
end
end
notify.notify(msg, level, opts)
end Those are just for example, there are lots of small customisations you could |
Thanks a lot for the answer, I'll try it out |
In cases where a plugin does multiple notify calls, is it possible to set the frequency at which notifications can be shown?
e.g - Show notification after every 15 mins
Another approach would be to add something like a
:DNDToggle
command that disables and enables notificationsThe text was updated successfully, but these errors were encountered: