chore: run stylua [generated] (#460)
* chore: add stylua Signed-off-by: Aaron Pham <contact@aarnphm.xyz> * chore: running stylua Signed-off-by: Aaron Pham <contact@aarnphm.xyz> --------- Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
---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")
|
||||
local Path = require "plenary.path"
|
||||
local Utils = require "avante.utils"
|
||||
local Config = require "avante.config"
|
||||
---@module "img-clip"
|
||||
local ImgClip = nil
|
||||
|
||||
@@ -18,10 +18,8 @@ local paste_directory = nil
|
||||
|
||||
---@return Path
|
||||
local function get_paste_directory()
|
||||
if paste_directory then
|
||||
return paste_directory
|
||||
end
|
||||
paste_directory = Path:new(Config.history.storage_path):joinpath("pasted_images")
|
||||
if paste_directory then return paste_directory end
|
||||
paste_directory = Path:new(Config.history.storage_path):joinpath "pasted_images"
|
||||
return paste_directory
|
||||
end
|
||||
|
||||
@@ -30,21 +28,15 @@ M.support_paste_image = Config.support_paste_image
|
||||
M.setup = function()
|
||||
get_paste_directory()
|
||||
|
||||
if not paste_directory:exists() then
|
||||
paste_directory:mkdir({ parent = true })
|
||||
end
|
||||
if not paste_directory:exists() then paste_directory:mkdir { parent = true } end
|
||||
|
||||
if M.support_paste_image() and ImgClip == nil then
|
||||
ImgClip = require("img-clip")
|
||||
end
|
||||
if M.support_paste_image() and ImgClip == nil then ImgClip = require "img-clip" end
|
||||
end
|
||||
|
||||
---@param line? string
|
||||
M.paste_image = function(line)
|
||||
line = line or nil
|
||||
if not Config.support_paste_image(true) then
|
||||
return false
|
||||
end
|
||||
if not Config.support_paste_image(true) then return false end
|
||||
|
||||
local opts = {
|
||||
dir_path = paste_directory:absolute(),
|
||||
@@ -54,9 +46,7 @@ M.paste_image = function(line)
|
||||
},
|
||||
}
|
||||
|
||||
if vim.fn.has("wsl") > 0 or vim.fn.has("win32") > 0 then
|
||||
opts.use_absolute_path = true
|
||||
end
|
||||
if vim.fn.has "wsl" > 0 or vim.fn.has "win32" > 0 then opts.use_absolute_path = true end
|
||||
|
||||
return ImgClip.paste_image(opts, line)
|
||||
end
|
||||
@@ -75,7 +65,7 @@ M.get_base64_content = function(filepath)
|
||||
if output.code == 0 then
|
||||
return output.stdout
|
||||
else
|
||||
error("Failed to convert image to base64")
|
||||
error "Failed to convert image to base64"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user