feat(buffer): add PendingRecur highlight and recurrence virtual text
Problem: recurring tasks have no visual indicator in the buffer, and the extmark logic uses a rigid if/elseif chain that does not compose well with additional virtual text fields. Solution: add PendingRecur highlight group linking to DiagnosticInfo. Refactor apply_extmarks() to build virtual text parts dynamically, appending category, recurrence indicator, and due date as separate composable segments. Set omnifunc on the pending buffer.
This commit is contained in:
parent
1e2d72914c
commit
a1a8d1db3b
1 changed files with 16 additions and 16 deletions
|
|
@ -55,6 +55,7 @@ local function set_buf_options(bufnr)
|
|||
vim.bo[bufnr].swapfile = false
|
||||
vim.bo[bufnr].filetype = 'pending'
|
||||
vim.bo[bufnr].modifiable = true
|
||||
vim.bo[bufnr].omnifunc = 'v:lua.require("pending.complete").omnifunc'
|
||||
end
|
||||
|
||||
---@param winid integer
|
||||
|
|
@ -122,24 +123,22 @@ local function apply_extmarks(bufnr, line_meta)
|
|||
local row = i - 1
|
||||
if m.type == 'task' then
|
||||
local due_hl = m.overdue and 'PendingOverdue' or 'PendingDue'
|
||||
if m.show_category then
|
||||
local virt_text
|
||||
if m.category and m.due then
|
||||
virt_text = { { m.category .. ' ', 'PendingHeader' }, { m.due, due_hl } }
|
||||
elseif m.category then
|
||||
virt_text = { { m.category, 'PendingHeader' } }
|
||||
elseif m.due then
|
||||
virt_text = { { m.due, due_hl } }
|
||||
local virt_parts = {}
|
||||
if m.show_category and m.category then
|
||||
table.insert(virt_parts, { m.category, 'PendingHeader' })
|
||||
end
|
||||
if m.recur then
|
||||
table.insert(virt_parts, { '\u{21bb} ' .. m.recur, 'PendingRecur' })
|
||||
end
|
||||
if m.due then
|
||||
table.insert(virt_parts, { m.due, due_hl })
|
||||
end
|
||||
if #virt_parts > 0 then
|
||||
for p = 1, #virt_parts - 1 do
|
||||
virt_parts[p][1] = virt_parts[p][1] .. ' '
|
||||
end
|
||||
if virt_text then
|
||||
vim.api.nvim_buf_set_extmark(bufnr, task_ns, row, 0, {
|
||||
virt_text = virt_text,
|
||||
virt_text_pos = 'eol',
|
||||
})
|
||||
end
|
||||
elseif m.due then
|
||||
vim.api.nvim_buf_set_extmark(bufnr, task_ns, row, 0, {
|
||||
virt_text = { { m.due, due_hl } },
|
||||
virt_text = virt_parts,
|
||||
virt_text_pos = 'eol',
|
||||
})
|
||||
end
|
||||
|
|
@ -167,6 +166,7 @@ local function setup_highlights()
|
|||
vim.api.nvim_set_hl(0, 'PendingOverdue', { link = 'DiagnosticError', default = true })
|
||||
vim.api.nvim_set_hl(0, 'PendingDone', { link = 'Comment', default = true })
|
||||
vim.api.nvim_set_hl(0, 'PendingPriority', { link = 'DiagnosticWarn', default = true })
|
||||
vim.api.nvim_set_hl(0, 'PendingRecur', { link = 'DiagnosticInfo', default = true })
|
||||
end
|
||||
|
||||
local function snapshot_folds(bufnr)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue