From 9c5d57becec1a64e8527d08c5f729af4ab248031 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Wed, 25 Feb 2026 13:06:20 -0500 Subject: [PATCH] ci: fix --- lua/pending/complete.lua | 30 ++++++++++++++--- lua/pending/health.lua | 4 +-- lua/pending/init.lua | 3 +- lua/pending/parse.lua | 70 +++++++++++++++++++--------------------- lua/pending/recur.lua | 7 +++- spec/parse_spec.lua | 6 ++-- spec/recur_spec.lua | 13 +++++--- 7 files changed, 80 insertions(+), 53 deletions(-) diff --git a/lua/pending/complete.lua b/lua/pending/complete.lua index f4b98fb..f83b6a4 100644 --- a/lua/pending/complete.lua +++ b/lua/pending/complete.lua @@ -32,11 +32,31 @@ end ---@return string[] local function date_completions() return { - 'today', 'tomorrow', 'yesterday', - '+1d', '+2d', '+3d', '+1w', '+2w', '+1m', - 'mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun', - 'eod', 'eow', 'eom', 'eoq', 'eoy', - 'sow', 'som', 'soq', 'soy', + 'today', + 'tomorrow', + 'yesterday', + '+1d', + '+2d', + '+3d', + '+1w', + '+2w', + '+1m', + 'mon', + 'tue', + 'wed', + 'thu', + 'fri', + 'sat', + 'sun', + 'eod', + 'eow', + 'eom', + 'eoq', + 'eoy', + 'sow', + 'som', + 'soq', + 'soy', 'later', } end diff --git a/lua/pending/health.lua b/lua/pending/health.lua index c37c4f8..78311d2 100644 --- a/lua/pending/health.lua +++ b/lua/pending/health.lua @@ -32,9 +32,7 @@ function M.check() for _, task in ipairs(tasks) do if task.recur and not recur.validate(task.recur) then invalid_count = invalid_count + 1 - vim.health.warn( - 'Task ' .. task.id .. ' has invalid recurrence spec: ' .. task.recur - ) + vim.health.warn('Task ' .. task.id .. ' has invalid recurrence spec: ' .. task.recur) end end if invalid_count == 0 then diff --git a/lua/pending/init.lua b/lua/pending/init.lua index 8f01289..966acf1 100644 --- a/lua/pending/init.lua +++ b/lua/pending/init.lua @@ -130,7 +130,8 @@ function M.toggle_complete() if task.recur and task.due then local recur = require('pending.recur') local mode = task.recur_mode or 'scheduled' - local base = mode == 'completion' and os.date('%Y-%m-%d') --[[@as string]] or task.due + local base = mode == 'completion' and os.date('%Y-%m-%d') --[[@as string]] + or task.due local next_date = recur.next_due(base, task.recur, mode) store.add({ description = task.description, diff --git a/lua/pending/parse.lua b/lua/pending/parse.lua index 5a6de47..853fa2c 100644 --- a/lua/pending/parse.lua +++ b/lua/pending/parse.lua @@ -45,9 +45,18 @@ local weekday_map = { } local month_map = { - jan = 1, feb = 2, mar = 3, apr = 4, - may = 5, jun = 6, jul = 7, aug = 8, - sep = 9, oct = 10, nov = 11, dec = 12, + jan = 1, + feb = 2, + mar = 3, + apr = 4, + may = 5, + jun = 6, + jul = 7, + aug = 8, + sep = 9, + oct = 10, + nov = 11, + dec = 12, } ---@param today osdate @@ -97,49 +106,31 @@ function M.resolve_date(text) end if lower == 'som' then - return os.date( - '%Y-%m-%d', - os.time({ year = today.year, month = today.month, day = 1 }) - ) --[[@as string]] + return os.date('%Y-%m-%d', os.time({ year = today.year, month = today.month, day = 1 })) --[[@as string]] end if lower == 'eom' then - return os.date( - '%Y-%m-%d', - os.time({ year = today.year, month = today.month + 1, day = 0 }) - ) --[[@as string]] + return os.date('%Y-%m-%d', os.time({ year = today.year, month = today.month + 1, day = 0 })) --[[@as string]] end if lower == 'soq' then local q = math.ceil(today.month / 3) local first_month = (q - 1) * 3 + 1 - return os.date( - '%Y-%m-%d', - os.time({ year = today.year, month = first_month, day = 1 }) - ) --[[@as string]] + return os.date('%Y-%m-%d', os.time({ year = today.year, month = first_month, day = 1 })) --[[@as string]] end if lower == 'eoq' then local q = math.ceil(today.month / 3) local last_month = q * 3 - return os.date( - '%Y-%m-%d', - os.time({ year = today.year, month = last_month + 1, day = 0 }) - ) --[[@as string]] + return os.date('%Y-%m-%d', os.time({ year = today.year, month = last_month + 1, day = 0 })) --[[@as string]] end if lower == 'soy' then - return os.date( - '%Y-%m-%d', - os.time({ year = today.year, month = 1, day = 1 }) - ) --[[@as string]] + return os.date('%Y-%m-%d', os.time({ year = today.year, month = 1, day = 1 })) --[[@as string]] end if lower == 'eoy' then - return os.date( - '%Y-%m-%d', - os.time({ year = today.year, month = 12, day = 31 }) - ) --[[@as string]] + return os.date('%Y-%m-%d', os.time({ year = today.year, month = 12, day = 31 })) --[[@as string]] end if lower == 'later' or lower == 'someday' then @@ -153,7 +144,9 @@ function M.resolve_date(text) os.time({ year = today.year, month = today.month, - day = today.day + (tonumber(n) --[[@as integer]]), + day = today.day + ( + tonumber(n) --[[@as integer]] + ), }) ) --[[@as string]] end @@ -165,7 +158,9 @@ function M.resolve_date(text) os.time({ year = today.year, month = today.month, - day = today.day + (tonumber(n) --[[@as integer]]) * 7, + day = today.day + ( + tonumber(n) --[[@as integer]] + ) * 7, }) ) --[[@as string]] end @@ -176,7 +171,9 @@ function M.resolve_date(text) '%Y-%m-%d', os.time({ year = today.year, - month = today.month + (tonumber(n) --[[@as integer]]), + month = today.month + ( + tonumber(n) --[[@as integer]] + ), day = today.day, }) ) --[[@as string]] @@ -189,7 +186,9 @@ function M.resolve_date(text) os.time({ year = today.year, month = today.month, - day = today.day - (tonumber(n) --[[@as integer]]), + day = today.day - ( + tonumber(n) --[[@as integer]] + ), }) ) --[[@as string]] end @@ -201,7 +200,9 @@ function M.resolve_date(text) os.time({ year = today.year, month = today.month, - day = today.day - (tonumber(n) --[[@as integer]]) * 7, + day = today.day - ( + tonumber(n) --[[@as integer]] + ) * 7, }) ) --[[@as string]] end @@ -243,10 +244,7 @@ function M.resolve_date(text) if today.month >= target_month then y = y + 1 end - return os.date( - '%Y-%m-%d', - os.time({ year = y, month = target_month, day = 1 }) - ) --[[@as string]] + return os.date('%Y-%m-%d', os.time({ year = y, month = target_month, day = 1 })) --[[@as string]] end local target_wday = weekday_map[lower] diff --git a/lua/pending/recur.lua b/lua/pending/recur.lua index f44d3f3..46a5dd2 100644 --- a/lua/pending/recur.lua +++ b/lua/pending/recur.lua @@ -10,7 +10,12 @@ local M = {} ---@type table local named = { daily = { freq = 'daily', interval = 1, from_completion = false }, - weekdays = { freq = 'weekly', interval = 1, byday = { 'MO', 'TU', 'WE', 'TH', 'FR' }, from_completion = false }, + weekdays = { + freq = 'weekly', + interval = 1, + byday = { 'MO', 'TU', 'WE', 'TH', 'FR' }, + from_completion = false, + }, weekly = { freq = 'weekly', interval = 1, from_completion = false }, biweekly = { freq = 'weekly', interval = 2, from_completion = false }, monthly = { freq = 'monthly', interval = 1, from_completion = false }, diff --git a/spec/parse_spec.lua b/spec/parse_spec.lua index 31eb50e..edeffcd 100644 --- a/spec/parse_spec.lua +++ b/spec/parse_spec.lua @@ -193,7 +193,8 @@ describe('parse', function() it('returns last day of current month for eom', function() local today = os.date('*t') --[[@as osdate]] - local expected = os.date('%Y-%m-%d', os.time({ year = today.year, month = today.month + 1, day = 0 })) + local expected = + os.date('%Y-%m-%d', os.time({ year = today.year, month = today.month + 1, day = 0 })) local result = parse.resolve_date('eom') assert.are.equal(expected, result) end) @@ -211,7 +212,8 @@ describe('parse', function() local today = os.date('*t') --[[@as osdate]] local q = math.ceil(today.month / 3) local last_month = q * 3 - local expected = os.date('%Y-%m-%d', os.time({ year = today.year, month = last_month + 1, day = 0 })) + local expected = + os.date('%Y-%m-%d', os.time({ year = today.year, month = last_month + 1, day = 0 })) local result = parse.resolve_date('eoq') assert.are.equal(expected, result) end) diff --git a/spec/recur_spec.lua b/spec/recur_spec.lua index eb3ccf0..53b7478 100644 --- a/spec/recur_spec.lua +++ b/spec/recur_spec.lua @@ -151,11 +151,14 @@ describe('recur', function() it('completion mode advances from today', function() local today = os.date('*t') --[[@as osdate]] - local expected = os.date('%Y-%m-%d', os.time({ - year = today.year, - month = today.month, - day = today.day + 7, - })) + local expected = os.date( + '%Y-%m-%d', + os.time({ + year = today.year, + month = today.month, + day = today.day + 7, + }) + ) local result = recur.next_due('2020-01-01', 'weekly', 'completion') assert.are.equal(expected, result) end)