Skip to content

Commit 0d23dc4

Browse files
committed
feat!: disable neoconf integration by default
1 parent 891063a commit 0d23dc4

File tree

5 files changed

+105
-20
lines changed

5 files changed

+105
-20
lines changed

doc/crates.txt

+22
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ For more information about individual config options see |crates-config|.
242242
enabled = false,
243243
name = "crates.nvim",
244244
},
245+
neoconf = {
246+
enabled = false,
247+
namespace = "crates",
248+
},
245249
lsp = {
246250
enabled = false,
247251
name = "crates.nvim",
@@ -1497,6 +1501,24 @@ null_ls.name *crates-config-null_ls-name*
14971501
The |null-ls.nvim| name.
14981502

14991503

1504+
neoconf *crates-config-neoconf*
1505+
Section type: `NeoconfConfig`
1506+
1507+
Configuration options for neoconf.nvim integration.
1508+
1509+
1510+
neoconf.enabled *crates-config-neoconf-enabled*
1511+
Type: `boolean`, Default: `false`
1512+
1513+
Whether to enable project-local configuration with |neoconf.nvim|.
1514+
1515+
1516+
neoconf.namespace *crates-config-neoconf-namespace*
1517+
Type: `string`, Default: `"crates"`
1518+
1519+
The root namespace for the project-local neoconf schema.
1520+
1521+
15001522
lsp *crates-config-lsp*
15011523
Section type: `LspConfig`
15021524

docgen/templates/documentation.md.in

+14-4
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,21 @@ How you might integrate `show_popup` into your `init.lua`.
290290
```
291291
</details>
292292

293-
## Neoconf Integration
293+
## neoconf.nvim integration
294294

295-
You can also set project-local settings if you have [Neoconf](https://github.com/folke/neoconf.nvim)
296-
installed; all settings are exactly the same, but are under the "crates"
297-
namespace.
295+
You can also set project-local settings if you have [neoconf.nvim](https://github.com/folke/neoconf.nvim)
296+
installed; all settings are exactly the same, but are by default under the "crates" namespace.
297+
298+
Neoconf integration has to be enabled, and optionally the namespace can be changed.
299+
```lua
300+
require("crates").setup {
301+
...
302+
neoconf = {
303+
enabled = false,
304+
namespace = "crates",
305+
},
306+
}
307+
```
298308

299309
Example:
300310

docgen/wiki/Documentation-unstable.md

+18-4
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,10 @@ require("crates").setup {
399399
enabled = false,
400400
name = "crates.nvim",
401401
},
402+
neoconf = {
403+
enabled = false,
404+
namespace = "crates",
405+
},
402406
lsp = {
403407
enabled = false,
404408
name = "crates.nvim",
@@ -669,11 +673,21 @@ endfunction
669673
```
670674
</details>
671675

672-
## Neoconf Integration
676+
## neoconf.nvim integration
677+
678+
You can also set project-local settings if you have [neoconf.nvim](https://github.com/folke/neoconf.nvim)
679+
installed; all settings are exactly the same, but are by default under the "crates" namespace.
673680

674-
You can also set project-local settings if you have [Neoconf](https://github.com/folke/neoconf.nvim)
675-
installed; all settings are exactly the same, but are under the "crates"
676-
namespace.
681+
Neoconf integration has to be enabled, and optionally the namespace can be changed.
682+
```lua
683+
require("crates").setup {
684+
...
685+
neoconf = {
686+
enabled = false,
687+
namespace = "crates",
688+
},
689+
}
690+
```
677691

678692
Example:
679693

lua/crates/config/init.lua

+41-12
Original file line numberDiff line numberDiff line change
@@ -1566,6 +1566,34 @@ entry(schema_null_ls, {
15661566
]],
15671567
})
15681568

1569+
local schema_neoconf = section_entry(M.schema, {
1570+
name = "neoconf",
1571+
type = {
1572+
config_type = "section",
1573+
emmylua_annotation = "NeoconfConfig",
1574+
},
1575+
description = [[
1576+
Configuration options for neoconf.nvim integration.
1577+
]],
1578+
fields = {},
1579+
})
1580+
entry(schema_neoconf, {
1581+
name = "enabled",
1582+
type = BOOLEAN_TYPE,
1583+
default = false,
1584+
description = [[
1585+
Whether to enable project-local configuration with |neoconf.nvim|.
1586+
]],
1587+
})
1588+
entry(schema_neoconf, {
1589+
name = "namespace",
1590+
type = STRING_TYPE,
1591+
default = "crates",
1592+
description = [[
1593+
The root namespace for the project-local neoconf schema.
1594+
]],
1595+
})
1596+
15691597

15701598
local schema_lsp = section_entry(M.schema, {
15711599
name = "lsp",
@@ -1804,22 +1832,19 @@ end
18041832
---@param config Config
18051833
---@return Config
18061834
local function setup_neoconf(config)
1807-
---@type boolean, table
18081835
local ok, neoconf = pcall(require, "neoconf")
18091836
if not ok then
1837+
warn("neoconf.nvim was not found")
18101838
return config
18111839
end
18121840

18131841
-- enables neodev to autocomplete settings in .neoconf.json
1814-
pcall(function()
1815-
---@type table
1816-
local neoconf_plugins = require("neoconf.plugins")
1817-
neoconf_plugins.register {
1818-
on_schema = function(schema)
1819-
schema:import("crates", config)
1820-
end
1821-
}
1822-
end)
1842+
local neoconf_plugins = require("neoconf.plugins")
1843+
neoconf_plugins.register({
1844+
on_schema = function(schema)
1845+
schema:import(config.neoconf.namespace, config)
1846+
end
1847+
})
18231848

18241849
return setmetatable({}, {
18251850
__index = function(self, key)
@@ -1829,7 +1854,7 @@ local function setup_neoconf(config)
18291854
return loc[key]
18301855
end
18311856
---@type Config
1832-
loc = neoconf.get("crates", config, {
1857+
loc = neoconf.get(config.neoconf.namespace, config, {
18331858
buffer = buf,
18341859
lsp = true,
18351860
})
@@ -1883,7 +1908,11 @@ function M.build(user_config)
18831908
handle_deprecated({}, M.schema, user_config, user_config)
18841909
validate_schema({}, M.schema, user_config)
18851910
local config = build_config(M.schema, user_config)
1886-
return setup_neoconf(config)
1911+
if config.neoconf.enabled then
1912+
return setup_neoconf(config)
1913+
else
1914+
return config
1915+
end
18871916
end
18881917

18891918
return M

lua/crates/config/types.lua

+10
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
---@field popup PopupConfig
2626
---@field completion CompletionConfig
2727
---@field null_ls NullLsConfig
28+
---@field neoconf NeoconfConfig
2829
---@field lsp LspConfig
2930

3031
---@class TextConfig
@@ -208,6 +209,10 @@
208209
---@field enabled boolean
209210
---@field name string
210211

212+
---@class NeoconfConfig
213+
---@field enabled boolean
214+
---@field namespace string
215+
211216
---@class LspConfig
212217
---@field enabled boolean
213218
---@field name string
@@ -238,6 +243,7 @@
238243
---@field public popup? crates.UserPopupConfig
239244
---@field public completion? crates.UserCompletionConfig
240245
---@field public null_ls? crates.UserNullLsConfig
246+
---@field public neoconf? crates.UserNeoconfConfig
241247
---@field public lsp? crates.UserLspConfig
242248

243249
---@class crates.UserTextConfig
@@ -400,6 +406,10 @@
400406
---@field public enabled? boolean
401407
---@field public name? string
402408

409+
---@class crates.UserNeoconfConfig
410+
---@field public enabled? boolean
411+
---@field public namespace? string
412+
403413
---@class crates.UserLspConfig
404414
---@field public enabled? boolean
405415
---@field public name? string

0 commit comments

Comments
 (0)