Skip to content

Commit

Permalink
fix: load default modules even if an empty table is provided as input…
Browse files Browse the repository at this point in the history
… to setup()

note: to load no modules whatsoever, manually supply a `load = {}` to the setup table
  • Loading branch information
vhyrro committed Mar 28, 2024
1 parent 5942fdf commit c1d36ad
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lua/neorg/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,29 @@ local user_configuration
--- @module "neorg.core.config"

--- Initializes Neorg. Parses the supplied user configuration, initializes all selected modules and adds filetype checking for `.norg`.
--- @param cfg neorg.configuration.user A table that reflects the structure of `config.user_config`.
--- @param cfg neorg.configuration.user? A table that reflects the structure of `config.user_config`.
--- @see config.user_config
--- @see neorg.configuration.user
function neorg.setup(cfg)
-- If the user supplied no configuration then generate a default one (assume the user wants the defaults)
cfg = cfg or {
load = {
["core.defaults"] = {},
},
}

-- If no `load` table was passed whatsoever then assume the user wants the default ones.
-- If the user explicitly sets `load = {}` in their configs then that means they do not want
-- any modules loaded.
--
-- We check for nil specifically because some users might think `load = false` is a valid thing.
-- With the explicit check `load = false` will issue an error.
if cfg.load == nil then
cfg.load = {
["core.defaults"] = {},
}
end

if not (pcall(require, "lua-utils")) then
user_configuration = cfg
return
Expand Down

0 comments on commit c1d36ad

Please sign in to comment.