mirror of
https://github.com/LunarVim/LunarVim.git
synced 2024-09-20 10:35:08 +02:00
feat: add example to the packer deprecation message (#4201)
* feat: add example to the packer deprecation message * feat: better formatting, message * also change the http messsage * Apply suggestions from code review Co-authored-by: kylo252 <59826753+kylo252@users.noreply.github.com> * feat: improve examples --------- Co-authored-by: kylo252 <59826753+kylo252@users.noreply.github.com>
This commit is contained in:
parent
804e08cb46
commit
f24df08794
1 changed files with 42 additions and 19 deletions
|
@ -111,18 +111,9 @@ function M.post_load()
|
||||||
run = "build",
|
run = "build",
|
||||||
lock = "pin",
|
lock = "pin",
|
||||||
tag = "version",
|
tag = "version",
|
||||||
|
requires = "dependencies",
|
||||||
}
|
}
|
||||||
|
|
||||||
alternatives.requires = function()
|
|
||||||
if type(spec.requires) == "string" then
|
|
||||||
spec.dependencies = { spec.requires }
|
|
||||||
else
|
|
||||||
spec.dependencies = spec.requires
|
|
||||||
end
|
|
||||||
|
|
||||||
return "Use `dependencies` instead"
|
|
||||||
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()
|
||||||
|
@ -131,17 +122,17 @@ function M.post_load()
|
||||||
else
|
else
|
||||||
spec.enabled = not spec.disabled
|
spec.enabled = not spec.disabled
|
||||||
end
|
end
|
||||||
return "Use `enabled` instead"
|
return "enabled = " .. vim.inspect(spec.enabled)
|
||||||
end
|
end
|
||||||
|
|
||||||
alternatives.wants = function()
|
alternatives.wants = function()
|
||||||
return "It's not needed in most cases, otherwise use `dependencies`."
|
return "dependencies = [value]"
|
||||||
end
|
end
|
||||||
alternatives.needs = alternatives.wants
|
alternatives.needs = alternatives.wants
|
||||||
|
|
||||||
alternatives.module = function()
|
alternatives.module = function()
|
||||||
spec.lazy = true
|
spec.lazy = true
|
||||||
return "Use `lazy = true` instead."
|
return "lazy = true"
|
||||||
end
|
end
|
||||||
|
|
||||||
for old_key, alternative in pairs(alternatives) do
|
for old_key, alternative in pairs(alternatives) do
|
||||||
|
@ -155,18 +146,50 @@ function M.post_load()
|
||||||
end
|
end
|
||||||
spec[old_key] = nil
|
spec[old_key] = nil
|
||||||
|
|
||||||
message = message or string.format("Use `%s` instead.", alternative)
|
local new_value = vim.inspect(spec[alternative] or "[value]")
|
||||||
deprecate(
|
message = message or string.format("%s = %s", alternative, new_value)
|
||||||
string.format("%s` in `lvim.plugins", old_key),
|
vim.schedule(function()
|
||||||
message .. " See https://github.com/folke/lazy.nvim#-migration-guide"
|
vim.notify_once(
|
||||||
)
|
string.format(
|
||||||
|
[[`%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,
|
||||||
|
message,
|
||||||
|
old_key,
|
||||||
|
new_value,
|
||||||
|
message
|
||||||
|
),
|
||||||
|
vim.log.levels.WARN
|
||||||
|
)
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if spec[1] and spec[1]:match "^http" then
|
if spec[1] and spec[1]:match "^http" then
|
||||||
spec.url = spec[1]
|
spec.url = spec[1]
|
||||||
spec[1] = nil
|
spec[1] = nil
|
||||||
deprecate("{ 'http...' }` in `lvim.plugins", "Use { url = 'http...' } instead.")
|
|
||||||
|
vim.schedule(function()
|
||||||
|
vim.notify_once(
|
||||||
|
|
||||||
|
string.format(
|
||||||
|
[[`"http..."` in `lvim.plugins` has been deprecated since the migration to lazy.nvim. Use `url = "http..."` instead.
|
||||||
|
Example:
|
||||||
|
`lvim.plugins = {... { "%s" ...} ...}`
|
||||||
|
->
|
||||||
|
`lvim.plugins = {... { url = "%s" ...} ...}`
|
||||||
|
See https://github.com/folke/lazy.nvim#-migration-guide"]],
|
||||||
|
spec.url,
|
||||||
|
spec.url
|
||||||
|
),
|
||||||
|
|
||||||
|
vim.log.levels.WARN
|
||||||
|
)
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue