Skip to content
Open
Changes from all commits
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
18 changes: 13 additions & 5 deletions lua/nvim-tree/actions/fs/clipboard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,7 @@ end
---@param node_or_nodes Node|Node[]
---@return boolean
function Clipboard:is_nodes_array(node_or_nodes)
if type(node_or_nodes) == "table" and node_or_nodes.is and node_or_nodes:is(Node) then
return false
end
return true
return type(node_or_nodes) == "table" and node_or_nodes.is and node_or_nodes:is(Node)
end

---Copy one or more nodes
Expand Down Expand Up @@ -388,7 +385,18 @@ function Clipboard:do_paste(node, action, action_fn)

-- Paste non-conflicting items immediately
for _, item in ipairs(no_conflict) do
do_paste_one(item.node.absolute_path, item.dest, action, action_fn)
local absolute_path = item.node.absolute_path
if absolute_path:sub(1, #"http") == "http" then
notify.info("Downloading " .. absolute_path .. " to " .. item.dest .. "...")
local result = vim.fn.system({ "curl", "-sL", absolute_path, "-o", item.dest })

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As much as it pains me to talk about netrw, it appears that it handle almost all protocols:

e.g.

nvim --clean
:Nread https://raw.githubusercontent.com/nvim-tree/nvim-tree.lua/refs/heads/master/README.md

Perhaps we could invoke it to do all the work.

if vim.v.shell_error == 0 then
notify.info("Downloaded " .. absolute_path .. " successfully at " .. item.dest)
else
notify.error("Error downloading " .. absolute_path .. ": " .. result)
end
else
do_paste_one(absolute_path, item.dest, action, action_fn)
end
end

-- Resolve conflicts in batch
Expand Down
Loading