Skip to content

Commit

Permalink
feat(health): don't warn if nvim-dap is not configured (#667)
Browse files Browse the repository at this point in the history
  • Loading branch information
b1nhack authored and mrcjkb committed Jan 27, 2025
1 parent e15c262 commit 0621e0c
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions lua/rustaceanvim/health.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,28 @@ local health = {}
local h = vim.health

---@class rustaceanvim.LuaDependency
---@field module string The name of a module
---@field optional fun():boolean Function that returns whether the dependency is optional
---@field name string The name of the dependency
---@field module string The name of a module to check for
---@field is_optional fun():boolean Function that returns whether the dependency is optional
---@field is_configured fun():boolean Function that returns whether the dependency is configured
---@field url string URL (markdown)
---@field info string Additional information

---@type rustaceanvim.LuaDependency[]
local lua_dependencies = {
{
name = 'nvim-dap',
module = 'dap',
optional = function()
is_optional = function()
return true
end,
is_configured = function()
local rustaceanvim_opts = type(vim.g.rustaceanvim) == 'function' and vim.g.rustaceanvim()
or vim.g.rustaceanvim
or {}
local dap_opts = vim.tbl_get(rustaceanvim_opts, 'dap')
return type(dap_opts) == 'table'
end,
url = '[mfussenegger/nvim-dap](https://github.com/mfussenegger/nvim-dap)',
info = 'Needed for debugging features',
},
Expand All @@ -39,10 +49,14 @@ local function check_lua_dependency(dep)
h.ok(dep.url .. ' installed.')
return
end
if dep.optional() then
h.warn(('%s not installed. %s %s'):format(dep.module, dep.info, dep.url))
if dep.is_optional() then
if dep.is_configured() then
h.warn(('optional dependency %s is configured, but not installed. %s %s'):format(dep.name, dep.info, dep.url))
else
h.ok(('optional dependency %s not installed. %s %s'):format(dep.name, dep.info, dep.url))
end
else
error(('Lua dependency %s not found: %s'):format(dep.module, dep.url))
error(('Lua dependency %s not found: %s'):format(dep.name, dep.url))
end
end

Expand Down

0 comments on commit 0621e0c

Please sign in to comment.