-
Notifications
You must be signed in to change notification settings - Fork 5
feat(#5): add copying to clipboard support #7
base: main
Are you sure you want to change the base?
feat(#5): add copying to clipboard support #7
Conversation
feat: added copy action
d2ee219 to
9914dc7
Compare
|
The unix implementation will likely fail in the near feature as |
|
@ethanholz What would you think should be the best way to approach it? This is what first comes to my mind. freeze.nvim/lua/freeze/init.lua Lines 4 to 13 in 8512ceb
Adding an option such as: local freeze = {
opts = {
-- ...
copy_cmd = ""
}
output = nil
}
-- ...
function freeze.copy(filename)
if freeze.opts.copy_cmd ~= "" then
-- use freeze.opts.copy_cmd
end
-- otherwise use the defaults?
end
|
|
No worries on Wayland, I still appreciate the changes! let me think about implementation around the |
For some reason the `copy` commands does not work properly when using them on `vim.fn.jobstart` or `vim.loop.spawn`. - Modified `freeze.dir` to be `vim.env.PWD` as default instead of `"."` for `macos` copy command to work properly (needs full path). - Moved `open` and `copy` actions to the `onExit` function so it works. If not, it will open the image but not copy it.
|
@ethanholz I made some changes for the For some reason it won't work unless outside a Tested it with both |
|
@ethanholz I added the Wayland support, but reading into Wayland here I discovered that What do you think is the best way to show if using Wayland if this not enough to tell? Maybe using |
I think this is good idea for a first pass and is good enough for review. |
|
If they merge this PR charmbracelet/freeze#97 it could be much easier, don't know exactly how it will work on It is using gclip in case you want to test it on your machine. |
|
If we can get this merged upstream I would much prefer to lean on that. Let's give it some time to see if your PR gets merged and if it does (it was reviewed so I'm hopeful), we can use that. |
`os.execute` for `vim.fn.system` for better user experience. Sometimes `os.execute` disturbs Neovim itself. Fixed `copy_macos` since it had a syntax error. If copy command fails, notify the user.
powershellscriptpowershellscript demo from Windows11 VM:Image pasted from Windows11 VM:

osascriptosascriptdemo from MacOS:osascript -e 'set the clipboard to (read (POSIX file "/Users/aome/dev/nvim_plugins/freeze.nvim/freeze.png") as JPEG picture)'Image from the script:

xclipI didn't test it yet in Ubuntu, but the script looks fine from what I use to copy images myself. If
xclipis not the way to do it, I will appreciate some suggestions.Closes #5