rcarriga / nvim-notify

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

Notification text wrapping #99

Closed asmodeus812 closed 2 years ago

asmodeus812 commented 2 years ago

Is there a way to make the notification text wrap since long text at the moment just runs off to the right and is cut off and not visible mostly. It would be great to allow for wrap.

rcarriga commented 2 years ago

You can set wrap using the on_open config option but wrapping doesn't work well with styles that move the window so you'd have to use static or fade for your stages option (assuming you don't want a buggy appearance)

asmodeus812 commented 2 years ago

@rcarriga thanks for the feedback, while setting wrap does work, what does not is autoexpanding the notification popup, after wrapping, i.e the notification window is always 2 or 3 lines high, and wrapping causes some of the text to be hidden, that is why i issued this question, maybe it is something that needs to be handled internally, no idea how to do that in on open however.

rcarriga commented 2 years ago

Ah so to handle that you'll have to use custom stages. The stages currently use the message height/width to set the window height/width but to handle wrapping you would have to calculate the window width with wrapping taken into account.

I've added the buffer to the arguments passed to the initial stage so you can check the raw text in the buffer and calculate the height.

CSpencerND commented 2 years ago

You can set wrap using the on_open config option

Can you show an example how to do this please?

rcarriga commented 2 years ago

Setting wrap with on_open can be done like this

require("notify").setup({
  on_open = function(win)
     vim.api.nvim_win_set_option(win, "wrap", true)
  end,
})

The stages are documented here https://github.com/rcarriga/nvim-notify#animation-style An example of using custom ones: https://github.com/rcarriga/nvim-notify/issues/94#issuecomment-1146777125

CSpencerND commented 2 years ago

@rcarriga Thanks!