fix(deprecation): only deprecate tag == "*" in lvim.plugins (#4297)

This commit is contained in:
LostNeophyte 2023-07-18 13:27:58 +02:00 committed by GitHub
parent e7ce9522d7
commit 84737b1573
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 4AEE18F83AFDEB23

View file

@ -110,10 +110,16 @@ function M.post_load()
opt = "lazy",
run = "build",
lock = "pin",
tag = "version",
requires = "dependencies",
}
alternatives.tag = function()
if spec.tag == "*" then
spec.version = "*"
return [[version = "*"]]
end
end
alternatives.disable = function()
if type(spec.disabled) == "function" then
spec.enabled = function()
@ -138,12 +144,16 @@ function M.post_load()
for old_key, alternative in pairs(alternatives) do
if spec[old_key] ~= nil then
local message
local old_value = vim.inspect(spec[old_key]) or "value"
if type(alternative) == "function" then
message = alternative()
else
spec[alternative] = spec[old_key]
end
-- not every function in alternatives returns a message (e.g. tag)
if type(alternative) ~= "function" or message then
spec[old_key] = nil
local new_value = vim.inspect(spec[alternative] or "[value]")
@ -151,16 +161,17 @@ function M.post_load()
vim.schedule(function()
vim.notify_once(
string.format(
[[`%s` in `lvim.plugins` has been deprecated since the migration to lazy.nvim. Use `%s` instead.
[[`%s = %s` in `lvim.plugins` has been deprecated since the migration to lazy.nvim. Use `%s` instead.
Example:
`lvim.plugins = {... {... %s = %s ...} ...}`
->
`lvim.plugins = {... {... %s ...} ...}`
See https://github.com/folke/lazy.nvim#-migration-guide"]],
old_key,
old_value,
message,
old_key,
new_value,
old_value,
message
),
vim.log.levels.WARN
@ -168,6 +179,7 @@ See https://github.com/folke/lazy.nvim#-migration-guide"]],
end)
end
end
end
if spec[1] and spec[1]:match "^http" then
spec.url = spec[1]