Skip to content

Commit 909776f

Browse files
committed
chore: format with stylua
1 parent 5bef42a commit 909776f

File tree

9 files changed

+132
-71
lines changed

9 files changed

+132
-71
lines changed

docgen/docgen.lua

+67-45
Original file line numberDiff line numberDiff line change
@@ -552,14 +552,20 @@ docgen.generators = {
552552
"",
553553
"### Further Reading",
554554
"",
555-
docgen.lookup_modules(mods, "To find out how to rebind the available keys consult the [`core.keybinds`](@core.keybinds) wiki entry."),
555+
docgen.lookup_modules(
556+
mods,
557+
"To find out how to rebind the available keys consult the [`core.keybinds`](@core.keybinds) wiki entry."
558+
),
556559
"",
557560
}
558561

559562
local main_preset = "neorg"
560563

561564
for preset_name, preset_data in vim.spairs(keybind_data) do
562-
table.insert(layout, string.format("## Preset `%s`%s", preset_name, preset_name == main_preset and " (default)" or ""))
565+
table.insert(
566+
layout,
567+
string.format("## Preset `%s`%s", preset_name, preset_name == main_preset and " (default)" or "")
568+
)
563569
table.insert(layout, "")
564570

565571
for neorg_mode_name, neorg_mode_data in vim.spairs(preset_data) do
@@ -583,9 +589,11 @@ docgen.generators = {
583589

584590
for key, data in vim.spairs(mode_data) do
585591
if not vim.tbl_isempty(data.comments) then
586-
local comments = vim.iter(data.comments):map(function(comment)
587-
return (comment:gsub("^%s*%-%-%s*", ""))
588-
end):totable()
592+
local comments = vim.iter(data.comments)
593+
:map(function(comment)
594+
return (comment:gsub("^%s*%-%-%s*", ""))
595+
end)
596+
:totable()
589597

590598
local mnemonic = docgen.extract_mnemonic(comments)
591599

@@ -599,7 +607,10 @@ docgen.generators = {
599607
table.insert(layout, string.format("- `%s` - %s", key, description))
600608
table.insert(layout, string.format(" - Default map: `%s`", data.rhs))
601609
if mnemonic then
602-
table.insert(layout, string.format(" - Mnemonic: %s", docgen.format_mnemonic(mnemonic)))
610+
table.insert(
611+
layout,
612+
string.format(" - Mnemonic: %s", docgen.format_mnemonic(mnemonic))
613+
)
603614
end
604615

605616
table.insert(layout, "")
@@ -610,7 +621,7 @@ docgen.generators = {
610621
end
611622

612623
return layout
613-
end
624+
end,
614625
}
615626

616627
--- Check the integrity of the description comments found in configuration blocks
@@ -788,55 +799,66 @@ end
788799
---@param buffer number The buffer ID to extract information from.
789800
---@return table<string, table>
790801
docgen.parse_keybind_data = function(buffer)
791-
local query = utils.ts_parse_query("lua", [[
802+
local query = utils.ts_parse_query(
803+
"lua",
804+
[[
792805
(field
793806
name: (identifier) @_ident
794807
(#eq? @_ident "presets")) @presets
795-
]])
796-
797-
local root = assert(vim.treesitter.get_parser(buffer, "lua"):parse()[1]:root(), "unable to parse keybinds!")
798-
799-
local _, presets = query:iter_captures(root, buffer)()
800-
assert(presets, "could not find presets")
801-
802-
local available_keys = neorg.modules.loaded_modules["core.keybinds"].private.presets
803-
804-
local output = vim.defaulttable()
805-
806-
for preset in presets:named_child(1):iter_children() do
807-
if preset:type() == "field" then
808-
local preset_name, preset_data = vim.treesitter.get_node_text(assert(preset:named_child(0)), buffer), preset:named_child(1)
809-
810-
for neorg_mode in assert(preset_data):iter_children() do
811-
if neorg_mode:type() == "field" then
812-
local neorg_mode_name, neorg_mode_data = vim.treesitter.get_node_text(assert(neorg_mode:named_child(0)), buffer), neorg_mode:named_child(1)
813-
814-
for neovim_mode in assert(neorg_mode_data):iter_children() do
815-
if neovim_mode:type() == "field" then
816-
local mode_name, mode_data = vim.treesitter.get_node_text(assert(neovim_mode:named_child(0)), buffer), neovim_mode:named_child(1)
817-
818-
local comments = {}
819-
local i, keybind_data
808+
]]
809+
)
820810

821-
for comment_or_data in assert(mode_data):iter_children() do
822-
if comment_or_data:type() == "comment" then
823-
table.insert(comments, vim.trim(vim.treesitter.get_node_text(comment_or_data, buffer)))
824-
elseif comment_or_data:type() == "field" then
825-
i, keybind_data = next(available_keys[preset_name][neorg_mode_name][mode_name], i)
826-
output[preset_name][neorg_mode_name][mode_name][keybind_data[1]] = {
827-
comments = comments,
828-
rhs = keybind_data[2],
829-
}
830-
comments = {}
831-
end
811+
local root = assert(vim.treesitter.get_parser(buffer, "lua"):parse()[1]:root(), "unable to parse keybinds!")
812+
813+
local _, presets = query:iter_captures(root, buffer)()
814+
assert(presets, "could not find presets")
815+
816+
local available_keys = neorg.modules.loaded_modules["core.keybinds"].private.presets
817+
818+
local output = vim.defaulttable()
819+
820+
for preset in presets:named_child(1):iter_children() do
821+
if preset:type() == "field" then
822+
local preset_name, preset_data =
823+
vim.treesitter.get_node_text(assert(preset:named_child(0)), buffer), preset:named_child(1)
824+
825+
for neorg_mode in assert(preset_data):iter_children() do
826+
if neorg_mode:type() == "field" then
827+
local neorg_mode_name, neorg_mode_data =
828+
vim.treesitter.get_node_text(assert(neorg_mode:named_child(0)), buffer),
829+
neorg_mode:named_child(1)
830+
831+
for neovim_mode in assert(neorg_mode_data):iter_children() do
832+
if neovim_mode:type() == "field" then
833+
local mode_name, mode_data =
834+
vim.treesitter.get_node_text(assert(neovim_mode:named_child(0)), buffer),
835+
neovim_mode:named_child(1)
836+
837+
local comments = {}
838+
local i, keybind_data
839+
840+
for comment_or_data in assert(mode_data):iter_children() do
841+
if comment_or_data:type() == "comment" then
842+
table.insert(
843+
comments,
844+
vim.trim(vim.treesitter.get_node_text(comment_or_data, buffer))
845+
)
846+
elseif comment_or_data:type() == "field" then
847+
i, keybind_data = next(available_keys[preset_name][neorg_mode_name][mode_name], i)
848+
output[preset_name][neorg_mode_name][mode_name][keybind_data[1]] = {
849+
comments = comments,
850+
rhs = keybind_data[2],
851+
}
852+
comments = {}
832853
end
833854
end
834855
end
835856
end
836857
end
837858
end
838859
end
839-
return output
860+
end
861+
return output
840862
end
841863

842864
docgen.format_mnemonic = function(str)

docgen/init.lua

+7-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,13 @@ end
9494

9595
-- Non-module pages have their own dedicated generators
9696
fileio.write_to_wiki("Home", docgen.generators.homepage(doc_modules))
97-
fileio.write_to_wiki("Default-Keybinds", docgen.generators.keybinds(doc_modules, docgen.open_file(vim.fn.fnamemodify("../lua/neorg/modules/core/keybinds/module.lua", ":p"))))
97+
fileio.write_to_wiki(
98+
"Default-Keybinds",
99+
docgen.generators.keybinds(
100+
doc_modules,
101+
docgen.open_file(vim.fn.fnamemodify("../lua/neorg/modules/core/keybinds/module.lua", ":p"))
102+
)
103+
)
98104
fileio.write_to_wiki("_Sidebar", docgen.generators.sidebar(doc_modules))
99105

100106
-- Loop through all modules and generate their respective wiki files

lua/neorg/modules/core/dirman/module.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ module.public = {
463463
end
464464
end)
465465
end
466-
end
466+
end,
467467
}
468468

469469
module.on_event = function(event)

lua/neorg/modules/core/esupports/hop/module.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ module.public = {
688688
local parsed_link = module.public.parse_link(link_node_at_cursor)
689689

690690
module.public.follow_link(link_node_at_cursor, split_mode, parsed_link)
691-
end
691+
end,
692692
}
693693

694694
module.private = {

lua/neorg/modules/core/keybinds/module.lua

+21-5
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,11 @@ module.private = {
235235
},
236236

237237
-- Promote an object non-recursively.
238-
{ ">.", "<Plug>(neorg.promo.promote)", opts = { desc = "[neorg] Promote Object (Non-Recursively)" } },
238+
{
239+
">.",
240+
"<Plug>(neorg.promo.promote)",
241+
opts = { desc = "[neorg] Promote Object (Non-Recursively)" },
242+
},
239243
-- Demote an object non-recursively.
240244
{ "<,", "<Plug>(neorg.promo.demote)", opts = { desc = "[neorg] Demote Object (Non-Recursively)" } },
241245

@@ -246,7 +250,11 @@ module.private = {
246250
opts = { desc = "[neorg] Promote Object (Recursively)" },
247251
},
248252
-- Demote an object recursively.
249-
{ "<<", "<Plug>(neorg.promo.demote.nested)", opts = { desc = "[neorg] Demote Object (Recursively)" } },
253+
{
254+
"<<",
255+
"<Plug>(neorg.promo.demote.nested)",
256+
opts = { desc = "[neorg] Demote Object (Recursively)" },
257+
},
250258

251259
-- Toggle a list from ordered <-> unordered
252260
-- ^List Toggle
@@ -273,14 +281,22 @@ module.private = {
273281

274282
i = {
275283
-- Promote an object recursively.
276-
{ "<C-t>", "<Plug>(neorg.promo.promote)", opts = { desc = "[neorg] Promote Object (Recursively)" } },
284+
{
285+
"<C-t>",
286+
"<Plug>(neorg.promo.promote)",
287+
opts = { desc = "[neorg] Promote Object (Recursively)" },
288+
},
277289
-- Demote an object recursively.
278290
{ "<C-d>", "<Plug>(neorg.promo.demote)", opts = { desc = "[neorg] Demote Object (Recursively)" } },
279291
-- Create an iteration of e.g. a list item.
280292
{ "<M-CR>", "<Plug>(neorg.itero.next-iteration)", opts = { desc = "[neorg] Continue Object" } },
281293
-- Insert a link to a date at the current cursor position.
282294
-- ^Date
283-
{ "<M-d>", "<Plug>(neorg.tempus.insert-date-insert-mode)", opts = { desc = "[neorg] Insert Date" } },
295+
{
296+
"<M-d>",
297+
"<Plug>(neorg.tempus.insert-date-insert-mode)",
298+
opts = { desc = "[neorg] Insert Date" },
299+
},
284300
},
285301

286302
v = {
@@ -289,7 +305,7 @@ module.private = {
289305
-- Demote objects in range.
290306
{ "<", "<Plug>(neorg.promo.demote.range)", opts = { desc = "[neorg] Demote Objects in Range" } },
291307
},
292-
}
308+
},
293309
},
294310
},
295311
}

lua/neorg/modules/core/looking-glass/module.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ module.public = {
177177
})
178178
end,
179179

