Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: copy/paste to system clipboard #556

Open
1 task done
stevalkr opened this issue Jan 11, 2025 · 6 comments · May be fixed by #559
Open
1 task done

feature request: copy/paste to system clipboard #556

stevalkr opened this issue Jan 11, 2025 · 6 comments · May be fixed by #559
Labels
enhancement New feature or request P2 Not a priority. PRs welcome

Comments

@stevalkr
Copy link
Contributor

Did you check existing requests?

  • I have searched the existing issues

Describe the feature

Hi! This plugin has become an essential tool for me to browse file directories. However, in some cases, using the system’s graphical file explorer (and any other tools) is more convenient. I’d like the ability to copy files from Neovim and paste them into the system clipboard (and vice versa), just like copying and pasting files in a graphical file explorer.

Provide background

When I connect a removable device, the path is often difficult to input manually. Similarly, when I want to send files to other applications (like a browser or chat software), I have to manually open the file explorer, copy the file, and then paste it into the application.

What is the significance of this feature?

strongly desired

Additional details

I’m not sure if this is feasible on all systems, but on macOS, it can be achieved using osascript.

@stevalkr stevalkr added the enhancement New feature or request label Jan 11, 2025
@stevearc
Copy link
Owner

There are actions to copy the file path, but if you want to copy the file itself that would require something like the osascript you linked. I would review a PR that adds an action with that functionality.

@stevearc stevearc added the P2 Not a priority. PRs welcome label Jan 12, 2025
@ethanuppal
Copy link

ethanuppal commented Jan 14, 2025

This would be pretty cool -- it seems it's a bit harder on Linux but very doable. I've made a fork to start tinkering with this on macOS, at least.

@ethanuppal
Copy link

As a sidenote, the keybinds gy and gp seem suitable for these actions.

stevalkr added a commit to stevalkr/oil.nvim that referenced this issue Jan 14, 2025
@stevalkr
Copy link
Contributor Author

stevalkr commented Jan 14, 2025

I’ve created a simple version of copying/pasting to the macOS clipboard, and it works. But it needs further investigation, made an ugly implementation of #156

stevalkr added a commit to stevalkr/oil.nvim that referenced this issue Jan 14, 2025
@stevalkr stevalkr linked a pull request Jan 14, 2025 that will close this issue
@stevalkr
Copy link
Contributor Author

parser.parse isn’t the best fit for asynchronous file operations. We could add a synchronous add_file function to the adapters to support not only files.

Or, we could implement it during rendering, though that’s not ideal either, but at least it’s asynchronous. If you all have any better ideas, please let me know, and I’d be happy to help.

@xzbdmw
Copy link

xzbdmw commented Jan 31, 2025

Similarly, when I want to send files to other applications (like a browser or chat software), I have to manually open the file explorer, copy the file, and then paste it into the application.

I'm using this approach to open the path in finder, after that you can copy it from there (one more step though)

                ["<c-cr>"] = function()
                    require("oil.actions").yank_entry.callback()
                    local path = vim.fn.getreg('"')
                    -- show in finder
                    vim.system({ "open", "-R", path }):wait()
                end,
                ["<d-cr>"] = function()
                    require("oil.actions").yank_entry.callback()
                    local path = vim.fn.getreg('"')
                    -- directly open
                    vim.system({ "open", path }):wait()
                end,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P2 Not a priority. PRs welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants