mirror of
https://github.com/neovim/neovim.git
synced 2026-08-27 09:31:47 +00:00
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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user