feat(clipboard): support windows (#345)

Signed-off-by: Hanchin Hsieh <me@yuchanns.xyz>
This commit is contained in:
Hanchin Hsieh 2024-08-29 12:00:19 +08:00 committed by GitHub
parent 38a5dbe429
commit cb197fb606
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 6 deletions

View File

@ -49,6 +49,8 @@ Install `avante.nvim` using [lazy.nvim](https://github.com/folke/lazy.nvim):
drag_and_drop = {
insert_mode = true,
},
-- required for Windows users
use_absolute_path = true,
},
},
},

View File

@ -61,14 +61,15 @@ M.get_base64_content = function(filepath)
local output
if os_mapping == "darwin" or os_mapping == "linux" then
output = Utils.shell_run(("cat %s | base64 | tr -d '\n'"):format(filepath))
else
output =
Utils.shell_run(("([Convert]::ToBase64String([IO.File]::ReadAllBytes('%s')) -replace '`r`n')"):format(filepath))
end
if output.code == 0 then
return output.stdout
else
error("Failed to convert image to base64")
end
else
Utils.warn("Windows is not supported yet", { title = "Avante" })
end
end
return M