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