fix: only show user-configured platforms in picker
Problem: tbl_deep_extend merges user platforms on top of defaults, so all four default platforms survive even when the user only configures a subset. The picker then shows platforms the user never intended to use. Solution: before the deep merge, prune any default platform not present in the user's platforms table. This preserves per-platform default filling (the user doesn't have to re-specify every field) while ensuring only explicitly configured platforms appear.
This commit is contained in:
parent
6045042dfb
commit
06f72bbe2b
1 changed files with 9 additions and 1 deletions
|
|
@ -292,7 +292,15 @@ end
|
||||||
---@return cp.Config
|
---@return cp.Config
|
||||||
function M.setup(user_config)
|
function M.setup(user_config)
|
||||||
vim.validate({ user_config = { user_config, { 'table', 'nil' }, true } })
|
vim.validate({ user_config = { user_config, { 'table', 'nil' }, true } })
|
||||||
local cfg = vim.tbl_deep_extend('force', vim.deepcopy(M.defaults), user_config or {})
|
local defaults = vim.deepcopy(M.defaults)
|
||||||
|
if user_config and user_config.platforms then
|
||||||
|
for plat in pairs(defaults.platforms) do
|
||||||
|
if not user_config.platforms[plat] then
|
||||||
|
defaults.platforms[plat] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local cfg = vim.tbl_deep_extend('force', defaults, user_config or {})
|
||||||
|
|
||||||
if not next(cfg.languages) then
|
if not next(cfg.languages) then
|
||||||
error('[cp.nvim] At least one language must be configured')
|
error('[cp.nvim] At least one language must be configured')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue