folke / snacks.nvim

🍿 A collection of small QoL plugins for Neovim
Apache License 2.0
969 stars 16 forks source link

feature(notifier): add `timeout = 0|false` to keep the notification until manually dismissed #102

Closed chrisgrieser closed 2 hours ago

chrisgrieser commented 2 hours ago

Did you check the docs?

Is your feature request related to a problem? Please describe.

One common scenario is wanting to keep a notification on screen until manually dismissed via require("snacks").notifier.hide(). An ergonomic and intuitive way for doing so would be to have timeout = 0 (or timeout = false) effectively disable the timeout.

This would make snacks.nvim also more backwards-compatible with nvim-notify, which also uses timeout = false to keep a notification on screen.

Describe the solution you'd like

vim.notify("foobar", vim.log.levels.INFO, { timeout = 0 }) should keep the notification on screen, and timeout = false would do the same.

Describe alternatives you've considered

Using keep = function() return true end.

Additional context

As far as I can tell, timeout = 0 to keep something on screen is a common practice when designing APIs. Obsidian notifications, for instance, also work like that.

folke commented 2 hours ago

Good idea. Added!

chrisgrieser commented 2 hours ago

wow, thanks for the quick implementation.

chrisgrieser commented 2 hours ago

Brief follow-up: I just noticed, it should definitely also support timeout = false. Because right now, timeout = false does work for nvim-notify but not snacks, while timeout = 0 works for snacks, but not nvim-notify.

folke commented 2 hours ago

Added as well.

folke commented 2 hours ago

And for completeness timeout = true for the default timeout...