refactor(config): remove legacy gcal top-level config key
Problem: the gcal migration shim silently accepted vim.g.pending = { gcal
= {...} } and copied it to sync.gcal, adding complexity and a deprecated
API surface.
Solution: remove the migration block in config.get(), drop the cfg.gcal
fallback in gcal_config(), delete the two migration tests, and clean up
the vimdoc references. Callers must now use sync.gcal directly.
This commit is contained in:
parent
461364bb5e
commit
ca4f9a384c
4 changed files with 9 additions and 48 deletions
|
|
@ -631,12 +631,6 @@ Fields: ~
|
|||
name and the value is the backend-specific config
|
||||
table. Currently only `gcal` is built-in.
|
||||
|
||||
{gcal} (table, default: nil)
|
||||
Legacy shorthand for `sync.gcal`. If `gcal` is set
|
||||
but `sync.gcal` is not, the value is migrated
|
||||
automatically. New configs should use `sync.gcal`
|
||||
instead. See |pending.GcalConfig|.
|
||||
|
||||
{icons} (table) *pending.Icons*
|
||||
Icon characters displayed in the buffer. Fields:
|
||||
{pending} Uncompleted task icon. Default: '○'
|
||||
|
|
@ -881,9 +875,6 @@ Configuration: >lua
|
|||
}
|
||||
<
|
||||
|
||||
The legacy `gcal` top-level key is still accepted and migrated automatically.
|
||||
New configurations should use `sync.gcal`.
|
||||
|
||||
*pending.GcalConfig*
|
||||
Fields: ~
|
||||
{calendar} (string, default: 'Pendings')
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@
|
|||
---@field debug? boolean
|
||||
---@field keymaps pending.Keymaps
|
||||
---@field sync? pending.SyncConfig
|
||||
---@field gcal? pending.GcalConfig
|
||||
---@field icons pending.Icons
|
||||
|
||||
---@class pending.config
|
||||
|
|
@ -101,10 +100,6 @@ function M.get()
|
|||
end
|
||||
local user = vim.g.pending or {}
|
||||
_resolved = vim.tbl_deep_extend('force', defaults, user)
|
||||
if _resolved.gcal and not (_resolved.sync and _resolved.sync.gcal) then
|
||||
_resolved.sync = _resolved.sync or {}
|
||||
_resolved.sync.gcal = _resolved.gcal
|
||||
end
|
||||
return _resolved
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ local SCOPE = 'https://www.googleapis.com/auth/calendar'
|
|||
---@return table<string, any>
|
||||
local function gcal_config()
|
||||
local cfg = config.get()
|
||||
return (cfg.sync and cfg.sync.gcal) or cfg.gcal or {}
|
||||
return (cfg.sync and cfg.sync.gcal) or {}
|
||||
end
|
||||
|
||||
---@return string
|
||||
|
|
|
|||
|
|
@ -112,39 +112,14 @@ describe('sync', function()
|
|||
end)
|
||||
end)
|
||||
|
||||
describe('config migration', function()
|
||||
it('migrates legacy gcal to sync.gcal', function()
|
||||
config.reset()
|
||||
vim.g.pending = {
|
||||
data_path = tmpdir .. '/tasks.json',
|
||||
gcal = { calendar = 'MyCalendar' },
|
||||
}
|
||||
local cfg = config.get()
|
||||
assert.is_not_nil(cfg.sync)
|
||||
assert.is_not_nil(cfg.sync.gcal)
|
||||
assert.are.equal('MyCalendar', cfg.sync.gcal.calendar)
|
||||
end)
|
||||
|
||||
it('does not overwrite explicit sync.gcal with legacy gcal', function()
|
||||
config.reset()
|
||||
vim.g.pending = {
|
||||
data_path = tmpdir .. '/tasks.json',
|
||||
gcal = { calendar = 'Legacy' },
|
||||
sync = { gcal = { calendar = 'Explicit' } },
|
||||
}
|
||||
local cfg = config.get()
|
||||
assert.are.equal('Explicit', cfg.sync.gcal.calendar)
|
||||
end)
|
||||
|
||||
it('works with sync.gcal and no legacy gcal', function()
|
||||
config.reset()
|
||||
vim.g.pending = {
|
||||
data_path = tmpdir .. '/tasks.json',
|
||||
sync = { gcal = { calendar = 'NewStyle' } },
|
||||
}
|
||||
local cfg = config.get()
|
||||
assert.are.equal('NewStyle', cfg.sync.gcal.calendar)
|
||||
end)
|
||||
it('works with sync.gcal config', function()
|
||||
config.reset()
|
||||
vim.g.pending = {
|
||||
data_path = tmpdir .. '/tasks.json',
|
||||
sync = { gcal = { calendar = 'NewStyle' } },
|
||||
}
|
||||
local cfg = config.get()
|
||||
assert.are.equal('NewStyle', cfg.sync.gcal.calendar)
|
||||
end)
|
||||
|
||||
describe('gcal module', function()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue