feat: show rockspec deps in plugin details

This commit is contained in:
Folke Lemaitre 2024-06-24 18:02:54 +02:00
parent 0f45c0d062
commit 656d3d1f5b
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
2 changed files with 22 additions and 2 deletions

View File

@ -1,12 +1,27 @@
--# selene:allow(incorrect_standard_library_use)
local Util = require("lazy.core.util")
local Config = require("lazy.core.config")
local Util = require("lazy.util")
local M = {}
M.dev_suffix = "-1.rockspec"
M.skip = { "lua" }
---@param plugin LazyPlugin
function M.deps(plugin)
local root = Config.options.rocks.root .. "/" .. plugin.name
local manifest_file = root .. "/lib/luarocks/rocks-5.1/manifest"
local manifest = {}
local ok = pcall(function()
local load, err = loadfile(manifest_file, "t", manifest)
if not load then
error(err)
end
load()
end)
return manifest and vim.tbl_keys(manifest.repository or {})
end
---@class RockSpec
---@field rockspec_format string
---@field package string

View File

@ -511,6 +511,11 @@ function M:details(plugin)
table.insert(props, { "commit", git.commit:sub(1, 7), "LazyCommit" })
end
end
local rocks = require("lazy.pkg.rockspec").deps(plugin)
if not vim.tbl_isempty(rocks) then
table.insert(props, { "rocks", vim.inspect(rocks) })
end
if Util.file_exists(plugin.dir .. "/README.md") then
table.insert(props, { "readme", "README.md" })
end