From 656d3d1f5b5910e50af3d67286999ff7088ebfb6 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 24 Jun 2024 18:02:54 +0200 Subject: [PATCH] feat: show rockspec deps in plugin details --- lua/lazy/pkg/rockspec.lua | 19 +++++++++++++++++-- lua/lazy/view/render.lua | 5 +++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lua/lazy/pkg/rockspec.lua b/lua/lazy/pkg/rockspec.lua index 58fc2c5..3d0745e 100644 --- a/lua/lazy/pkg/rockspec.lua +++ b/lua/lazy/pkg/rockspec.lua @@ -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 diff --git a/lua/lazy/view/render.lua b/lua/lazy/view/render.lua index a34456c..7d91dd8 100644 --- a/lua/lazy/view/render.lua +++ b/lua/lazy/view/render.lua @@ -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