Skip to content

Commit 1985f2d

Browse files
authored
feat: automatically typed module.required dependencies (#1537)
1 parent 28a247b commit 1985f2d

File tree

19 files changed

+60
-5
lines changed

19 files changed

+60
-5
lines changed

lua/neorg/core/modules.lua

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,47 @@ local utils = require("neorg.core.utils")
1313

1414
--- @alias neorg.module.public { version: string, [any]: any }
1515

16+
--- @class (exact) neorg.module.resolver
17+
--- @field ["core.autocommands"] core.autocommands
18+
--- @field ["core.clipboard"] core.clipboard
19+
--- @field ["core.completion"] core.completion
20+
--- @field ["core.concealer"] core.concealer
21+
--- @field ["core.dirman"] core.dirman
22+
--- @field ["core.esupports.hop"] core.esupports.hop
23+
--- @field ["core.esupports.indent"] core.esupports.indent
24+
--- @field ["core.esupports.metagen"] core.esupports.metagen
25+
--- @field ["core.export"] core.export
26+
--- @field ["core.export.markdown"] core.export.markdown
27+
--- @field ["core.fs"] core.fs
28+
--- @field ["core.highlights"] core.highlights
29+
--- @field ["core.integrations.treesitter"] core.integrations.treesitter
30+
--- @field ["core.itero"] core.itero
31+
--- @field ["core.journal"] core.journal
32+
--- @field ["core.keybinds"] core.keybinds
33+
--- @field ["core.latex.renderer"] core.latex.renderer
34+
--- @field ["core.links"] core.links
35+
--- @field ["core.looking-glass"] core.looking-glass
36+
--- @field ["core.neorgcmd"] core.neorgcmd
37+
--- @field ["core.pivot"] core.pivot
38+
--- @field ["core.presenter"] core.presenter
39+
--- @field ["core.promo"] core.promo
40+
--- @field ["core.qol.toc"] core.qol.toc
41+
--- @field ["core.qol.todo_items"] core.qol.todo_items
42+
--- @field ["core.queries.native"] core.queries.native
43+
--- @field ["core.scanner"] core.scanner
44+
--- @field ["core.storage"] core.storage
45+
--- @field ["core.summary"] core.summary
46+
--- @field ["core.syntax"] core.syntax
47+
--- @field ["core.tangle"] core.tangle
48+
--- @field ["core.tempus"] core.tempus
49+
--- @field ["core.text-objects"] core.text-objects
50+
--- @field ["core.todo-introspector"] core.todo-introspector
51+
--- @field ["core.ui"] core.ui
52+
--- @field ["core.ui.calendar"] core.ui.calendar
53+
--- @field ["core.ui.calendar.views.monthly"] core.ui.calendar.views.monthly
54+
--- @field ["core.ui.selection_popup"] core.ui.selection_popup
55+
--- @field ["core.ui.text_popup"] core.ui.text_popup
56+
1657
--- Defines both a public and private configuration for a Neorg module.
1758
--- Public configurations may be tweaked by the user from the `neorg.setup()` function,
1859
--- whereas private configurations are for internal use only.
@@ -41,7 +82,7 @@ local utils = require("neorg.core.utils")
4182
--- @field path string The full path to the module (a more verbose version of `name`). May be used in lua's `require()` statements.
4283
--- @field public private? table A convenience table to place all of your private variables that you don't want to expose.
4384
--- @field public public? neorg.module.public Every module can expose any set of information it sees fit through this field. All functions and variables declared in this table will be visiable to any other module loaded.
44-
--- @field required? table<string, neorg.module.public> Contains the public tables of all modules that were required via the `requires` array provided in the `setup()` function of this module.
85+
--- @field required? neorg.module.resolver Contains the public tables of all modules that were required via the `requires` array provided in the `setup()` function of this module.
4586
--- @field setup? fun(): neorg.module.setup? Function that is invoked before any other loading occurs. Should perform preliminary startup tasks.
4687
--- @field replaced? boolean If `true`, this means the module is a replacement for a core module. This flag is set automatically whenever `setup().replaces` is set to a value.
4788
--- @field on_event fun(event: neorg.event) A callback that is invoked any time an event the module has subscribed to has fired.

lua/neorg/modules/core/clipboard/module.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ module.private = {
7979
callbacks = {},
8080
}
8181

82+
--- @class core.clipboard
8283
module.public = {
8384
add_callback = function(node_type, func, strict)
8485
module.private.callbacks[node_type] = module.private.callbacks[node_type] or {}

lua/neorg/modules/core/export/markdown/module.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ module.config.public = {
206206
extension = "md",
207207
}
208208

209+
--- @class core.export.markdown
209210
module.public = {
210211
export = {
211212
init_state = function()

lua/neorg/modules/core/export/module.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ module.config.public = {
6969
export_dir = "<export-dir>/<language>-export",
7070
}
7171

72+
---@class core.export
7273
module.public = {
7374
--- Returns a module that can handle conversion from `.norg` to the target filetype
7475
---@param ftype string #The filetype to export to

lua/neorg/modules/core/fs/module.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ local modules = neorg.modules
1313

1414
local module = modules.create("core.fs")
1515

16+
---@class core.fs
1617
module.public = {
1718
directory_map = function(path, callback)
1819
for name, type in vim.fs.dir(path) do

lua/neorg/modules/core/itero/module.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ module.load = function()
7979
vim.keymap.set("!", "<Plug>(neorg.itero.next-iteration)", module.public.next_iteration_cr)
8080
end
8181

82+
---@class core.itero
8283
module.public = {
8384
next_iteration_cr = function()
8485
local cursor = vim.api.nvim_win_get_cursor(0)

lua/neorg/modules/core/journal/module.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ module.config.private = {
414414
},
415415
}
416416

417+
---@class core.journal
417418
module.public = {
418419
version = "0.0.9",
419420
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ module.config.public = {
109109
preset = "neorg",
110110
}
111111

112+
---@class core.keybinds
112113
module.public = {
113114
--- Adds a set of default keys for Neorg to bind.
114115
--- Should be used exclusively by external modules wanting to provide their own default keymaps.

lua/neorg/modules/core/latex/renderer/module.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ module.private.get_key = function(range)
154154
return ("%d:%d"):format(range[1], range[2])
155155
end
156156

157+
---@class core.latex.renderer
157158
module.public = {
158159
---@async
159160
---@param buf number

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ module.load = function()
3333
vim.keymap.set("", "<Plug>(neorg.looking-glass.magnify-code-block)", module.public.magnify_code_block)
3434
end
3535

36+
---@class core.looking-glass
3637
module.public = {
3738
sync_text_segment = function(source, source_window, source_start, source_end, target, target_window)
3839
-- Create a unique but deterministic namespace name for the code block

0 commit comments

Comments
 (0)