Skip to content

feat: add feature to download from url when p from register#3339

Open
Uanela wants to merge 5 commits into
chore/remove-operation-between-instances-protocolfrom
feat/add-download-from-path
Open

feat: add feature to download from url when p from register#3339
Uanela wants to merge 5 commits into
chore/remove-operation-between-instances-protocolfrom
feat/add-download-from-path

Conversation

@Uanela

@Uanela Uanela commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Depends on #3336

Summary

This PR simply takes #3336 one step further and allows downloading files directly to nvim when it finds URL on the register on p.

  • There is no edge case that I've just forgotten what was is it and not quite sure if it is real a problem (may I'll update if I remember it)
  • It only works when the text starts with http I don't if should support other protocols. btw passing an url that doens't start with http will be treated as a folder because my folder/file can be github.com/user/some-blog.png which is also a valid link on http context.

Context: #3336 (comment)

@Uanela Uanela requested review from alex-courtis and gegoune June 18, 2026 09:20

@gegoune gegoune left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I wasn't following recent discussions too closely, got one question: why do we want nvim-tree to handle fetching files over http?

Comment thread lua/nvim-tree/actions/fs/clipboard.lua Outdated
Co-authored-by: gegoune <69750637+gegoune@users.noreply.github.com>
@Uanela

Uanela commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator Author

I wasn't following recent discussions too closely, got one question: why do we want nvim-tree to handle fetching files over http?

I read this through my phones notification bar and it sounded like whey do we need cars to fly, rsrsrsrs.

This PR as more to do with #3336 and is basically a one tiny addition to allow download files, WHY? On #3336 I added a feature to allow c and p between different nvim-tree instances this discussion was undergoing at #1549, as the feature simply copies the absolute path(s) and pastes into another instance and nvim-tree deals with it and make copy/cut an horizon of possibilites were opened:

1 - Copy/Cut files from anywhere on the OS as far as you got the absolute path, I can go to finder/explorer simply grab the absolute path and go paste into nvim-tree
2 - Most of the time when download something to a project (image, audio, video, etc) you download it to your OS explorer then copy to your IDE (and on vim we basically can't), then I thought why do I need to download first and copy to my project why not simply download directly to my project then this PR feature came along just grab the link and p on nvim-tree and it will download it.

Fix is_nodes_array function to correctly identify node arrays.
@alex-courtis alex-courtis changed the base branch from master to chore/remove-operation-between-instances-protocol June 20, 2026 03:46
@alex-courtis

Copy link
Copy Markdown
Member

Hope you don't mind, I changed the target branch for reviewability. It will change to master after merge.

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.

@alex-courtis

Copy link
Copy Markdown
Member

There is also https://github.com/miversen33/netman.nvim which we could integrate with to provide the file transfers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants