feat(pack): introduce plugin manifest support

Problem: There is no agreed way for plugins to provide extra information
  about themselves. Like required Neovim version, install/update/delete
  hooks, and dependencies.

Solution: Introduce basic concept of plugin manifest file `pkg.json`
  based on https://packspec.org/.
This commit is contained in:
Evgeni Chasnovski
2026-07-31 11:28:11 +03:00
parent 02a25caa1b
commit 4cdd6d76c5
5 changed files with 140 additions and 0 deletions

View File

@@ -200,6 +200,31 @@ local function check_lockfile()
end
end
local function check_manifest(manifest, plug_name)
local name_str = vim.inspect(plug_name)
if vim.tbl_count(manifest) == 0 then
health.warn(('Plugin %s has empty or malformed manifest file'):format(name_str))
return false
end
local nvim_engine = (manifest.engines or {}).nvim or '*'
local ok_version, nvim_version_range = pcall(vim.version.range, nvim_engine)
if not ok_version then
health.warn(('Plugin %s has malformed `engines.nvim` in manifest file'):format(name_str))
return false
end
--- @cast nvim_version_range vim.VersionRange
if not nvim_version_range:has(vim.version()) then
health.warn(
('Plugin %s Nvim version requirement %s'):format(name_str, tostring(nvim_version_range))
.. (' does not match current version %s'):format(tostring(vim.version()))
)
return false
end
return true
end
--- @return boolean Whether a check is successful
local function check_installed_plugin(plug_name)
local name_str = vim.inspect(plug_name)
@@ -248,6 +273,11 @@ local function check_installed_plugin(plug_name)
)
end
-- Manifest
if info[1].manifest then
return check_manifest(info[1].manifest, plug_name)
end
return true
end