fix: load path (#926)

This commit is contained in:
yetone 2024-12-06 01:35:33 +08:00 committed by GitHub
parent 6206998f24
commit 4464b7f4ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -23,6 +23,34 @@ M.did_setup = false
local H = {}
H.load_path = function()
local ok, LazyConfig = pcall(require, "lazy.core.config")
if ok then
local name = "avante.nvim"
local load_path = function() require("avante_lib").load() end
if LazyConfig.plugins[name] and LazyConfig.plugins[name]._.loaded then
vim.schedule(load_path)
else
api.nvim_create_autocmd("User", {
pattern = "LazyLoad",
callback = function(event)
if event.data == name then
load_path()
return true
end
end,
})
end
api.nvim_create_autocmd("User", {
pattern = "VeryLazy",
callback = load_path,
})
end
end
H.keymaps = function()
vim.keymap.set({ "n", "v" }, "<Plug>(AvanteAsk)", function() require("avante.api").ask() end, { noremap = true })
vim.keymap.set(
@ -153,32 +181,6 @@ H.signs = function() vim.fn.sign_define("AvanteInputPromptSign", { text = Config
H.augroup = api.nvim_create_augroup("avante_autocmds", { clear = true })
H.autocmds = function()
local ok, LazyConfig = pcall(require, "lazy.core.config")
if ok then
local name = "avante.nvim"
local load_path = function() require("avante_lib").load() end
if LazyConfig.plugins[name] and LazyConfig.plugins[name]._.loaded then
vim.schedule(load_path)
else
api.nvim_create_autocmd("User", {
pattern = "LazyLoad",
callback = function(event)
if event.data == name then
load_path()
return true
end
end,
})
end
api.nvim_create_autocmd("User", {
pattern = "VeryLazy",
callback = load_path,
})
end
api.nvim_create_autocmd("TabEnter", {
group = H.augroup,
pattern = "*",
@ -356,6 +358,8 @@ function M.setup(opts)
if M.did_setup then return end
H.load_path()
require("avante.repo_map").setup()
require("avante.path").setup()
require("avante.highlights").setup()