Closed tvercruyssen closed 2 years ago
Well the dismiss function is intended for users (i.e. person viewing the notification) while the returned record is intended for the caller of the notification.
You can set the on_open
function for the notification which receives the window ID, store it somewhere and then call vim.api.nvim_win_close
when you want. nvim-notify will handle a window closing gracefully.
That works perfectly, Thanks!
It seems I looked over the fact that on_open receives the window ID. Suppose I was looking for it in the wrong place as I didn't understand that the dismiss function was intended for users. Maybe drop a hint in the documentation that it is? It may just be me missreading misreading the docs.
Hey! I know this issue has been closed for a while, but I've been wondering if there could be a more intuitive or better documented solution for this? I was trying to make a loading notification, and took me quite a while to find this. Also, I think it's likely more people would have a need for such behavior.
I have a few ideas that could be done:
id
argument to the notify.dismiss
function. If the argument is given, it'll dismiss a single notification with the given id, and not the whole thingnotify.Record
that will close the notificationThese are just a few ideas. I'd be willing to make a pull request for any of them, but I thought it'd be a better idea to discuss the best solution first
Using the id
to close a notification is problematic because there is not a 1 to 1 relationship as notifications can be replaced over time, which I imagine would be a common use case for people looking to programmatically close a notification.
The wiki is open to edits if you'd like to an entry there :smile:
Their is a possibility to replace a notification and to dissmis all of them. But no function to dissmis a single notification using it's id/NotifyRecord. As a workaround you can replace a notification and set it's timeout to 0, but this seems less than ideal. I'm I missing a function here or has their simply never been a need to close a specfic notification.