Skip to content

Commit

Permalink
feat(concealer): add more icon generators
Browse files Browse the repository at this point in the history
  • Loading branch information
vhyrro committed Jun 2, 2023
1 parent 55feccf commit 49b9788
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions lua/neorg/modules/core/concealer/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,10 @@ module.public = {
end -- TODO: warning
local index = get_ordered_index(bufid, node)
local result = config.generator and config.generator(index) or tostring(index)
local generator = table_get_default_last(config.generators, len)
local format = table_get_default_last(config.formatters, index)
local text = (" "):rep(len - 1) .. string.format(format, result)
local text = (" "):rep(len - 1) .. string.format(format, generator(index))
local highlight = config.highlights and table_get_default_last(config.highlights, len)
Expand Down Expand Up @@ -606,6 +606,33 @@ module.public = {
end
end,
},
icon_generators = {
numeric = function(index)
return tostring(index)
end,
convert_to_base_n = function(vocabulary, number)
local result = {}
while number > 0 do
local remainder = ((number - 1) % #vocabulary) + 1
table.insert(result, 1, string.sub(vocabulary, remainder, remainder))
number = math.floor((number - 1) / #vocabulary)
end
return table.concat(result)
end,
alphanumeric_uppercase = function(index)
return module.public.icon_generators.convert_to_base_n("ABCDEFGHIJKLMNOPQRSTUVWXYZ", index)
end,
alphanumeric_lowercase = function(index)
return module.public.icon_generators.convert_to_base_n("abcdefghijklmnopqrstuvwxyz", index)
end,
},
}
module.config.public = {
Expand Down Expand Up @@ -703,9 +730,15 @@ module.config.public = {
"ordered_list6_prefix",
},
generators = {
module.public.icon_generators.numeric,
module.public.icon_generators.alphanumeric_uppercase,
module.public.icon_generators.alphanumeric_lowercase,
},
formatters = { "%s." },
render = has_anticonceal and module.public.icon_renderers.multilevel_ordered_inline_on_right or module.public.icon_renderers.multilevel_ordered_on_right,
render = has_anticonceal and module.public.icon_renderers.multilevel_ordered_inline_on_right
or module.public.icon_renderers.multilevel_ordered_on_right,
},
quote = {
icons = { "" },
Expand Down

0 comments on commit 49b9788

Please sign in to comment.