Skip to content

Commit 4ca3039

Browse files
committed
feat(loader): warn when mapleader is changed after init
1 parent 540847b commit 4ca3039

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lua/lazy/core/config.lua

+4
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ M.options = {}
111111
---@type string
112112
M.me = nil
113113

114+
---@type string
115+
M.mapleader = nil
116+
114117
---@param spec LazySpec
115118
---@param opts? LazyConfig
116119
function M.setup(spec, opts)
@@ -143,6 +146,7 @@ function M.setup(spec, opts)
143146

144147
-- disable plugin loading since we do all of that ourselves
145148
vim.go.loadplugins = false
149+
M.mapleader = vim.g.mapleader
146150

147151
vim.api.nvim_create_autocmd("User", {
148152
pattern = "VeryLazy",

lua/lazy/manage/reloader.lua

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ local Cache = require("lazy.core.cache")
22
local Config = require("lazy.core.config")
33
local Util = require("lazy.util")
44
local Plugin = require("lazy.core.plugin")
5+
local Loader = require("lazy.core.loader")
56

67
local M = {}
78

@@ -63,6 +64,11 @@ function M.check(start)
6364
end
6465
end
6566

67+
if Loader.init_done and Config.mapleader ~= vim.g.mapleader then
68+
require("lazy.core.util").warn("You need to set `vim.g.mapleader` **BEFORE** loading lazy")
69+
Config.mapleader = vim.g.mapleader
70+
end
71+
6672
if not (start or #changes == 0) then
6773
vim.schedule(function()
6874
if Config.options.change_detection.notify then

0 commit comments

Comments
 (0)