Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(intro-spector): recursively search for TODO items #1490

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions lua/neorg/modules/core/todo-introspector/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ function module.public.attach_introspector(buffer)

module.required["core.integrations.treesitter"].execute_query(
[[
(_
state: (detached_modifier_extension)) @item
]],
(_
state: (detached_modifier_extension)) @item
]],
function(query, id, node)
if query.captures[id] == "item" then
module.public.perform_introspection(buffer, node)
Expand Down Expand Up @@ -132,25 +132,28 @@ function module.public.calculate_items(node)

local total = 0

-- Go through all the children of the current todo item node and count the amount of "done" children
for child in node:iter_children() do
if child:named_child(1) and child:named_child(1):type() == "detached_modifier_extension" then
for status in child:named_child(1):iter_children() do
if status:type():match("^todo_item_") then
local type = status:type():match("^todo_item_(.+)$")
local function descend(next_node)
for child in next_node:iter_children() do
if child:named_child(1) and child:named_child(1):type() == "detached_modifier_extension" then
for status in child:named_child(1):iter_children() do
if status:type():match("^todo_item_") then
local type = status:type():match("^todo_item_(.+)$")

counts[type] = counts[type] + 1
counts[type] = counts[type] + 1

if type == "cancelled" then
break
if type ~= "cancelled" then
total = total + 1
end
end

total = total + 1
end
else
descend(child)
end
end
end

descend(node)

return counts, total
end

Expand Down
Loading