refactor(icons): unify category/header icon and use checkbox overlays

Problem: `header` and `category` were separate icons for the same
concept. The icon overlay replaced `[ ]` with a bare character,
hiding the markdown checkbox syntax. Header format `## ` produced
a double-space with single-char icons.

Solution: merge `header` into `category` (one icon for both header
lines and EOL labels). Overlay renders `[icon]` preserving bracket
syntax. Change header line format from `## ` to `# ` so the
2-char overlay (`# `) maps cleanly.
This commit is contained in:
Barrett Ruth 2026-03-04 18:38:10 -05:00
parent 26b14b6ba8
commit 530009d830
9 changed files with 61 additions and 81 deletions

View file

@ -115,7 +115,7 @@ local function setup_syntax(bufnr)
vim.cmd([[
syntax clear
syntax match taskId /^\/\d\+\// conceal
syntax match taskHeader /^## .*$/ contains=taskId
syntax match taskHeader /^# .*$/ contains=taskId
syntax match taskCheckbox /\[!\]/ contained containedin=taskLine
syntax match taskLine /^\/\d\+\/- \[.\] .*$/ contains=taskId,taskCheckbox
]])
@ -205,9 +205,8 @@ local function apply_extmarks(bufnr, line_meta)
else
icon, icon_hl = icons.pending, 'Normal'
end
local icon_padded = icon .. ' '
vim.api.nvim_buf_set_extmark(bufnr, task_ns, row, bracket_col, {
virt_text = { { icon_padded, icon_hl } },
virt_text = { { '[' .. icon .. ']', icon_hl } },
virt_text_pos = 'overlay',
priority = 100,
})
@ -218,7 +217,7 @@ local function apply_extmarks(bufnr, line_meta)
hl_group = 'PendingHeader',
})
vim.api.nvim_buf_set_extmark(bufnr, task_ns, row, 0, {
virt_text = { { icons.header .. ' ', 'PendingHeader' } },
virt_text = { { icons.category .. ' ', 'PendingHeader' } },
virt_text_pos = 'overlay',
priority = 100,
})

View file

@ -2,7 +2,6 @@
---@field pending string
---@field done string
---@field priority string
---@field header string
---@field due string
---@field recur string
---@field category string
@ -82,10 +81,9 @@ local defaults = {
},
sync = {},
icons = {
pending = '-',
pending = ' ',
done = 'x',
priority = '!',
header = '>',
due = '.',
recur = '~',
category = '#',

View file

@ -59,8 +59,8 @@ function M.parse_buffer(lines)
lnum = i,
})
end
elseif line:match('^## (.+)$') then
current_category = line:match('^## (.+)$')
elseif line:match('^# (.+)$') then
current_category = line:match('^# (.+)$')
table.insert(result, { type = 'header', category = current_category, lnum = i })
end
end

View file

@ -133,7 +133,7 @@ function M.category_view(tasks)
table.insert(lines, '')
table.insert(meta, { type = 'blank' })
end
table.insert(lines, '## ' .. cat)
table.insert(lines, '# ' .. cat)
table.insert(meta, { type = 'header', category = cat })
local all = {}