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:
@@ -5,6 +5,21 @@ local config = {
|
||||
absolute_path = true,
|
||||
}
|
||||
|
||||
local title_support
|
||||
function M.supports_title()
|
||||
-- TODO increase stylua column_width
|
||||
-- stylua: ignore start
|
||||
if title_support == nil then
|
||||
title_support = (package.loaded.notify and (vim.notify == require "notify" or vim.notify == require("notify").notify))
|
||||
or (package.loaded.noice and (vim.notify == require("noice").notify or vim.notify == require("noice.source.notify").notify))
|
||||
or (package.loaded.notifier and require("notifier.config").has_component "nvim")
|
||||
or false
|
||||
end
|
||||
-- stylua: ignore end
|
||||
|
||||
return title_support
|
||||
end
|
||||
|
||||
local modes = {
|
||||
{ name = "trace", level = vim.log.levels.TRACE },
|
||||
{ name = "debug", level = vim.log.levels.DEBUG },
|
||||
@@ -20,6 +35,10 @@ do
|
||||
end
|
||||
|
||||
vim.schedule(function()
|
||||
if not M.supports_title() then
|
||||
msg = "[NvimTree]\n" .. msg
|
||||
end
|
||||
|
||||
vim.notify(msg, level, { title = "NvimTree" })
|
||||
end)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user