diff --git a/lua/pending/init.lua b/lua/pending/init.lua index 14b9c24..8f01289 100644 --- a/lua/pending/init.lua +++ b/lua/pending/init.lua @@ -127,6 +127,20 @@ function M.toggle_complete() if task.status == 'done' then store.update(id, { status = 'pending', ['end'] = vim.NIL }) else + 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 next_date = recur.next_due(base, task.recur, mode) + store.add({ + description = task.description, + category = task.category, + priority = task.priority, + due = next_date, + recur = task.recur, + recur_mode = task.recur_mode, + }) + end store.update(id, { status = 'done' }) end store.save() @@ -219,6 +233,8 @@ function M.add(text) description = description, category = metadata.cat, due = metadata.due, + recur = metadata.rec, + recur_mode = metadata.rec_mode, }) store.save() local bufnr = buffer.bufnr() @@ -320,6 +336,7 @@ end function M.show_help() local cfg = require('pending.config').get() local dk = cfg.date_syntax or 'due' + local rk = cfg.recur_syntax or 'rec' local lines = { 'pending.nvim keybindings', '', @@ -344,14 +361,21 @@ function M.show_help() 'Inline metadata (on new lines before :w):', ' ' .. dk .. ':YYYY-MM-DD Set due date', ' cat:Name Set category', + ' ' .. rk .. ':pattern Set recurrence', '', 'Due date input:', - ' today, tomorrow, +Nd, mon-sun', + ' today, tomorrow, yesterday, +Nd, +Nw, +Nm', + ' -Nd, -Nw, mon-sun, jan-dec, 1st-31st', + ' eod, eow, eom, eoq, eoy, sow, som, soq, soy', + ' later, someday', ' Empty input clears due date', '', - 'Highlights:', - ' PendingOverdue overdue tasks (red)', - ' PendingPriority [!] urgent tasks', + 'Recurrence patterns:', + ' daily, weekdays, weekly, biweekly', + ' monthly, quarterly, yearly, Nd, Nw, Nm, Ny', + ' Prefix ! for completion-based (e.g. !weekly)', + '', + 'Completion: after due:, cat:, rec:', '', 'Press q or to close', }