Skip to content
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

Dismiss notification by id #240

Open
chrisgrieser opened this issue Jan 2, 2024 · 3 comments
Open

Dismiss notification by id #240

chrisgrieser opened this issue Jan 2, 2024 · 3 comments

Comments

@chrisgrieser
Copy link
Contributor

Right now, we can use a notification id to replace a notification, and we can use dismiss to dismiss all notifications. Would it be possible to dismiss a specific notification by id?

@rcarriga
Copy link
Owner

rcarriga commented Jan 3, 2024

Would you mind describing the use case to be able to do this?

@chrisgrieser
Copy link
Contributor Author

chrisgrieser commented Jan 3, 2024

In my plugin, I want to keep certain notifications on screen for a bit longer (using timeout = false). When I then want to dismiss the notification, the option I have is to dismiss all notifications, which has the undesired side effect of also dismissing any other notifications (from other plugins or from the user) as well


the concrete use case: In my plugin tinygit, I want to display commit-diffstats while the user is entering a commit message
Pasted image 2024-01-03 at 17 08 31@2x

@jonathan-elize
Copy link

So I was wondering if this was possible as well. I use a notification to show when I'm debugging certain things and it wanted to be able to dismiss just that notification specifically when I finish debugging without closing any other notifications I might have open.

I found we can accomplish this by using the current functionality of nvim-notify to replace the original message with a very short timeout so it leaves almost immediately:

local debug_notify_id = vim.notify("Debugging...", vim.log.levels.WARN)

-- Once debugging is done:
vim.notify("Debugging...", vim.log.levels.WARN, { timeout = 1, replace = debug_notify_id })

debug_notify_id is the id of the original message I sent out. I set a timeout of 1 millisecond to make it leave after this amount of time. 1 milisecond is almost effectively making it leave immediately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants