Skip to content

Commit db54fbf

Browse files
authored
fix: nvim-java mason reg is added if the mason config does not consid… (#355)
* fix: nvim-java mason reg is added if the mason config does not consider parent conf * chore: format the config example
1 parent 04e3a41 commit db54fbf

File tree

4 files changed

+36
-8
lines changed

4 files changed

+36
-8
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ want, following options are available
366366
-- load java test plugins
367367
java_test = {
368368
enable = true,
369-
version = '0.43.0',
369+
version = '0.40.1',
370370
},
371371

372372
-- load java debugger plugins
@@ -377,7 +377,7 @@ want, following options are available
377377

378378
spring_boot_tools = {
379379
enable = true,
380-
version = '1.59.0',
380+
version = '1.55.1',
381381
},
382382

383383
jdk = {
@@ -416,7 +416,16 @@ want, following options are available
416416
-- will stop setup
417417
invalid_mason_registry = false,
418418
},
419+
420+
mason = {
421+
-- These mason registries will be prepended to the existing mason
422+
-- configuration
423+
registries = {
424+
'github:nvim-java/mason-registry',
425+
},
426+
},
419427
}
428+
420429
```
421430

422431
</details>

lazy.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ return {
1515
},
1616
{
1717
'williamboman/mason.nvim',
18-
opts = {
19-
registries = {
20-
'github:nvim-java/mason-registry',
21-
'github:mason-org/mason-registry',
22-
},
23-
},
18+
-- opts = {
19+
-- registries = {
20+
-- 'github:nvim-java/mason-registry',
21+
-- 'github:mason-org/mason-registry',
22+
-- },
23+
-- },
2424
},
2525
},
2626
}

lua/java/config.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
---@field jdk { auto_install: boolean, version: string }
99
---@field notifications { dap: boolean }
1010
---@field verification { invalid_order: boolean, duplicate_setup_calls: boolean, invalid_mason_registry: boolean }
11+
---@field mason { registries: string[] }
1112
local config = {
1213
-- list of file that exists in root of the project
1314
root_markers = {
@@ -83,6 +84,14 @@ local config = {
8384
-- will stop setup
8485
invalid_mason_registry = false,
8586
},
87+
88+
mason = {
89+
-- These mason registries will be prepended to the existing mason
90+
-- configuration
91+
registries = {
92+
'github:nvim-java/mason-registry',
93+
},
94+
},
8695
}
8796

8897
return config

lua/java/startup/mason-dep.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
local log = require('java.utils.log')
22
local mason_ui = require('mason.ui')
33
local mason_util = require('java.utils.mason')
4+
local list_util = require('java-core.utils.list')
45
local notify = require('java-core.utils.notify')
56
local async = require('java-core.utils.async')
67
local lazy = require('java.ui.lazy')
@@ -13,6 +14,15 @@ local M = {}
1314
---Install mason package dependencies for nvim-java
1415
---@param config java.Config
1516
function M.install(config)
17+
local mason_default_config = require('mason.settings').current
18+
19+
local registries = list_util
20+
:new(config.mason.registries)
21+
:concat(mason_default_config.registries)
22+
23+
require('mason').setup({
24+
registries = registries,
25+
})
1626
local packages = M.get_pkg_list(config)
1727
local is_outdated = mason_util.is_outdated(packages)
1828

0 commit comments

Comments
 (0)