180-
magnify_code_block = function ()
180+
magnify_code_block = function()
181181
local buffer = vim.api.nvim_get_current_buf()
182182
local window = vim.api.nvim_get_current_win()
183183

@@ -263,7 +263,7 @@ module.public = {
263263
vsplit,
264264
vim.api.nvim_get_current_win()
265265
)
266-
end
266+
end,
267267
}
268268

269269
return module

lua/neorg/modules/core/pivot/module.lua

+1-4
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ module.public = {
4141
local buffer = vim.api.nvim_get_current_buf()
4242
local cursor = vim.api.nvim_win_get_cursor(0)
4343

44-
local node = module.required["core.integrations.treesitter"].get_first_node_on_line(
45-
buffer,
46-
cursor[1] - 1
47-
)
44+
local node = module.required["core.integrations.treesitter"].get_first_node_on_line(buffer, cursor[1] - 1)
4845

4946
if not node then
5047
log.error("No node found under the cursor! Make sure your cursor is in a list.")

lua/neorg/modules/core/tempus/module.lua

+7-7
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ module.public = {
438438
prompt = "Date: ",
439439
}, callback)
440440
end
441-
end
441+
end,
442442
}
443443

444444
module.private = {
@@ -450,12 +450,12 @@ module.private = {
450450
end
451451

452452
return vim.trim(
453-
d(date_table.weekday and date_table.weekday.name)
454-
.. d(date_table.day)
455-
.. d(date_table.month and date_table.month.name)
456-
.. d(date_table.year and string.format("%04d", date_table.year))
457-
.. d(date_table.time and tostring(date_table.time))
458-
.. d(date_table.timezone)
453+
d(date_table.weekday and date_table.weekday.name)
454+
.. d(date_table.day)
455+
.. d(date_table.month and date_table.month.name)
456+
.. d(date_table.year and string.format("%04d", date_table.year))
457+
.. d(date_table.time and tostring(date_table.time))
458+
.. d(date_table.timezone)
459459
)
460460
end,
461461
})

