mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-19 12:56:46 +00:00
feat: added support for plugin packages by lazy, rockspec and packspec
This commit is contained in:
parent
f1ba2e3d05
commit
3be55a4615
11 changed files with 281 additions and 171 deletions
28
lua/lazy/pkg/lazy.lua
Normal file
28
lua/lazy/pkg/lazy.lua
Normal file
|
@ -0,0 +1,28 @@
|
|||
local Util = require("lazy.util")
|
||||
|
||||
local M = {}
|
||||
|
||||
M.lazy_file = "lazy.lua"
|
||||
|
||||
---@param plugin LazyPlugin
|
||||
---@return LazyPkg?
|
||||
function M.get(plugin)
|
||||
local file = Util.norm(plugin.dir .. "/" .. M.lazy_file)
|
||||
if Util.file_exists(file) then
|
||||
---@type fun(): LazySpec
|
||||
local chunk = Util.try(function()
|
||||
local ret, err = loadfile(file)
|
||||
return err and error(err) or ret
|
||||
end, "`" .. M.lazy_file .. "` for **" .. plugin.name .. "** has errors:")
|
||||
if not chunk then
|
||||
Util.error("Invalid `" .. M.lazy_file .. "` for **" .. plugin.name .. "**")
|
||||
end
|
||||
return {
|
||||
source = "lazy",
|
||||
file = M.lazy_file,
|
||||
chunk = chunk,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
Loading…
Add table
Add a link
Reference in a new issue