Closed ianbattersby closed 1 year ago
Went down a couple of routes to do this myself but the best way to do this is to avoid using the existing buffer, it's tied to the animation so even if you stop the timeout, there can be other issues with opacity changes.
Instead, I've added a new notify.open
function which you can use to open and render a notification in a buffer including all of the highlights and extmarks (doing this manually would have been tricky :sweat_smile:).
Sample usage for your use case
local notify = require("notify")
local notif
notif = notify("Hello World", vim.log.levels.INFO, {
on_open = function(win)
local bufnr = vim.api.nvim_win_get_buf(win)
vim.keymap.set("n", "<C-t>", function()
local opened = require("notify").open(notif)
vim.cmd("tab split")
vim.api.nvim_win_set_buf(0, opened.buffer)
end, { noremap = true, silent = true, desc = "Dismiss", buffer = bufnr })
end,
})
That is amazing - thank you! 🙇
FWIW, I'm currently using @folke's excellent noice.nvim so have coded this into its notify
backend for the moment. I suspect @folke might be interested in adding this as a configuration option if the other backends can also support it.
@ianbattersby for Noice, you can simply do :Noice last
. That'll open the last noice message (which can be displayed anywhere like nvim-notify) in a popup.
@folke This is an excellent point, and I've now wired up some mappings to take best advantage. I'm still going to experiment with being able to extend mvim-notify
hooks as to facilitate more complex scenarios (and leverage @rcarriga's hard work).
Thanks again to you both, immensely grateful 🙇
Sincere thanks for the amazing plugin and all the hard work!
I'm trying to mangle my config so that I can break out a notification into a different tab should (a) it be hard to read inside the popup window and/or (b) I want to take a better look. Breaking the buffer into a separate tab was quite straight forward using the
on_open
event (see below) but I'm struggling to see how I can cancel the associated timer that will close the buffer. Is this even possible or should I look to duplicate the buffer contents into a new one?