-
Notifications
You must be signed in to change notification settings - Fork 143
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
feat: copy/paste to system clipboard #559
base: master
Are you sure you want to change the base?
Conversation
Hi @stevearc, I’m having a bit of trouble with the |
This PR looks like it's doing two things: yanking/pasting using osascript, and changing the buffer parsing logic to allow for As an alternative approach to support pasting, what if we found the parent directory of the pasted file, performed an async read of that directory, and then properly inserted the correct line into the current buffer? It's more logic on paste, but it leaves the rest of the internals the same. |
1cfc643
to
3c8c533
Compare
Hi @stevearc! I’ve implemented the method you suggested. I haven’t thoroughly tested all the cases, but it should work fine. However, the code might need some cleaning up :) |
I’ve also added support for Linux (but it needs some testing). But the default file explorer 'nautilus' on Ubuntu doesn’t support the MIME type 'text/uri-list'. I think we could add a config option so the user can specify their own command for reading and writing the clipboard. Also, include an example of supporting 'nautilus’s special protocol in the readme. copy:
paste:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm...I tested it on my mac but I can't seem to get it working. Copying a file in finder and pasting produces
...tevearc/dotfiles/vimplugins/oil.nvim/lua/oil/actions.lua:503: bad argument #2 to 'fs_realpath' (function or callable table expected, got number)
stack traceback:
^I[C]: in function 'fs_realpath'
^I...tevearc/dotfiles/vimplugins/oil.nvim/lua/oil/actions.lua:503: in function <...tevearc/dotfiles/vimplugins/oil.nvim/lua/oil/actions.lua:501>
If I copy to the system clipboard, there's no feedback or anything but I can't seem to paste anything into finder. Any ideas?
My bad, should be resolved in the latest commit
I added a notify when file is copied to system clipboard, but I can copy and paste as expected. Could you provide me your macOS and shell version? It might be an issue with shell unquoting or a change in osascript Note: none of the commands would fail if the input is not valid. It’s only a notify, doesn’t mean it succeeded |
lua/oil/actions.lua
Outdated
cmd = | ||
"osascript -e 'on run args' -e 'set the clipboard to POSIX file (first item of args)' -e 'end run' '%s'" | ||
elseif fs.is_linux then | ||
cmd = "echo -en '%s\\n' | xclip -i -selection clipboard -t text/uri-list" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xclip is only for X11, for wayland you would have to use wl-clipboard, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! Could you help me find and test the equivalent command using wl-clipboard
? I’m not using Linux anymore, so it’s difficult for me to test these things out.
Edit: I found it quite straightforward. Wayland is now supported in the latest commit. Please give it a try! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm on MacOS unfortunately, just spotted this and thought I'd let you know :-)
This PR
Closes #556
Closes #569
Closes#156Known bugs:
fs.posix_to_os_path
or similar.