Skip to content

Commit

Permalink
feat(loader): warn when mapleader is changed after init
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Dec 21, 2022
1 parent 540847b commit 4ca3039
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lua/lazy/core/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions lua/lazy/manage/reloader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4ca3039

Please sign in to comment.