feat(clipboard): initial support (#279)
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
27
lua/avante/clipboard/init.lua
Normal file
27
lua/avante/clipboard/init.lua
Normal file
@@ -0,0 +1,27 @@
|
||||
---NOTE: this module is inspired by https://github.com/HakonHarnes/img-clip.nvim/tree/main
|
||||
|
||||
local Utils = require("avante.utils")
|
||||
|
||||
---@class AvanteClipboard
|
||||
---@field clip_cmd string
|
||||
---@field get_clip_cmd fun(): string
|
||||
---@field has_content fun(): boolean
|
||||
---@field get_content fun(): string
|
||||
---
|
||||
---@class avante.Clipboard: AvanteClipboard
|
||||
local M = {}
|
||||
|
||||
return setmetatable(M, {
|
||||
__index = function(t, k)
|
||||
local os_mapping = Utils.get_os_name()
|
||||
---@type AvanteClipboard
|
||||
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
|
||||
end,
|
||||
})
|
||||
Reference in New Issue
Block a user