Skip to content

Commit

Permalink
feat: allow nested workspace summaries (#1144)
Browse files Browse the repository at this point in the history
implemented by aswa2ds
  • Loading branch information
vhyrro committed Nov 18, 2023
1 parent 16af444 commit a923055
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lua/neorg/modules/core/summary/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,47 @@ module.load = function()
metadata.title = vim.fs.basename(norgname)
end
end

if metadata.description == vim.NIL then
metadata.description = nil
end

if not include_categories or vim.tbl_contains(include_categories, category:lower()) then
table.insert(categories[lib.title(category)], {
title = tostring(metadata.title),
norgname = norgname,
description = metadata.description,
})
end

local leaf_categories = categories
local categories_path = vim.split(category, ".", { plain = true })
for i, path in ipairs(categories_path) do
local titled_path = lib.title(path)
if i == #categories_path then
table.insert(leaf_categories[titled_path], {
title = tostring(metadata.title),
norgname = norgname,
description = metadata.description,
})
break
end
local sub_categories = vim.defaulttable()
if leaf_categories[titled_path] then
for _, item in ipairs(leaf_categories[titled_path]) do
if item.sub_categories then
leaf_categories = item.sub_categories
goto continue
end
end
end
table.insert(leaf_categories[titled_path], {
title = titled_path,
sub_categories = sub_categories,
})
leaf_categories = sub_categories
::continue::
end
end
end)
local result = {}
Expand Down

0 comments on commit a923055

Please sign in to comment.