From 4612960b9a67a7c190b76b25a5d9c41921da9f04 Mon Sep 17 00:00:00 2001 From: Barrett Ruth <62671086+barrettruth@users.noreply.github.com> Date: Thu, 26 Feb 2026 22:53:51 -0500 Subject: [PATCH] refactor(config): remove legacy gcal top-level config key (#51) * 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. * ci: fix * fix(spec): remove duplicate buffer require in complete_spec --- doc/pending.txt | 9 --------- lua/pending/config.lua | 5 ----- lua/pending/sync/gcal.lua | 2 +- spec/complete_spec.lua | 1 - spec/sync_spec.lua | 41 ++++++++------------------------------- 5 files changed, 9 insertions(+), 49 deletions(-) diff --git a/doc/pending.txt b/doc/pending.txt index 13ebb77..3577f49 100644 --- a/doc/pending.txt +++ b/doc/pending.txt @@ -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') diff --git a/lua/pending/config.lua b/lua/pending/config.lua index f1749e2..d8df30e 100644 --- a/lua/pending/config.lua +++ b/lua/pending/config.lua @@ -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 diff --git a/lua/pending/sync/gcal.lua b/lua/pending/sync/gcal.lua index a2d9992..2ec96a8 100644 --- a/lua/pending/sync/gcal.lua +++ b/lua/pending/sync/gcal.lua @@ -23,7 +23,7 @@ local SCOPE = 'https://www.googleapis.com/auth/calendar' ---@return table 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 diff --git a/spec/complete_spec.lua b/spec/complete_spec.lua index 4e650b1..98547e8 100644 --- a/spec/complete_spec.lua +++ b/spec/complete_spec.lua @@ -3,7 +3,6 @@ require('spec.helpers') local buffer = require('pending.buffer') local config = require('pending.config') local store = require('pending.store') -local buffer = require('pending.buffer') describe('complete', function() local tmpdir diff --git a/spec/sync_spec.lua b/spec/sync_spec.lua index 28bd0e3..9e24e7d 100644 --- a/spec/sync_spec.lua +++ b/spec/sync_spec.lua @@ -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()