-
-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathmason-registry-check.lua
More file actions
52 lines (44 loc) · 1.26 KB
/
mason-registry-check.lua
File metadata and controls
52 lines (44 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
local mason_v2 = require('mason.version').MAJOR_VERSION == 2
local mason_sources
if mason_v2 then
-- compiler will complain when Mason 1.x is used
---@diagnostic disable-next-line: undefined-field
mason_sources = require('mason-registry').sources
else
mason_sources = require('mason-registry.sources')
end
local M = {}
if mason_v2 then
M.JAVA_REG_ID = 'nvim-java/mason-registry'
else
M.JAVA_REG_ID = 'github:nvim-java/mason-registry'
end
function M.is_valid()
local iterator
if mason_v2 then
-- the compiler will complain when Mason 1.x is in use
---@diagnostic disable-next-line: undefined-field
iterator = mason_sources.iterate
else
-- the compiler will complain when Mason 2.x is in use
---@diagnostic disable-next-line: undefined-field
iterator = mason_sources.iter
end
for reg in iterator(mason_sources) do
if reg.id == M.JAVA_REG_ID then
return {
success = true,
continue = true,
}
end
end
return {
success = false,
continue = false,
message = 'nvim-java mason registry is not added correctly!'
.. '\nThis occurs when mason.nvim configured incorrectly'
.. '\nPlease refer the link below to fix the issue'
.. '\nhttps://github.com/nvim-java/nvim-java/wiki/Q-&-A#no_entry-cannot-find-package-xxxxx',
}
end
return M