chore(clipboard): separate logic to save as base64 and files (#329)

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
Aaron Pham
2024-08-28 11:52:12 -04:00
committed by GitHub
parent 2c450b1da3
commit 755c15c0bd
9 changed files with 89 additions and 9 deletions

View File

@@ -1,16 +1,28 @@
---NOTE: this module is inspired by https://github.com/HakonHarnes/img-clip.nvim/tree/main
---@see https://github.com/ekickx/clipboard-image.nvim/blob/main/lua/clipboard-image/paste.lua
local Path = require("plenary.path")
local Utils = require("avante.utils")
local Config = require("avante.config")
---@class AvanteClipboard
---@field clip_cmd string
---@field get_clip_cmd fun(): string
---@field has_content fun(): boolean
---@field get_content fun(): string
---@field get_base64_content fun(): string
---@field save_content fun(filename: string): boolean
---
---@class avante.Clipboard: AvanteClipboard
local M = {}
M.paste_directory = Path:new(Config.history.storage_path):joinpath("pasted_images")
M.setup = function()
if not M.paste_directory:exists() then
M.paste_directory:mkdir({ parent = true })
end
end
return setmetatable(M, {
__index = function(t, k)
local os_mapping = Utils.get_os_name()