feat(notify): add notify.threshold (#1693)
* feat: configurable notification level add `notify.threshold` to setup opts * feat: configurable notification level: add threshold example doc * feat: configurable notification level: log always comes last Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
@@ -4,6 +4,7 @@ local lib = require "nvim-tree.lib"
|
||||
local log = require "nvim-tree.log"
|
||||
local utils = require "nvim-tree.utils"
|
||||
local core = require "nvim-tree.core"
|
||||
local notify = require "nvim-tree.notify"
|
||||
|
||||
local M = {}
|
||||
|
||||
@@ -81,14 +82,14 @@ local function do_single_paste(source, dest, action_type, action_fn)
|
||||
|
||||
dest_stats, errmsg, errcode = uv.fs_stat(dest)
|
||||
if not dest_stats and errcode ~= "ENOENT" then
|
||||
utils.notify.error("Could not " .. action_type .. " " .. source .. " - " .. (errmsg or "???"))
|
||||
notify.error("Could not " .. action_type .. " " .. source .. " - " .. (errmsg or "???"))
|
||||
return false, errmsg
|
||||
end
|
||||
|
||||
local function on_process()
|
||||
success, errmsg = action_fn(source, dest)
|
||||
if not success then
|
||||
utils.notify.error("Could not " .. action_type .. " " .. source .. " - " .. (errmsg or "???"))
|
||||
notify.error("Could not " .. action_type .. " " .. source .. " - " .. (errmsg or "???"))
|
||||
return false, errmsg
|
||||
end
|
||||
end
|
||||
@@ -122,11 +123,11 @@ local function add_to_clipboard(node, clip)
|
||||
for idx, _node in ipairs(clip) do
|
||||
if _node.absolute_path == node.absolute_path then
|
||||
table.remove(clip, idx)
|
||||
return utils.notify.info(node.absolute_path .. " removed to clipboard.")
|
||||
return notify.info(node.absolute_path .. " removed to clipboard.")
|
||||
end
|
||||
end
|
||||
table.insert(clip, node)
|
||||
utils.notify.info(node.absolute_path .. " added to clipboard.")
|
||||
notify.info(node.absolute_path .. " added to clipboard.")
|
||||
end
|
||||
|
||||
function M.clear_clipboard()
|
||||
@@ -157,7 +158,7 @@ local function do_paste(node, action_type, action_fn)
|
||||
local stats, errmsg, errcode = uv.fs_stat(destination)
|
||||
if not stats and errcode ~= "ENOENT" then
|
||||
log.line("copy_paste", "do_paste fs_stat '%s' failed '%s'", destination, errmsg)
|
||||
utils.notify.error("Could not " .. action_type .. " " .. destination .. " - " .. (errmsg or "???"))
|
||||
notify.error("Could not " .. action_type .. " " .. destination .. " - " .. (errmsg or "???"))
|
||||
return
|
||||
end
|
||||
local is_dir = stats and stats.type == "directory"
|
||||
@@ -219,18 +220,18 @@ function M.print_clipboard()
|
||||
end
|
||||
end
|
||||
|
||||
return utils.notify.info(table.concat(content, "\n") .. "\n")
|
||||
return notify.info(table.concat(content, "\n") .. "\n")
|
||||
end
|
||||
|
||||
local function copy_to_clipboard(content)
|
||||
if M.use_system_clipboard == true then
|
||||
vim.fn.setreg("+", content)
|
||||
vim.fn.setreg('"', content)
|
||||
return utils.notify.info(string.format("Copied %s to system clipboard!", content))
|
||||
return notify.info(string.format("Copied %s to system clipboard!", content))
|
||||
else
|
||||
vim.fn.setreg('"', content)
|
||||
vim.fn.setreg("1", content)
|
||||
return utils.notify.info(string.format("Copied %s to neovim clipboard!", content))
|
||||
return notify.info(string.format("Copied %s to neovim clipboard!", content))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user