Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lua/nvim-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ local modified = require "nvim-tree.modified"
local find_file = require "nvim-tree.actions.tree.find-file"
local open = require "nvim-tree.actions.tree.open"
local events = require "nvim-tree.events"
local notify = require "nvim-tree.notify"

local function notify_once(msg, level)
if not notify.supports_title then
msg = "[NvimTree]\n" .. msg
end

vim.schedule(function()
vim.notify_once(msg, level or vim.log.levels.WARN, { title = "NvimTree" })
end)
Expand Down Expand Up @@ -729,7 +734,7 @@ local function validate_options(conf)
if msg then
msg = string.format("%s\n%s", msg, invalid)
else
msg = string.format("[NvimTree]\n%s", invalid)
msg = invalid
end
user[k] = nil
else
Expand Down
8 changes: 8 additions & 0 deletions lua/nvim-tree/notify.lua
Original file line number Diff line number Diff line change
@@ -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)
Copy link
Member

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

Copy link
Collaborator Author

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.

or (pcall(require, "notifier") and require("notifier.config").has_component "nvim")

local config = {
threshold = vim.log.levels.INFO,
absolute_path = true,
Expand All @@ -19,6 +23,10 @@ do
return
end

if not M.supports_title then
msg = "[NvimTree]\n" .. msg
end

vim.schedule(function()
vim.notify(msg, level, { title = "NvimTree" })
end)
Expand Down