feat: add markdown detail buffer for task notes

Problem: tasks only have a one-line description. There is no way to
attach extended notes, checklists, or context to a task.

Solution: add `ge` keymap to open a `pending://task/<id>` markdown
buffer that replaces the task list in the same split. The buffer shows
a read-only metadata header (status, priority, category, due,
recurrence) rendered via extmarks, a `---` separator, and editable
notes below. `:w` saves notes to a new top-level `notes` field on the
task stored in the single `tasks.json`. `q` returns to the task list.
This commit is contained in:
Barrett Ruth 2026-03-13 08:18:49 -04:00
parent 0b0b64fc3d
commit d7d79b5b87
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
7 changed files with 298 additions and 0 deletions

View file

@ -401,6 +401,9 @@ function M._setup_buf_mappings(bufnr)
open_line_above = function()
buffer.open_line(true)
end,
edit_notes = function()
M.open_detail()
end,
}
for name, fn in pairs(actions) do
@ -888,6 +891,46 @@ function M.toggle_status(target_status)
end
end
---@return nil
function M.open_detail()
local bufnr = buffer.bufnr()
if not bufnr then
return
end
if not require_saved() then
return
end
local row = vim.api.nvim_win_get_cursor(0)[1]
local meta = buffer.meta()
if not meta[row] or meta[row].type ~= 'task' then
return
end
local id = meta[row].id
if not id then
return
end
local detail_bufnr = buffer.open_detail(id)
if not detail_bufnr then
return
end
local group = vim.api.nvim_create_augroup('PendingDetail', { clear = true })
vim.api.nvim_create_autocmd('BufWriteCmd', {
group = group,
buffer = detail_bufnr,
callback = function()
buffer.save_detail()
end,
})
local km = require('pending.config').get().keymaps
vim.keymap.set('n', km.close or 'q', function()
vim.api.nvim_del_augroup_by_name('PendingDetail')
buffer.close_detail()
end, { buffer = detail_bufnr })
end
---@param direction 'up'|'down'
---@return nil
function M.move_task(direction)