@@ -5,18 +5,28 @@ local health = {}
5
5
local h = vim .health
6
6
7
7
--- @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
10
12
--- @field url string URL (markdown )
11
13
--- @field info string Additional information
12
14
13
15
--- @type rustaceanvim.LuaDependency[]
14
16
local lua_dependencies = {
15
17
{
18
+ name = ' nvim-dap' ,
16
19
module = ' dap' ,
17
- optional = function ()
20
+ is_optional = function ()
18
21
return true
19
22
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 ,
20
30
url = ' [mfussenegger/nvim-dap](https://github.com/mfussenegger/nvim-dap)' ,
21
31
info = ' Needed for debugging features' ,
22
32
},
@@ -27,7 +37,7 @@ local lua_dependencies = {
27
37
--- @field required_version_spec ? string Version range spec. See ` vim.version.range()`
28
38
--- @field get_binaries fun (): string[] Function that returns the binaries to check for
29
39
--- @field is_installed ? fun ( bin : string ): boolean Default : ` vim.fn.executable (bin ) == 1`
30
- --- @field optional fun (): boolean Function that returns whether the dependency is optional
40
+ --- @field is_optional fun (): boolean Function that returns whether the dependency is optional
31
41
--- @field url string URL (markdown )
32
42
--- @field info string Additional information
33
43
--- @field extra_checks_if_installed ? fun ( bin : string ) Optional extra checks to perform if the dependency is installed
@@ -39,10 +49,14 @@ local function check_lua_dependency(dep)
39
49
h .ok (dep .url .. ' installed.' )
40
50
return
41
51
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
44
58
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 ))
46
60
end
47
61
end
48
62
@@ -94,7 +108,7 @@ local function check_external_dependency(dep)
94
108
end
95
109
return
96
110
end
97
- if not dep .optional () then
111
+ if not dep .is_optional () then
98
112
h .error (([[
99
113
%s: not found: %s
100
114
rustaceanvim requires %s.
@@ -209,7 +223,7 @@ function health.check()
209
223
end )
210
224
return success
211
225
end ,
212
- optional = function ()
226
+ is_optional = function ()
213
227
return false
214
228
end ,
215
229
url = ' [rust-analyzer](https://rust-analyzer.github.io/)' ,
@@ -232,7 +246,7 @@ function health.check()
232
246
end )
233
247
return success
234
248
end ,
235
- optional = function ()
249
+ is_optional = function ()
236
250
return true
237
251
end ,
238
252
url = ' [ra-multiplex](https://github.com/pr2502/ra-multiplex)' ,
@@ -243,7 +257,7 @@ function health.check()
243
257
get_binaries = function ()
244
258
return { ' cargo' }
245
259
end ,
246
- optional = function ()
260
+ is_optional = function ()
247
261
return true
248
262
end ,
249
263
url = ' [Cargo](https://doc.rust-lang.org/cargo/)' ,
@@ -258,7 +272,7 @@ function health.check()
258
272
get_binaries = function ()
259
273
return { ' rustc' }
260
274
end ,
261
- optional = function ()
275
+ is_optional = function ()
262
276
return true
263
277
end ,
264
278
url = ' [rustc](https://doc.rust-lang.org/rustc/what-is-rustc.html)' ,
@@ -275,7 +289,7 @@ function health.check()
275
289
get_binaries = function ()
276
290
return { config .tools .cargo_override }
277
291
end ,
278
- optional = function ()
292
+ is_optional = function ()
279
293
return true
280
294
end ,
281
295
url = ' ' ,
0 commit comments