@@ -5,18 +5,28 @@ local health = {}
55local h = vim .health
66
77--- @class rustaceanvim.LuaDependency
8- --- @field module string The name of a module
9- --- @field optional fun (): boolean Function that returns whether the dependency is optional
8+ --- @field name string The name of the dependency
9+ --- @field module string The name of a module to check for
10+ --- @field is_optional fun (): boolean Function that returns whether the dependency is optional
11+ --- @field is_configured fun (): boolean Function that returns whether the dependency is configured
1012--- @field url string URL (markdown )
1113--- @field info string Additional information
1214
1315--- @type rustaceanvim.LuaDependency[]
1416local lua_dependencies = {
1517 {
18+ name = ' nvim-dap' ,
1619 module = ' dap' ,
17- optional = function ()
20+ is_optional = function ()
1821 return true
1922 end ,
23+ is_configured = function ()
24+ local rustaceanvim_opts = type (vim .g .rustaceanvim ) == ' function' and vim .g .rustaceanvim ()
25+ or vim .g .rustaceanvim
26+ or {}
27+ local dap_opts = vim .tbl_get (rustaceanvim_opts , ' dap' )
28+ return type (dap_opts ) == ' table'
29+ end ,
2030 url = ' [mfussenegger/nvim-dap](https://github.com/mfussenegger/nvim-dap)' ,
2131 info = ' Needed for debugging features' ,
2232 },
@@ -39,10 +49,14 @@ local function check_lua_dependency(dep)
3949 h .ok (dep .url .. ' installed.' )
4050 return
4151 end
42- if dep .optional () then
43- h .warn ((' %s not installed. %s %s' ):format (dep .module , dep .info , dep .url ))
52+ if dep .is_optional () then
53+ if dep .is_configured () then
54+ h .warn ((' optional dependency %s is configured, but not installed. %s %s' ):format (dep .name , dep .info , dep .url ))
55+ else
56+ h .ok ((' optional dependency %s not installed. %s %s' ):format (dep .name , dep .info , dep .url ))
57+ end
4458 else
45- error ((' Lua dependency %s not found: %s' ):format (dep .module , dep .url ))
59+ error ((' Lua dependency %s not found: %s' ):format (dep .name , dep .url ))
4660 end
4761end
4862
0 commit comments