Skip to content

Commit

Permalink
fix checkhealth to run outside lazy (#1401)
Browse files Browse the repository at this point in the history
  • Loading branch information
omarcresp authored Feb 26, 2025
1 parent 6f98cb0 commit 44e673d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
32 changes: 22 additions & 10 deletions lua/avante/health.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,31 @@ local Config = require("avante.config")
function M.check()
H.start("avante.nvim")

-- Required dependencies
-- Required dependencies with their module names
local required_plugins = {
["nvim-treesitter"] = "nvim-treesitter/nvim-treesitter",
["dressing.nvim"] = "stevearc/dressing.nvim",
["plenary.nvim"] = "nvim-lua/plenary.nvim",
["nui.nvim"] = "MunifTanjim/nui.nvim",
["nvim-treesitter"] = {
path = "nvim-treesitter/nvim-treesitter",
module = "nvim-treesitter",
},
["dressing.nvim"] = {
path = "stevearc/dressing.nvim",
module = "dressing",
},
["plenary.nvim"] = {
path = "nvim-lua/plenary.nvim",
module = "plenary",
},
["nui.nvim"] = {
path = "MunifTanjim/nui.nvim",
module = "nui",
},
}

for plugin_name, plugin_path in pairs(required_plugins) do
if Utils.has(plugin_name) then
H.ok(string.format("Found required plugin: %s", plugin_path))
for name, plugin in pairs(required_plugins) do
if Utils.has(name) or Utils.has(plugin.module) then
H.ok(string.format("Found required plugin: %s", plugin.path))
else
H.error(string.format("Missing required plugin: %s", plugin_path))
H.error(string.format("Missing required plugin: %s", plugin.path))
end
end

Expand All @@ -31,7 +43,7 @@ function M.check()

-- Check Copilot if configured
if Config.providers and Config.providers == "copilot" then
if Utils.has("copilot.lua") or Utils.has("copilot.vim") then
if Utils.has("copilot.lua") or Utils.has("copilot.vim") or Utils.has("copilot") then
H.ok("Found Copilot plugin")
else
H.error("Copilot provider is configured but neither copilot.lua nor copilot.vim is installed")
Expand Down
4 changes: 3 additions & 1 deletion lua/avante/utils/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ setmetatable(M, {
function M.has(plugin)
local ok, LazyConfig = pcall(require, "lazy.core.config")
if ok then return LazyConfig.plugins[plugin] ~= nil end
return package.loaded[plugin] ~= nil

local res, _ = pcall(require, plugin)
return res ~= nil
end

function M.is_win() return jit.os:find("Windows") ~= nil end
Expand Down

0 comments on commit 44e673d

Please sign in to comment.