Skip to content

Commit

Permalink
feat(todo-introspector): finalize display code
Browse files Browse the repository at this point in the history
  • Loading branch information
vhyrro committed Mar 28, 2024
1 parent 76e6443 commit 949ae96
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lua/neorg/modules/core/todo-introspector/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,27 @@ function module.public.perform_introspection(buffer, node)
return
end

local curated_total = counts.done + counts.undone + counts.pending + counts.urgent

-- TODO: Make configurable, make colours customizable, don't display [x/total]
-- as the total also includes things like uncertain tasks.
--
-- NOTE(vhyrro): The selection of done/undone/pending/urgent is a curated arbitrary list for now (and a common-case scenario).
-- Yet again, should be customizable :)
--
-- TODO(vhyrro): Extract the whole string building logic to a function so that it can be used outside of Neorg for other things.
vim.api.nvim_buf_set_extmark(buffer, module.private.namespace, line, col, {
virt_text = { { string.format("[%d/%d]", counts.done, total), "Normal" } },
virt_text = {
{
string.format(
"[%d/%d] (%d%%)",
counts.done,
curated_total,
(curated_total ~= 0 and math.floor((counts.done / curated_total) * 100) or 0)
),
"Normal",
},
},
invalidate = true,
})
end
Expand Down

0 comments on commit 949ae96

Please sign in to comment.