sindrets / diffview.nvim

Single tabpage interface for easily cycling through diffs for all modified files for any git rev.
Other
3.57k stars 101 forks source link

[feat][would write PR] use vim.notify for user notifications #473

Closed emmanueltouzery closed 1 month ago

emmanueltouzery commented 3 months ago

I would be interested to write a PR for that, but I'm afraid that you'd reject it, so I would first ask if you'd agree with the approach.

It seems to me that in particular error messages (eg utils.err() in the source) are not that emphasized in the GUI. neovim introduced the vim.notify call that can be overridden by users for custom display. For instance the vim.notify plugin offers such an override: https://github.com/rcarriga/nvim-notify

I would like to enable the user to decide between the current display (using nvim_echo) or vim.notify, that would allow the user to customize the display.

Possible options...

  1. rewrite utils.info/warn/err to directly call vim.notify, and delete echo_multiln
  2. add a new config option, for instance user_messages_with_notify = false
  3. add new hooks for user messages, for instance user_message_displayed. Although that's a bit redundant, because vim.notify already allows customization but...

If you think such a feature has its place in diffview, feel free to let me know which approach you'd rather see, and I can prepare a PR to that effect!

Thank you for an amazing plugin!

sindrets commented 1 month ago

I've been meaning to replace the old echo commands for a while, but never got around to it. Thank you for taking the initiative!

I think your first suggested course of action is the best one: remove echo_multiln() and call vim.notify() from the other notification functions.

vim.notify() accepts an optional table parameter, that is unused by the default handler, but many of the popular UI notification plugins at least respect the title key in this table. So let's set that to "diffview.nvim".

Are you still interested in writing a PR for this?

emmanueltouzery commented 1 month ago

Yes! Thank you for the feedback.

I'll open a pr soon based on your plan, or ask followup questions here 👍

sindrets commented 1 month ago

Great, thank you! I'll go ahead and assign you to the issue.