Explorar el Código

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>
LostNeophyte hace 2 años
padre
commit
f24df08794
Se han modificado 1 ficheros con 42 adiciones y 19 borrados
  1. 42 19
      lua/lvim/config/_deprecated.lua

+ 42 - 19
lua/lvim/config/_deprecated.lua

@@ -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