lua/neorg/modules/core/text-objects/module.lua

+25-5
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,31 @@ module.load = function()
6363
ts = module.required["core.integrations.treesitter"]
6464
vim.keymap.set("", "<Plug>(neorg.text-objects.item-up)", module.public.move_up)
6565
vim.keymap.set("", "<Plug>(neorg.text-objects.item-down)", module.public.move_down)
66-
vim.keymap.set("", "<Plug>(neorg.text-objects.textobject.heading.outer)", lib.wrap(module.public.highlight_node, "heading.outer"))
67-
vim.keymap.set("", "<Plug>(neorg.text-objects.textobject.heading.inner)", lib.wrap(module.public.highlight_node, "heading.inner"))
68-
vim.keymap.set("", "<Plug>(neorg.text-objects.textobject.tag.inner)", lib.wrap(module.public.highlight_node, "tag.inner"))
69-
vim.keymap.set("", "<Plug>(neorg.text-objects.textobject.tag.outer)", lib.wrap(module.public.highlight_node, "tag.outer"))
70-
vim.keymap.set("", "<Plug>(neorg.text-objects.textobject.list.outer)", lib.wrap(module.public.highlight_node, "lits.outer"))
66+
vim.keymap.set(
67+
"",
68+
"<Plug>(neorg.text-objects.textobject.heading.outer)",
69+
lib.wrap(module.public.highlight_node, "heading.outer")
70+
)
71+
vim.keymap.set(
72+
"",
73+
"<Plug>(neorg.text-objects.textobject.heading.inner)",
74+
lib.wrap(module.public.highlight_node, "heading.inner")
75+
)
76+
vim.keymap.set(
77+
"",
78+
"<Plug>(neorg.text-objects.textobject.tag.inner)",
79+
lib.wrap(module.public.highlight_node, "tag.inner")
80+
)
81+
vim.keymap.set(
82+
"",
83+
"<Plug>(neorg.text-objects.textobject.tag.outer)",
84+
lib.wrap(module.public.highlight_node, "tag.outer")
85+
)
86+
vim.keymap.set(
87+
"",
88+
"<Plug>(neorg.text-objects.textobject.list.outer)",
89+
lib.wrap(module.public.highlight_node, "lits.outer")
90+
)
7191
end
7292

7393
module.config.public = {

0 commit comments

Comments
 (0)