From 0e46f7bfccfc91d15223e27aa189b0cb1386a861 Mon Sep 17 00:00:00 2001 From: abeldekat Date: Mon, 4 Dec 2023 16:55:34 +0100 Subject: [PATCH] added a warning when extra lazyrc is not the last plugin spec --- lua/lazyvim/plugins/extras/lazyrc.lua | 23 +++++++++++++++++++++-- lua/lazyvim/plugins/xtras.lua | 1 - 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lazyrc.lua b/lua/lazyvim/plugins/extras/lazyrc.lua index 1c4d0d62..4ae88441 100644 --- a/lua/lazyvim/plugins/extras/lazyrc.lua +++ b/lua/lazyvim/plugins/extras/lazyrc.lua @@ -1,12 +1,12 @@ --[[ -This extra allows for project-specific plugin specs. +Enable project-specific plugin specs. File .lazy.lua: is read when present in the current working directory should return a plugin spec has to be manually trusted for each instance of the file -This extra should be the last plugin spec parsed by lazy.nvim +This extra should be the last plugin spec added to lazy.nvim See: :h 'exrc' @@ -17,4 +17,23 @@ local file = vim.secure.read(filepath) if not file then return {} end + +vim.api.nvim_create_autocmd("User", { + pattern = "VeryLazy", + once = true, + callback = function() + local Config = require("lazy.core.config") + local Util = require("lazyvim.util") + local lazyrc_idx = Util.plugin.extra_idx("lazyrc") + + if lazyrc_idx and lazyrc_idx ~= #Config.spec.modules then + Util.warn({ + "The `lazyrc` extra must be the last plugin spec added to **lazy.nvim**. ", + "", + "Add `{ import = 'lazyvim.plugins.extras.lazyrc' }` to file `config.lazy`. ", + "Do not use the `LazyExtras` command. ", + }, { title = "LazyVim", once = true }) + end + end, +}) return loadstring(file)() diff --git a/lua/lazyvim/plugins/xtras.lua b/lua/lazyvim/plugins/xtras.lua index 1ecf081a..4eb73804 100644 --- a/lua/lazyvim/plugins/xtras.lua +++ b/lua/lazyvim/plugins/xtras.lua @@ -2,7 +2,6 @@ local Config = require("lazyvim.config") -- Some extras need to be loaded before others local prios = { - ["lazyvim.plugins.extras.lazyrc"] = 1000, ["lazyvim.plugins.extras.editor.aerial"] = 100, ["lazyvim.plugins.extras.editor.symbols-outline"] = 100, ["lazyvim.plugins.extras.test.core"] = 1,