mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-10 01:14:41 +02:00
refactor(config): moved loading of options, keymaps and autocmds to lazyvim.config
This commit is contained in:
parent
7b943822db
commit
dcf520f3a7
4 changed files with 38 additions and 34 deletions
|
@ -71,6 +71,16 @@ function M.setup(opts)
|
|||
{ title = "LazyVim" }
|
||||
)
|
||||
end
|
||||
|
||||
-- autocmds and keymaps can wait to load
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
group = vim.api.nvim_create_augroup("LazyVim", { clear = true }),
|
||||
pattern = "VeryLazy",
|
||||
callback = function()
|
||||
M.load("autocmds")
|
||||
M.load("keymaps")
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
---@param range? string
|
||||
|
@ -79,6 +89,25 @@ function M.has(range)
|
|||
return Semver.range(range or M.lazy_version):matches(require("lazy.core.config").version or "0.0.0")
|
||||
end
|
||||
|
||||
---@param name "autocmds" | "options" | "keymaps"
|
||||
function M.load(name)
|
||||
local Util = require("lazy.core.util")
|
||||
-- always load lazyvim, then user file
|
||||
for _, mod in ipairs({ "lazyvim.config." .. name, "config." .. name }) do
|
||||
Util.try(function()
|
||||
require(mod)
|
||||
end, {
|
||||
msg = "Failed loading " .. mod,
|
||||
on_error = function(msg)
|
||||
local modpath = require("lazy.core.cache").find(mod)
|
||||
if modpath then
|
||||
Util.error(msg)
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
setmetatable(M, {
|
||||
__index = function(_, key)
|
||||
if options == nil then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue