feat: time-aware due dates, persistent undo, @return audit (#33)

* fix(plugin): allow command chaining with bar separator

Problem: :Pending|only failed because the command definition lacked the
bar attribute, causing | to be consumed as an argument.

Solution: Add bar = true to nvim_create_user_command so | is treated as
a command separator, matching fugitive's :Git behavior.

* refactor(buffer): remove opinionated window options

Problem: The plugin hardcoded number, relativenumber, wrap, spell,
signcolumn, foldcolumn, and cursorline in set_win_options, overriding
user preferences with no way to opt out.

Solution: Remove all cosmetic window options. Users who want them can
set them in after/ftplugin/pending.lua. Only conceallevel,
concealcursor, and winfixheight remain as functionally required.

* feat: time-aware due dates, persistent undo, @return audit

Problem: Due dates had no time component, the undo stack was lost on
restart and stored in a separate file, and many public functions lacked
required @return annotations.

Solution: Add YYYY-MM-DDThh:mm support across parse, views, recur,
complete, and init with time-aware overdue checks. Merge the undo stack
into the task store JSON so a single file holds all state. Add @return
nil annotations to all 27 void public functions across every module.

* feat(parse): flexible time parsing for @ suffix

Problem: the @HH:MM time suffix required zero-padded 24-hour format,
forcing users to write due:tomorrow@14:00 instead of due:tomorrow@2pm.

Solution: add normalize_time() that accepts bare hours (9, 14),
H:MM (9:30), am/pm (2pm, 9:30am, 12am), and existing HH:MM format,
normalizing all to canonical HH:MM on save.

* feat(complete): add info descriptions to omnifunc items

Problem: completion menu items had no description, making it hard to
distinguish between similar entries like date shorthands and recurrence
patterns.

Solution: return { word, info } tables from date_completions() and
recur_completions(), surfacing human-readable descriptions in the
completion popup.

* ci: format
This commit is contained in:
Barrett Ruth 2026-02-25 20:37:50 -05:00 committed by GitHub
parent 72dbf037c7
commit c57cc0845b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 580 additions and 158 deletions

View file

@ -19,6 +19,7 @@ local config = require('pending.config')
---@field version integer
---@field next_id integer
---@field tasks pending.Task[]
---@field undo pending.Task[][]
---@class pending.store
local M = {}
@ -34,6 +35,7 @@ local function empty_data()
version = SUPPORTED_VERSION,
next_id = 1,
tasks = {},
undo = {},
}
end
@ -165,13 +167,24 @@ function M.load()
version = decoded.version or SUPPORTED_VERSION,
next_id = decoded.next_id or 1,
tasks = {},
undo = {},
}
for _, t in ipairs(decoded.tasks or {}) do
table.insert(_data.tasks, table_to_task(t))
end
for _, snapshot in ipairs(decoded.undo or {}) do
if type(snapshot) == 'table' then
local tasks = {}
for _, raw in ipairs(snapshot) do
table.insert(tasks, table_to_task(raw))
end
table.insert(_data.undo, tasks)
end
end
return _data
end
---@return nil
function M.save()
if not _data then
return
@ -182,10 +195,18 @@ function M.save()
version = _data.version,
next_id = _data.next_id,
tasks = {},
undo = {},
}
for _, task in ipairs(_data.tasks) do
table.insert(out.tasks, task_to_table(task))
end
for _, snapshot in ipairs(_data.undo) do
local serialized = {}
for _, task in ipairs(snapshot) do
table.insert(serialized, task_to_table(task))
end
table.insert(out.undo, serialized)
end
local encoded = vim.json.encode(out)
local tmp = path .. '.tmp'
local f = io.open(tmp, 'w')
@ -300,6 +321,7 @@ function M.find_index(id)
end
---@param tasks pending.Task[]
---@return nil
function M.replace_tasks(tasks)
M.data().tasks = tasks
end
@ -325,11 +347,24 @@ function M.snapshot()
return result
end
---@return pending.Task[][]
function M.undo_stack()
return M.data().undo
end
---@param stack pending.Task[][]
---@return nil
function M.set_undo_stack(stack)
M.data().undo = stack
end
---@param id integer
---@return nil
function M.set_next_id(id)
M.data().next_id = id
end
---@return nil
function M.unload()
_data = nil
end