Skip to content

Commit 7d9bd33

Browse files
committed
fix: improve startup time by removing pcall on every module load
1 parent 5cc4111 commit 7d9bd33

File tree

7 files changed

+1
-25
lines changed

7 files changed

+1
-25
lines changed

Diff for: lua/neorg/core/modules.lua

+1-16
Original file line numberDiff line numberDiff line change
@@ -439,22 +439,7 @@ function modules.load_module(module_name, cfg)
439439
end
440440

441441
-- Attempt to require the module, does not throw an error if the module doesn't exist
442-
local exists, module = pcall(require, "neorg.modules." .. module_name .. ".module")
443-
444-
-- If the module doesn't exist then return false
445-
if not exists then
446-
local fallback_exists, fallback_module = pcall(require, "neorg.modules." .. module_name)
447-
448-
if not fallback_exists then
449-
log.error(
450-
"Unable to load module '" .. module_name .. "'. The module probably does not exist! Stacktrace: ",
451-
module
452-
)
453-
return false
454-
end
455-
456-
module = fallback_module
457-
end
442+
local module = require("neorg.modules." .. module_name .. ".module")
458443

459444
-- If the module is nil for some reason return false
460445
if not module then

Diff for: lua/neorg/init.lua

-9
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,6 @@ function neorg.org_file_entered(manual, arguments)
8989

9090
-- Go through each defined module and grab its config
9191
for name, module in pairs(module_list) do
92-
-- If the module's data is not empty and we have not defined a config table then it probably means there's junk in there
93-
if not vim.tbl_isempty(module) and not module.config then
94-
log.warn(
95-
"Potential bug detected in",
96-
name,
97-
"- nonstandard tables found in the module definition. Did you perhaps mean to put these tables inside of the config = {} table?"
98-
)
99-
end
100-
10192
-- Apply the config
10293
config.modules[name] = vim.tbl_deep_extend("force", config.modules[name] or {}, module.config or {})
10394
end

0 commit comments

Comments
 (0)