rcarriga / nvim-notify

A fancy, configurable, notification manager for NeoVim
MIT License
3k stars 80 forks source link

Show notifications on top of relevant window #108

Closed andrewferrier closed 2 years ago

andrewferrier commented 2 years ago

It would be really nice if there was a way to show notifications on top of a relevant Vim window. I use split windows a lot in NeoVim, and notifications always appear in the top-right-hand corner of the NeoVim terminal, irrespective of which buffer/window the message applies to. I use vim.notify = require('notify') to set up nvim-notify; presumably it could be theoretically possible to pass a custom param in the opts (last) parameter to vim.notify which specified a window or buffer number to display the notification on top of. Clearly this would only work when that parameter was added.

Thanks for all your hard work on this plugin, I use it daily!

rcarriga commented 2 years ago

This would massively complicate the rendering so I don't think I'd want this to be a feature of nvim-notify. However what you could do is to use separate instances of nvim-notify within a custom vim.notify function and handle the window param there.

Something like this

local notify = require("notify")
local instances = {}
vim.notify = function (msg, level, opts)
  opts = opts or {}

  if not opts.win then
    return notify(msg, level, opts)
  end
  if not instances[opts.win] then
    instances[opts.win] = notify.instance({
      stages = ... -- Some custom animation stages that choose where to place windows based on given window param 
    })
  end
  return instances[opts.win](msg, level, opts)
end
andrewferrier commented 2 years ago

Yep, that makes sense. I'm not 100% sure I agree that it doesn't fit in nvim-notify (currently some notifications actually get very confusing because they look like they pertain to the window in the top-most/right-most part of the screen, even when they don't, so in my mind this is verging on "bug" territory...), but I get your concern about complicating the code.

I might work on something custom using the pattern outlined above. If I get somewhere, I'll come back and see whether you want to include it. If not, maybe it might at least be useful in a wiki or linked from a README or such...

Thanks, and thanks for all your hard work on this great plugin!

rcarriga commented 2 years ago

Would definitely love something like this for the wiki! If the solution uses multiple instances then I don't think it'll be added to the repo, but if you really wanted you could define a custom stages to handle placing the windows separately. However I do think this would be a painful exercise :sweat_smile: