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",
|
||||
lock = "pin",
|
||||
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()
|
||||
if type(spec.disabled) == "function" then
|
||||
spec.enabled = function()
|
||||
|
@ -131,17 +122,17 @@ function M.post_load()
|
|||
else
|
||||
spec.enabled = not spec.disabled
|
||||
end
|
||||
return "Use `enabled` instead"
|
||||
return "enabled = " .. vim.inspect(spec.enabled)
|
||||
end
|
||||
|
||||
alternatives.wants = function()
|
||||
return "It's not needed in most cases, otherwise use `dependencies`."
|
||||
return "dependencies = [value]"
|
||||
end
|
||||
alternatives.needs = alternatives.wants
|
||||
|
||||
alternatives.module = function()
|
||||
spec.lazy = true
|
||||
return "Use `lazy = true` instead."
|
||||
return "lazy = true"
|
||||
end
|
||||
|
||||
for old_key, alternative in pairs(alternatives) do
|
||||
|
@ -155,18 +146,50 @@ function M.post_load()
|
|||
end
|
||||
spec[old_key] = nil
|
||||
|
||||
message = message or string.format("Use `%s` instead.", alternative)
|
||||
deprecate(
|
||||
string.format("%s` in `lvim.plugins", old_key),
|
||||
message .. " See https://github.com/folke/lazy.nvim#-migration-guide"
|
||||
)
|
||||
local new_value = vim.inspect(spec[alternative] or "[value]")
|
||||
message = message or string.format("%s = %s", alternative, new_value)
|
||||
vim.schedule(function()
|
||||
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
|
||||
|
||||
if spec[1] and spec[1]:match "^http" then
|
||||
spec.url = spec[1]
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue