Skip to content

Commit

Permalink
feat: show rockspec deps in plugin details
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jun 24, 2024
1 parent 0f45c0d commit 656d3d1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
19 changes: 17 additions & 2 deletions lua/lazy/pkg/rockspec.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 5 additions & 0 deletions lua/lazy/view/render.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 656d3d1

Please sign in to comment.