mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-27 03:09:07 +02:00
feat(extras): Enable project-specific plugin specs using local .lazy.lua (#2115)
* feat(extras): Enable project-specific plugin specs using .lazy.lua * added a warning when extra lazyrc is not the last plugin spec
This commit is contained in:
parent
5012d7d839
commit
b949835de5
1 changed files with 39 additions and 0 deletions
39
lua/lazyvim/plugins/extras/lazyrc.lua
Normal file
39
lua/lazyvim/plugins/extras/lazyrc.lua
Normal file
|
@ -0,0 +1,39 @@
|
|||
--[[
|
||||
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 added to lazy.nvim
|
||||
|
||||
See:
|
||||
:h 'exrc'
|
||||
:h :trust
|
||||
--]]
|
||||
local filepath = vim.fn.fnamemodify(".lazy.lua", ":p")
|
||||
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)()
|
Loading…
Add table
Add a link
Reference in a new issue