feat: add cancelled task status with configurable state chars

Problem: the task lifecycle only has `pending`, `wip`, `blocked`, and
`done`. There is no way to mark a task as abandoned. Additionally,
state characters (`>`, `=`) are hardcoded rather than reading from
`config.icons`, so customizing them has no effect on rendering or
parsing.

Solution: add a `cancelled` status with default state char `c`, `g/`
keymap, `PendingCancelled` highlight, filter predicate, and archive
support. Unify state chars by making `state_char()`, `parse_buffer()`,
and `infer_status()` read from `config.icons`. Change defaults to
mnemonic chars: `w` (wip), `b` (blocked), `c` (cancelled).
This commit is contained in:
Barrett Ruth 2026-03-12 20:15:35 -04:00
parent b2456580b5
commit cee291a20b
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
9 changed files with 109 additions and 45 deletions

View file

@ -146,6 +146,14 @@ local function apply_inline_row(bufnr, row, m, icons)
hl_group = 'PendingDone',
invalidate = true,
})
elseif m.status == 'cancelled' then
local line = vim.api.nvim_buf_get_lines(bufnr, row, row + 1, false)[1] or ''
local col_start = line:find('/%d+/') and select(2, line:find('/%d+/')) or 0
vim.api.nvim_buf_set_extmark(bufnr, ns_inline, row, col_start, {
end_col = #line,
hl_group = 'PendingCancelled',
invalidate = true,
})
elseif m.status == 'blocked' then
local line = vim.api.nvim_buf_get_lines(bufnr, row, row + 1, false)[1] or ''
local col_start = line:find('/%d+/') and select(2, line:find('/%d+/')) or 0
@ -160,10 +168,12 @@ local function apply_inline_row(bufnr, row, m, icons)
local icon, icon_hl
if m.status == 'done' then
icon, icon_hl = icons.done, 'PendingDone'
elseif m.status == 'cancelled' then
icon, icon_hl = icons.cancelled, 'PendingCancelled'
elseif m.status == 'wip' then
icon, icon_hl = icons.wip or '>', 'PendingWip'
icon, icon_hl = icons.wip, 'PendingWip'
elseif m.status == 'blocked' then
icon, icon_hl = icons.blocked or '=', 'PendingBlocked'
icon, icon_hl = icons.blocked, 'PendingBlocked'
elseif m.priority and m.priority >= 3 then
icon, icon_hl = icons.priority, 'PendingPriority3'
elseif m.priority and m.priority == 2 then
@ -216,11 +226,14 @@ local function infer_status(line)
if not ch then
return nil
end
if ch == 'x' then
local icons = config.get().icons
if ch == icons.done then
return 'done'
elseif ch == '>' then
elseif ch == icons.cancelled then
return 'cancelled'
elseif ch == icons.wip then
return 'wip'
elseif ch == '=' then
elseif ch == icons.blocked then
return 'blocked'
end
return 'pending'
@ -573,6 +586,7 @@ local function setup_highlights()
vim.api.nvim_set_hl(0, 'PendingPriority3', { link = 'DiagnosticError', default = true })
vim.api.nvim_set_hl(0, 'PendingWip', { link = 'DiagnosticInfo', default = true })
vim.api.nvim_set_hl(0, 'PendingBlocked', { link = 'DiagnosticError', default = true })
vim.api.nvim_set_hl(0, 'PendingCancelled', { link = 'NonText', default = true })
vim.api.nvim_set_hl(0, 'PendingRecur', { link = 'DiagnosticInfo', default = true })
vim.api.nvim_set_hl(0, 'PendingFilter', { link = 'DiagnosticWarn', default = true })
vim.api.nvim_set_hl(0, 'PendingForge', { link = 'DiagnosticInfo', default = true })