fix: check for clipboard path locally to avoid recursion (#330)
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
parent
cadee677ba
commit
46a621e9de
@ -241,6 +241,7 @@ We would like to express our heartfelt gratitude to the contributors of the foll
|
||||
| --- | --- | --- | --- |
|
||||
| [git-conflict.nvim](https://github.com/akinsho/git-conflict.nvim) | No License | Diff comparison functionality | https://github.com/yetone/avante.nvim/blob/main/lua/avante/diff.lua |
|
||||
| [ChatGPT.nvim](https://github.com/jackMort/ChatGPT.nvim) | Apache 2.0 License | Calculation of tokens count | https://github.com/yetone/avante.nvim/blob/main/lua/avante/utils/tokens.lua |
|
||||
| [img-clip.nvim](https://github.com/HakonHarnes/img-clip.nvim) | MIT License | Clipboard image support | https://github.com/yetone/avante.nvim/blob/main/lua/avante/clipboard/init.lua |
|
||||
|
||||
The high quality and ingenuity of these projects' source code have been immensely beneficial throughout our development process. We extend our sincere thanks and respect to the authors and contributors of these projects. It is the selfless dedication of the open-source community that drives projects like avante.nvim forward.
|
||||
|
||||
|
@ -15,11 +15,23 @@ local Config = require("avante.config")
|
||||
---@class avante.Clipboard: AvanteClipboard
|
||||
local M = {}
|
||||
|
||||
M.paste_directory = Path:new(Config.history.storage_path):joinpath("pasted_images")
|
||||
---@type Path
|
||||
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")
|
||||
return paste_directory
|
||||
end
|
||||
|
||||
M.setup = function()
|
||||
if not M.paste_directory:exists() then
|
||||
M.paste_directory:mkdir({ parent = true })
|
||||
get_paste_directory()
|
||||
|
||||
if not paste_directory:exists() then
|
||||
paste_directory:mkdir({ parent = true })
|
||||
end
|
||||
end
|
||||
|
||||
@ -30,10 +42,7 @@ return setmetatable(M, {
|
||||
local impl = require("avante.clipboard." .. os_mapping)
|
||||
if impl[k] ~= nil then
|
||||
return impl[k]
|
||||
elseif t[k] ~= nil then
|
||||
return t[k]
|
||||
else
|
||||
error("Failed to find clipboard implementation for " .. os_mapping)
|
||||
end
|
||||
return t[k]
|
||||
end,
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user