docs(pack): add example workflow of how to revert after a bad update

Problem: No example workflow of how to revert after a bad update.

Solution: Add example workflow of how to revert after a bad update.

  In future this might be improved by utilizing other `vim.pack`
  features or via a dedicated function (like `vim.pack.restore()` that
  restores all installed plugins to a state from the lockfile).
This commit is contained in:
Evgeni Chasnovski
2025-11-13 15:49:17 +02:00
parent 2e533e364e
commit 18e6ba90e2
2 changed files with 24 additions and 0 deletions

View File

@@ -294,6 +294,18 @@ Unfreeze plugin to start receiving updates:
want it to be updated. want it to be updated.
• |:restart|. • |:restart|.
Revert plugin after an update:
• Locate plugin's revision at working state. For example:
• If there is a previous version of |vim.pack-lockfile| (like from version
control history), use it to get plugin's `rev` field.
• If there is a log file ("nvim-pack.log" at "log" |stdpath()|), open it and
navigate to latest updates (at the bottom). Locate lines about plugin
update details and use revision from "State before".
• Freeze plugin to target revision (set `version` and |:restart|).
• Run `vim.pack.update({ 'plugin-name' }, { force = true })` to make plugin
state on disk follow target revision. |:restart|.
• When ready to deal with updating plugin, unfreeze it.
Remove plugins from disk: Remove plugins from disk:
• Use |vim.pack.del()| with a list of plugin names to remove. Make sure their • Use |vim.pack.del()| with a list of plugin names to remove. Make sure their
specs are not included in |vim.pack.add()| call in 'init.lua' or they will specs are not included in |vim.pack.add()| call in 'init.lua' or they will

View File

@@ -91,6 +91,18 @@
---you want it to be updated. ---you want it to be updated.
---- |:restart|. ---- |:restart|.
--- ---
---Revert plugin after an update:
---- Locate plugin's revision at working state. For example:
--- - If there is a previous version of |vim.pack-lockfile| (like from version
--- control history), use it to get plugin's `rev` field.
--- - If there is a log file ("nvim-pack.log" at "log" |stdpath()|), open it
--- and navigate to latest updates (at the bottom). Locate lines about plugin
--- update details and use revision from "State before".
---- Freeze plugin to target revision (set `version` and |:restart|).
---- Run `vim.pack.update({ 'plugin-name' }, { force = true })` to make plugin
--- state on disk follow target revision. |:restart|.
---- When ready to deal with updating plugin, unfreeze it.
---
---Remove plugins from disk: ---Remove plugins from disk:
---- Use |vim.pack.del()| with a list of plugin names to remove. Make sure their specs ---- Use |vim.pack.del()| with a list of plugin names to remove. Make sure their specs
---are not included in |vim.pack.add()| call in 'init.lua' or they will be reinstalled. ---are not included in |vim.pack.add()| call in 'init.lua' or they will be reinstalled.