rcarriga / nvim-notify

A fancy, configurable, notification manager for NeoVim
MIT License
3.03k stars 81 forks source link

Option to Interrupt Timeout & Close via Keymap #203

Closed dboyd42 closed 1 year ago

dboyd42 commented 1 year ago

Trying to close the notification's popup manually before the timeout. The timeout doesn't need to be changed as (personally) the default 5 seconds works great. However, when either a notification is "blocking" text or the notification is repeated from a previous session; I'd just like to close the popup.

Any help would be appreciated. Thanks in advanced!

NStefan002 commented 1 year ago

I wanted to clear all notifications when I enter insert mode, so I created the following autocmd:

            vim.api.nvim_create_autocmd({ "InsertEnter" }, {
                group = vim.api.nvim_create_augroup("NotifyClearGrp", {}),
                pattern = "*",
                callback = function()
                    require("notify").dismiss({ silent = true })
                end
            })

You could also bind this to some keymap like:

 vim.keymap.set('mode', 'some_key_kombo', function() require("notify").dismiss({ silent = true }) end, opts) 

Note that this clears all popups. I hope this was helpful.

dboyd42 commented 1 year ago

@NStefan002 Yes, and thank you! I was previously looking at the on_close function rather than the dismiss --hence, why my config wasn't working.