feat(notify): switch all print/nvim_*write statements to utils.notify
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
local a = vim.api
|
||||
local uv = vim.loop
|
||||
|
||||
local lib = require "nvim-tree.lib"
|
||||
@@ -82,7 +81,7 @@ 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
|
||||
a.nvim_err_writeln("Could not " .. action_type .. " " .. source .. " - " .. (errmsg or "???"))
|
||||
utils.notify.error("Could not " .. action_type .. " " .. source .. " - " .. (errmsg or "???"))
|
||||
return false, errmsg
|
||||
end
|
||||
|
||||
@@ -105,7 +104,7 @@ local function do_single_paste(source, dest, action_type, action_fn)
|
||||
if should_process then
|
||||
success, errmsg = action_fn(source, dest)
|
||||
if not success then
|
||||
a.nvim_err_writeln("Could not " .. action_type .. " " .. source .. " - " .. (errmsg or "???"))
|
||||
utils.notify.error("Could not " .. action_type .. " " .. source .. " - " .. (errmsg or "???"))
|
||||
return false, errmsg
|
||||
end
|
||||
end
|
||||
@@ -119,11 +118,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 a.nvim_out_write(node.absolute_path .. " removed to clipboard.\n")
|
||||
return utils.notify.info(node.absolute_path .. " removed to clipboard.\n")
|
||||
end
|
||||
end
|
||||
table.insert(clip, node)
|
||||
a.nvim_out_write(node.absolute_path .. " added to clipboard.\n")
|
||||
utils.notify.info(node.absolute_path .. " added to clipboard.\n")
|
||||
end
|
||||
|
||||
function M.copy(node)
|
||||
@@ -148,7 +147,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)
|
||||
a.nvim_err_writeln("Could not " .. action_type .. " " .. destination .. " - " .. (errmsg or "???"))
|
||||
utils.notify.error("Could not " .. action_type .. " " .. destination .. " - " .. (errmsg or "???"))
|
||||
return
|
||||
end
|
||||
local is_dir = stats and stats.type == "directory"
|
||||
@@ -210,18 +209,18 @@ function M.print_clipboard()
|
||||
end
|
||||
end
|
||||
|
||||
return a.nvim_out_write(table.concat(content, "\n") .. "\n")
|
||||
return utils.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 a.nvim_out_write(string.format("Copied %s to system clipboard! \n", content))
|
||||
return utils.notify.info(string.format("Copied %s to system clipboard! \n", content))
|
||||
else
|
||||
vim.fn.setreg('"', content)
|
||||
vim.fn.setreg("1", content)
|
||||
return a.nvim_out_write(string.format("Copied %s to neovim clipboard \n", content))
|
||||
return utils.notify.info(string.format("Copied %s to neovim clipboard \n", content))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
local a = vim.api
|
||||
local uv = vim.loop
|
||||
|
||||
local utils = require "nvim-tree.utils"
|
||||
@@ -19,7 +18,7 @@ local function create_file(file)
|
||||
end
|
||||
local ok, fd = pcall(uv.fs_open, file, "w", 420)
|
||||
if not ok then
|
||||
a.nvim_err_writeln("Couldn't create file " .. file)
|
||||
utils.notify.error("Couldn't create file " .. file)
|
||||
return
|
||||
end
|
||||
uv.fs_close(fd)
|
||||
@@ -90,14 +89,14 @@ function M.fn(node)
|
||||
elseif not utils.file_exists(path_to_create) then
|
||||
local success = uv.fs_mkdir(path_to_create, 493)
|
||||
if not success then
|
||||
a.nvim_err_writeln("Could not create folder " .. path_to_create)
|
||||
utils.notify.error("Could not create folder " .. path_to_create)
|
||||
is_error = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
if not is_error then
|
||||
a.nvim_out_write(new_file_path .. " was properly created\n")
|
||||
utils.notify.info(new_file_path .. " was properly created\n")
|
||||
end
|
||||
events._dispatch_folder_created(new_file_path)
|
||||
if M.enable_reload then
|
||||
|
||||
@@ -36,7 +36,7 @@ end
|
||||
local function remove_dir(cwd)
|
||||
local handle = luv.fs_scandir(cwd)
|
||||
if type(handle) == "string" then
|
||||
return a.nvim_err_writeln(handle)
|
||||
return utils.notify.error(handle)
|
||||
end
|
||||
|
||||
while true do
|
||||
@@ -75,17 +75,18 @@ function M.fn(node)
|
||||
if node.nodes ~= nil and not node.link_to then
|
||||
local success = remove_dir(node.absolute_path)
|
||||
if not success then
|
||||
return a.nvim_err_writeln("Could not remove " .. node.name)
|
||||
return utils.notify.error("Could not remove " .. node.name)
|
||||
end
|
||||
events._dispatch_folder_removed(node.absolute_path)
|
||||
else
|
||||
local success = luv.fs_unlink(node.absolute_path)
|
||||
if not success then
|
||||
return a.nvim_err_writeln("Could not remove " .. node.name)
|
||||
return utils.notify.error("Could not remove " .. node.name)
|
||||
end
|
||||
events._dispatch_file_removed(node.absolute_path)
|
||||
clear_buffer(node.absolute_path)
|
||||
end
|
||||
utils.notify.info(node.absolute_path .. " was properly removed.")
|
||||
if M.enable_reload then
|
||||
require("nvim-tree.actions.reloaders.reloaders").reload_explorer()
|
||||
end
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
local a = vim.api
|
||||
local uv = vim.loop
|
||||
|
||||
local lib = require "nvim-tree.lib"
|
||||
@@ -21,8 +20,7 @@ function M.rename(node, to)
|
||||
if not success then
|
||||
return utils.notify.warn(err_fmt(node.absolute_path, to, err))
|
||||
end
|
||||
utils.clear_prompt()
|
||||
a.nvim_out_write(node.absolute_path .. " ➜ " .. to .. "\n")
|
||||
utils.notify.info(node.absolute_path .. " ➜ " .. to .. "\n")
|
||||
utils.rename_loaded_buffers(node.absolute_path, to)
|
||||
events._dispatch_node_renamed(node.absolute_path, to)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user