Skip to content

Commit

Permalink
refactor!: simplify code in preparation of lazy.nvim luarocks support
Browse files Browse the repository at this point in the history
  • Loading branch information
vhyrro committed Jul 8, 2024
1 parent bb8e102 commit 9b09252
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 71 deletions.
26 changes: 0 additions & 26 deletions build.lua

This file was deleted.

4 changes: 1 addition & 3 deletions lua/neorg/core/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ local neorg = {
log = require("neorg.core.log"),
modules = require("neorg.core.modules"),
utils = require("neorg.core.utils"),

---@module "lua-utils"
lib = nil,
lib = require("lua-utils"),
}

return neorg
42 changes: 0 additions & 42 deletions lua/neorg/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
local neorg = require("neorg.core")
local config, log, modules = neorg.config, neorg.log, neorg.modules

-- HACK(vhyrro): This variable is here to prevent issues with lazy's build.lua script loading.

---@type neorg.configuration.user?
local user_configuration

--- @module "neorg.core.config"

--- Initializes Neorg. Parses the supplied user configuration, initializes all selected modules and adds filetype checking for `.norg`.
Expand All @@ -36,19 +31,6 @@ function neorg.setup(cfg)
}
end

if not (pcall(require, "lua-utils")) then
vim.notify(
"Warning [neorg]: lua-utils not found. If you're just installing the plugin, ignore this message, when in doubt run `:Lazy build neorg`. If you're not on lazy please rerun the build scripts.",
vim.log.levels.WARN
)

-- Allow neorg to be reloaded once more.
package.loaded.neorg = nil

user_configuration = cfg
return
end

config.user_config = vim.tbl_deep_extend("force", config.user_config, cfg)

-- Create a new global instance of the neorg logger.
Expand All @@ -62,11 +44,6 @@ function neorg.setup(cfg)
},
})

local ok, lua_utils = pcall(require, "lua-utils")
assert(ok, "unable to find lua-utils dependency. Perhaps try restarting Neovim?")

neorg.lib = lua_utils

-- If the file we have entered has a `.norg` extension:
if vim.fn.expand("%:e") == "norg" or not config.user_config.lazy_loading then
-- Then boot up the environment.
Expand All @@ -87,25 +64,6 @@ function neorg.setup(cfg)
end
end

--- Equivalent of `setup()`, but is executed by Lazy.nvim's build.lua script.
--- It attempts to pull the configuration options provided by the user when setup()
--- first ran, and relays those configuration options to the actual Neorg runtime.
function neorg.setup_after_build()
if not user_configuration then
return
end

package.loaded["lua-utils"] = nil

-- HACK(vhyrro): Please do this elsewhere.
local ok, lua_utils = pcall(require, "lua-utils")
assert(ok, "unable to find lua-utils dependency. Perhaps try restarting Neovim?")

neorg.lib = lua_utils

neorg.setup(user_configuration)
end

--- This function gets called upon entering a .norg file and loads all of the user-defined modules.
--- @param manual boolean If true then the environment was kickstarted manually by the user.
--- @param arguments string? A list of arguments in the format of "key=value other_key=other_value".
Expand Down

0 comments on commit 9b09252

Please sign in to comment.