-
-
Notifications
You must be signed in to change notification settings - Fork 627
feat: use virtual title in notifications if title is not supported #2439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
And maybe now it's time to raise stylua's column width, splitting these boolean expressions would be really confusing. |
It is hard to determine whether we have an alternate notify plugin installed. Could we be clever and look for the Experimenting:
That's a no... We couldn't detect whether vim.notify has changed over time either, due to plugin load/setup order. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will result in user happiness, thanks for taking it on.
We have options:
- Harden detection.
It might be nicer to put it innotify.setup
so it runs at a controlled time rather than on module load. - Add
notify.prefix
boolean|string or similar, default"[NvimTree]\n"
I prefer 1 - we have too many options and users can add additional notify plugin detection if needed.
Edit: moving to setup is not possible.
lua/nvim-tree/notify.lua
Outdated
@@ -1,5 +1,9 @@ | |||
local M = {} | |||
|
|||
M.supports_title = (pcall(require, "notify") and vim.notify == require "notify" or vim.notify == require("notify").notify) | |||
or (pcall(require, "noice") and vim.notify == require("noice").notify or vim.notify == require("noice.source.notify").notify) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one's not happy when we don't have noice:
Error detected while processing /tmp/nvt-dev/nvt-dev.lua:
E5113: Error while calling lua chunk: ...v/site/pack/packer/start/master/lua/nvim-tree/notify.lua:4: module 'noice.source.notify' not found:
no field package.preload['noice.source.notify']
no file './noice/source/notify.lua'
no file '/usr/share/luajit-2.1/noice/source/notify.lua'
no file '/usr/local/share/lua/5.1/noice/source/notify.lua'
no file '/usr/local/share/lua/5.1/noice/source/notify/init.lua'
no file '/usr/share/lua/5.1/noice/source/notify.lua'
no file '/usr/share/lua/5.1/noice/source/notify/init.lua'
no file './noice/source/notify.so'
no file '/usr/local/lib/lua/5.1/noice/source/notify.so'
no file '/usr/lib/lua/5.1/noice/source/notify.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file './noice.so'
no file '/usr/local/lib/lua/5.1/noice.so'
no file '/usr/lib/lua/5.1/noice.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
[C]: in function 'require'
...v/site/pack/packer/start/master/lua/nvim-tree/notify.lua:4: in main chunk
[C]: in function 'require'
...-dev/site/pack/packer/start/master/lua/nvim-tree/api.lua:1: in main chunk
[C]: in function 'require'
/tmp/nvt-dev/nvt-dev.lua:49: in main chunk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I forgot to put parentheses on the second part, it did not show up to me because I have nvim-notify enabled.
Yeah, this is getting silly. The intent is to keep statements minimal however sometimes you just have to have long lines for readability.
How about trying, say, 140 on a new branch and we see how it looks? |
Would it be possible for us to move FYI: my nvim-tree availability is late Sat to early Mon AEST |
Yeah, I also initially considered to add a user option to manage it, but this is such a slight and almost irrelevant improvement that probably no one would care about going out of their way to change it. In order to harden detection, as it stands now the notification plugin must be loaded before nvim-tree, but that's something that the user should do manually, so it isn't ideal... Otherwise we can put the boolean expression inside a function that gets evaluated each time. I'm trying to create an hybrid that evaluates the expression only once (the first time it gets called) and then reuse its result without other pointless evaluations. |
That would make sense, but there are a couple of choices to be made to make it consistent with other members of the Edit: now that I think about it... Can't we just use |
140 seems reasonable, I'm not sure what you mean by seeing how it looks on a new branch however. I mean, if we want to merge this when it will be ready I don't see any other decent alternative... |
This is the most efficient and effective solution I can find |
Thank you. That simplifies greatly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- nvim-notify
- noice
- notifier
Added a temporary suppression. Changing format disrupts PRs in flight, so we will do that when the queue is empty. |
Having
[NvimTree]
as a notification header while using a notification system that actually supports title is redundant, so with this simple change it will be added only if needed.