mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-23 17:28:57 +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
2
init.lua
2
init.lua
|
@ -1,4 +1,4 @@
|
||||||
vim.g.mapleader = " "
|
vim.g.mapleader = " "
|
||||||
vim.g.maplocalleader = " "
|
vim.g.maplocalleader = " "
|
||||||
|
|
||||||
require("lazyvim").setup()
|
require("lazyvim.config.lazy")
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
-- This file is automatically loaded by plugins.config
|
||||||
|
|
||||||
-- Check if we need to reload the file when it changed
|
-- Check if we need to reload the file when it changed
|
||||||
vim.api.nvim_create_autocmd({ "FocusGained", "TermClose", "TermLeave" }, { command = "checktime" })
|
vim.api.nvim_create_autocmd({ "FocusGained", "TermClose", "TermLeave" }, { command = "checktime" })
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
-- This file is automatically loaded by plugins.config
|
||||||
|
|
||||||
-- Move to window using the <meta> movement keys
|
-- Move to window using the <meta> movement keys
|
||||||
vim.keymap.set("n", "<A-left>", "<C-w>h")
|
vim.keymap.set("n", "<A-left>", "<C-w>h")
|
||||||
vim.keymap.set("n", "<A-down>", "<C-w>j")
|
vim.keymap.set("n", "<A-down>", "<C-w>j")
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
-- This file is automatically loaded by plugins.config
|
||||||
|
|
||||||
vim.opt.autowrite = true -- enable auto write
|
vim.opt.autowrite = true -- enable auto write
|
||||||
vim.opt.clipboard = "unnamedplus" -- sync with system clipboard
|
vim.opt.clipboard = "unnamedplus" -- sync with system clipboard
|
||||||
vim.opt.cmdheight = 1
|
vim.opt.cmdheight = 1
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
local M = {}
|
|
||||||
|
|
||||||
---@param opts? LazyVimSettings
|
|
||||||
function M.setup(opts)
|
|
||||||
if not package.loaded.lazy then
|
|
||||||
require("lazyvim.config.lazy")
|
|
||||||
end
|
|
||||||
local settings = require("lazyvim.config.settings")
|
|
||||||
package.loaded["lazyvim.config.settings"] = vim.tbl_deep_extend("force", settings, opts or {})
|
|
||||||
require("lazyvim.config.options")
|
|
||||||
require("lazyvim.config.autocmds")
|
|
||||||
require("lazyvim.config.keymaps")
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
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