mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-19 21:06: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
55
lua/lazy/pkg/rockspec.lua
Normal file
55
lua/lazy/pkg/rockspec.lua
Normal file
|
@ -0,0 +1,55 @@
|
|||
--# selene:allow(incorrect_standard_library_use)
|
||||
|
||||
local Util = require("lazy.core.util")
|
||||
|
||||
local M = {}
|
||||
|
||||
M.dev_suffix = "-scm-1.rockspec"
|
||||
M.skip = { "lua" }
|
||||
|
||||
---@class RockSpec
|
||||
---@field rockspec_format string
|
||||
---@field package string
|
||||
---@field version string
|
||||
---@field dependencies string[]
|
||||
|
||||
---@param plugin LazyPlugin
|
||||
---@return LazyPkg?
|
||||
function M.get(plugin)
|
||||
local rockspec_file ---@type string?
|
||||
Util.ls(plugin.dir, function(path, name, t)
|
||||
if t == "file" and name:sub(-#M.dev_suffix) == M.dev_suffix then
|
||||
rockspec_file = path
|
||||
return false
|
||||
end
|
||||
end)
|
||||
|
||||
if not rockspec_file then
|
||||
return
|
||||
end
|
||||
|
||||
---@type RockSpec?
|
||||
local rockspec = {}
|
||||
local ret, err = loadfile(rockspec_file, "t", rockspec)
|
||||
if not ret then
|
||||
error(err)
|
||||
end
|
||||
ret()
|
||||
return rockspec
|
||||
and rockspec.package
|
||||
and {
|
||||
source = "rockspec",
|
||||
file = rockspec_file,
|
||||
spec = {
|
||||
dir = plugin.dir,
|
||||
url = plugin.url,
|
||||
rocks = vim.tbl_filter(function(dep)
|
||||
local name = dep:gsub("%s.*", "")
|
||||
return not vim.tbl_contains(M.skip, name)
|
||||
end, rockspec.dependencies),
|
||||
},
|
||||
}
|
||||
or nil
|
||||
end
|
||||
|
||||
return M
|
Loading…
Add table
Add a link
Reference in a new issue