feat: fetch tool (#1196)

This commit is contained in:
yetone
2025-02-06 19:13:47 +08:00
committed by GitHub
parent 77e20fd088
commit 1ec12907a2
10 changed files with 1037 additions and 11 deletions

27
lua/avante/html2md.lua Normal file
View File

@@ -0,0 +1,27 @@
---@class AvanteHtml2Md
---@field fetch_md fun(url: string): string
local _html2md_lib = nil
local M = {}
---@return AvanteHtml2Md|nil
function M._init_html2md_lib()
if _html2md_lib ~= nil then return _html2md_lib end
local ok, core = pcall(require, "avante_html2md")
if not ok then return nil end
_html2md_lib = core
return _html2md_lib
end
function M.setup() vim.defer_fn(M._init_html2md_lib, 1000) end
function M.fetch_md(url)
local html2md_lib = M._init_html2md_lib()
if not html2md_lib then return "", "Failed to load avante_html2md" end
return html2md_lib.fetch_md(url)
end
return M