feat: use virtual title in notifications if title is not supported (#2439)
* feat: use virtual title in notifications if title is not supported * Fix boolean expressions * Replace `pcall` with `package.loaded` * Detect title support before sending notification * Prevent `title_support` from being nil after evaluation * temporary stylua suppression --------- Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
@@ -15,12 +15,7 @@ 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 function notify_once(msg, level)
|
||||
vim.schedule(function()
|
||||
vim.notify_once(msg, level or vim.log.levels.WARN, { title = "NvimTree" })
|
||||
end)
|
||||
end
|
||||
local notify = require "nvim-tree.notify"
|
||||
|
||||
local _config = {}
|
||||
|
||||
@@ -730,7 +725,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
|
||||
@@ -743,7 +738,7 @@ local function validate_options(conf)
|
||||
validate(conf, DEFAULT_OPTS, ACCEPTED_STRINGS, ACCEPTED_TYPES, "")
|
||||
|
||||
if msg then
|
||||
notify_once(msg .. "\n\nsee :help nvim-tree-opts for available configuration options")
|
||||
notify.warn(msg .. "\n\nsee :help nvim-tree-opts for available configuration options")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -766,7 +761,7 @@ end
|
||||
|
||||
function M.setup(conf)
|
||||
if vim.fn.has "nvim-0.8" == 0 then
|
||||
notify_once "nvim-tree.lua requires Neovim 0.8 or higher"
|
||||
notify.warn "nvim-tree.lua requires Neovim 0.8 or higher"
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user