feat(loader): warn when mapleader is changed after init

This commit is contained in:
Folke Lemaitre 2022-12-21 10:51:31 +01:00
parent 540847b7cb
commit 4ca30390ec
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
2 changed files with 10 additions and 0 deletions

View File

@ -111,6 +111,9 @@ M.options = {}
---@type string
M.me = nil
---@type string
M.mapleader = nil
---@param spec LazySpec
---@param opts? LazyConfig
function M.setup(spec, opts)
@ -143,6 +146,7 @@ function M.setup(spec, opts)
-- disable plugin loading since we do all of that ourselves
vim.go.loadplugins = false
M.mapleader = vim.g.mapleader
vim.api.nvim_create_autocmd("User", {
pattern = "VeryLazy",

View File

@ -2,6 +2,7 @@ local Cache = require("lazy.core.cache")
local Config = require("lazy.core.config")
local Util = require("lazy.util")
local Plugin = require("lazy.core.plugin")
local Loader = require("lazy.core.loader")
local M = {}
@ -63,6 +64,11 @@ function M.check(start)
end
end
if Loader.init_done and Config.mapleader ~= vim.g.mapleader then
require("lazy.core.util").warn("You need to set `vim.g.mapleader` **BEFORE** loading lazy")
Config.mapleader = vim.g.mapleader
end
if not (start or #changes == 0) then
vim.schedule(function()
if Config.options.change_detection.notify then