feat(filter): oil-like editable filter line (#43)

* feat(filter): oil-like editable filter line with predicate dispatch

Problem: no way to narrow the pending buffer to a subset of tasks
without manual scrolling; filtered-out tasks would be silently deleted
on :w because diff.apply() marks unseen IDs as deleted.

Solution: add a FILTER: line rendered at the top of the buffer when a
filter is active. The line is editable — :w re-parses it and updates
the hidden set. diff.apply() gains a hidden_ids param that prevents
filtered-out tasks from being marked deleted. Predicates: cat:X,
overdue, today, priority (space-separated AND). :Pending filter sets
it programmatically; :Pending filter clear removes it.

* ci: format
This commit is contained in:
Barrett Ruth 2026-02-26 18:29:56 -05:00 committed by GitHub
parent 3da23c924a
commit dcb6a4781d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 526 additions and 8 deletions

View file

@ -268,6 +268,30 @@ COMMANDS *pending-commands*
`gcal` Google Calendar one-way push. See |pending-gcal|.
*:Pending-filter*
:Pending filter {predicates}
Apply a filter to the task buffer. {predicates} is a space-separated list
of one or more predicate tokens. Only tasks matching all predicates (AND
semantics) are shown. Hidden tasks are not deleted — they are preserved in
the store and reappear when the filter is cleared. >vim
:Pending filter cat:Work
:Pending filter overdue
:Pending filter cat:Work overdue
:Pending filter priority
:Pending filter clear
<
When a filter is active the buffer's first line shows: >
FILTER: cat:Work overdue
<
The user can edit this line inline and `:w` to change the active filter.
Deleting the `FILTER:` line entirely and saving clears the filter.
`:Pending filter clear` also clears the filter programmatically.
Tab completion after `:Pending filter ` lists available predicates and
category values. Already-used predicates are excluded from completions.
See |pending-filters| for the full list of supported predicates.
*:Pending-undo*
:Pending undo
Undo the last `:w` save, restoring the task store to its previous state.
@ -421,6 +445,47 @@ Queue view: ~ *pending-view-queue*
text alongside the due date virtual text so tasks remain identifiable
across categories. The buffer is named `pending://queue`.
==============================================================================
FILTERS *pending-filters*
Filters narrow the task buffer to a subset of tasks without deleting any data.
Hidden tasks are preserved in the store and reappear when the filter is
cleared. Filter state is session-local — it does not persist across Neovim
restarts.
Set a filter with |:Pending-filter| or by editing the `FILTER:` line: >vim
:Pending filter cat:Work overdue
<
Multiple predicates are separated by spaces and combined with AND logic — a
task must match every predicate to be shown.
Available predicates: ~
`cat:X` Show only tasks whose category is exactly `X`. Tasks with no
category (assigned to `default_category`) are hidden unless
`default_category` matches `X`.
`overdue` Show only pending tasks with a due date strictly before today.
`today` Show only pending tasks with a due date equal to today.
`priority` Show only tasks with priority > 0 (the `!` marker).
`clear` Special value for |:Pending-filter| — clears the active filter
and shows all tasks.
FILTER: line: ~ *pending-filter-line*
When a filter is active, the first line of the task buffer is: >
FILTER: cat:Work overdue
<
This line is editable. Write the buffer with `:w` to apply the updated
predicates. Deleting the `FILTER:` line and saving clears the filter. The
line is highlighted with |PendingFilter| and does not appear in the stored
task data.
==============================================================================
CONFIGURATION *pending-config*
@ -760,6 +825,11 @@ PendingRecur Applied to the recurrence indicator virtual text shown
alongside due dates for recurring tasks.
Default: links to `DiagnosticInfo`.
*PendingFilter*
PendingFilter Applied to the `FILTER:` header line shown at the top of
the buffer when a filter is active.
Default: links to `DiagnosticWarn`.
To override a group in your colorscheme or config: >lua
vim.api.nvim_set_hl(0, 'PendingDue', { fg = '#aaaaaa', italic = true })
<