@@ -51,33 +51,24 @@ M.init_lsp_commands = function()
51
51
end
52
52
53
53
M .get_ls_from_mason = function ()
54
- local result = M .get_from_mason_registry (" vscode-spring-boot-tools" , " vscode-spring-boot-tools/ language-server.jar" )
54
+ local result = M .get_from_mason_registry (" vscode-spring-boot-tools" , " language-server.jar" )
55
55
if # result > 0 then
56
56
return result [1 ]
57
57
end
58
58
return nil
59
59
end
60
60
61
- M .get_from_mason_registry = function (package_name , key_prefix )
61
+ M .get_from_mason_registry = function (package_name , filter )
62
62
local success , mason_registry = pcall (require , " mason-registry" )
63
63
local result = {}
64
64
if success then
65
- mason_registry .refresh ()
66
- local mason_package
67
- if mason_registry .has_package (package_name ) then
68
- mason_package = mason_registry .get_package (package_name )
69
- else
70
- return result
71
- end
72
- if mason_package :is_installed () then
73
- local install_path = mason_package :get_install_path ()
74
- mason_package :get_receipt ():if_present (function (recipe )
75
- for key , value in pairs (recipe .links .share ) do
76
- if key :sub (1 , # key_prefix ) == key_prefix then
77
- table.insert (result , install_path .. " /" .. value )
78
- end
65
+ local has_package , mason_package = pcall (mason_registry .get_package , package_name )
66
+ if has_package then
67
+ if mason_package :is_installed () then
68
+ for key , value in pairs (vim .fn .globpath (" $MASON/share/" .. package_name , filter or " *" , true , true )) do
69
+ table.insert (result , value )
79
70
end
80
- end )
71
+ end
81
72
end
82
73
end
83
74
return result
@@ -95,8 +86,7 @@ M.setup = function(opts)
95
86
if not opts .ls_path then
96
87
opts .ls_path = M .get_ls_from_mason () -- get ls from mason-registry
97
88
if opts .ls_path then
98
- spring_boot .jdt_expanded_extensions_jars =
99
- M .get_from_mason_registry (" vscode-spring-boot-tools" , " vscode-spring-boot-tools/jdtls/" )
89
+ spring_boot .jdt_expanded_extensions_jars = M .get_from_mason_registry (" vscode-spring-boot-tools" , " jdtls/*.jar" )
100
90
end
101
91
end
102
92
if not opts .ls_path then
@@ -137,7 +127,7 @@ M.java_extensions = function()
137
127
if spring_boot .jdt_expanded_extensions_jars and # spring_boot .jdt_expanded_extensions_jars > 0 then
138
128
return spring_boot .jdt_expanded_extensions_jars
139
129
end
140
- local bundles = M .get_from_mason_registry (" vscode-spring-boot-tools" , " vscode-spring-boot-tools/ jdtls/" )
130
+ local bundles = M .get_from_mason_registry (" vscode-spring-boot-tools" , " jdtls/*.jar " )
141
131
if # bundles > 0 then
142
132
for _ , v in pairs (bundles ) do
143
133
table.insert (spring_boot .jdt_expanded_extensions_jars , v )
0 commit comments