mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-23 01:08:59 +02:00
refactor: automatically load keymaps, autocmds and options
This commit is contained in:
parent
d224aea4a4
commit
a15f44eb89
6 changed files with 40 additions and 16 deletions
33
lua/lazyvim/plugins/config.lua
Normal file
33
lua/lazyvim/plugins/config.lua
Normal file
|
@ -0,0 +1,33 @@
|
|||
local function 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
|
||||
|
||||
-- load options here, before lazy init while sourcing plugin modules
|
||||
-- this is needed to make sure options will be correctly applied
|
||||
-- after installing missing plugins
|
||||
load("options")
|
||||
|
||||
-- autocmds and keymaps can wait to load
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "VeryLazy",
|
||||
callback = function()
|
||||
load("autocmds")
|
||||
load("keymaps")
|
||||
end,
|
||||
})
|
||||
|
||||
return {}
|
Loading…
Add table
Add a link
Reference in a new issue