feat(views): make queue view sort order configurable (#154)
Problem: the queue/priority view sort in `sort_tasks_priority()` uses a hardcoded tiebreak chain (status, priority, due, order, id). Users who care more about due dates than priority have no way to reorder it. Solution: add `view.queue.sort` config field (string[]) that defines an ordered tiebreak chain. `build_queue_comparator()` maps each key to a comparison function and returns a single comparator. Unknown keys emit a `log.warn`. The default matches the previous hardcoded behavior.
This commit is contained in:
parent
283f93eda1
commit
969dbd299f
4 changed files with 169 additions and 12 deletions
|
|
@ -542,11 +542,12 @@ Category view (default): ~ *pending-view-category*
|
|||
`zc` and `zo`.
|
||||
|
||||
Queue view: ~ *pending-view-queue*
|
||||
A flat list of all tasks sorted by status (wip → pending → blocked →
|
||||
done), then by priority, then by due date (tasks without a due date sort
|
||||
last), then by internal order. Category names are shown as right-aligned virtual
|
||||
text alongside the due date virtual text so tasks remain identifiable
|
||||
across categories. The buffer is named `pending://queue`.
|
||||
A flat list of all tasks sorted by a configurable tiebreak chain
|
||||
(default: status → priority → due → order → id). See
|
||||
`view.queue.sort` in |pending-config| for customization. Category
|
||||
names are shown as right-aligned virtual text alongside the due date
|
||||
virtual text so tasks remain identifiable across categories. The
|
||||
buffer is named `pending://queue`.
|
||||
|
||||
==============================================================================
|
||||
FILTERS *pending-filters*
|
||||
|
|
@ -749,7 +750,9 @@ loads: >lua
|
|||
order = {},
|
||||
folding = true,
|
||||
},
|
||||
queue = {},
|
||||
queue = {
|
||||
sort = { 'status', 'priority', 'due', 'order', 'id' },
|
||||
},
|
||||
},
|
||||
keymaps = {
|
||||
close = 'q',
|
||||
|
|
@ -891,6 +894,24 @@ Fields: ~
|
|||
|
||||
{queue} (table) *pending.QueueViewConfig*
|
||||
Queue (priority) view settings.
|
||||
{sort} (string[], default:
|
||||
`{ 'status', 'priority', 'due',
|
||||
'order', 'id' }`)
|
||||
Ordered tiebreak chain for the
|
||||
queue view sort. Each element is a
|
||||
sort key; the comparator walks the
|
||||
list and returns on the first
|
||||
non-equal comparison. Valid keys:
|
||||
`status` wip < pending <
|
||||
blocked < done
|
||||
`priority` higher number first
|
||||
`due` sooner first, no-due
|
||||
last
|
||||
`order` ascending
|
||||
`id` ascending
|
||||
`age` alias for `id`
|
||||
Unknown keys are ignored with a
|
||||
warning.
|
||||
|
||||
Examples: >lua
|
||||
vim.g.pending = {
|
||||
|
|
@ -901,6 +922,10 @@ Fields: ~
|
|||
order = { 'Work', 'Personal' },
|
||||
folding = { foldtext = '%c: %n items' },
|
||||
},
|
||||
queue = {
|
||||
sort = { 'status', 'due', 'priority',
|
||||
'order', 'id' },
|
||||
},
|
||||
},
|
||||
}
|
||||
<
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue