Skip to content

Commit 6412719

Browse files
committed
docs(lockfile): Upgrade moved to optional args
1 parent 1a7f177 commit 6412719

File tree

2 files changed

+119
-55
lines changed

2 files changed

+119
-55
lines changed

README.md

Lines changed: 65 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -178,34 +178,23 @@ end)
178178

179179
`packer` provides the following commands after you've run and configured `packer` with `require('packer').startup(...)`:
180180

181-
```
182-
-- You must run this or `PackerSync` whenever you make changes to your plugin configuration
183-
-- Regenerate compiled loader file
184-
:PackerCompile
185-
186-
-- Remove any disabled or unused plugins
187-
:PackerClean
188-
189-
-- Clean, then install missing plugins
190-
:PackerInstall
191-
192-
-- Clean, then update and install plugins
193-
-- supports the `--preview` flag as an optional first argument to preview updates
194-
:PackerUpdate
195-
196-
-- Perform `PackerUpdate` and then `PackerCompile`
197-
-- supports the `--preview` flag as an optional first argument to preview updates
198-
:PackerSync
199-
200-
-- Perform `PackerUpdate` without lockfile.
201-
:PackerUpgrade
202-
203-
-- Loads opt plugin immediately
204-
:PackerLoad completion-nvim ale
205-
206-
-- Updates lockfile from installed plugins.
207-
:PackerLockfile
208-
```
181+
- `:PackerCompile` Regenerate compiled loader file
182+
- You must run this or `PackerSync` whenever you make changes to your plugin configuration
183+
- `:PackerClean` Remove any disabled or unused plugins
184+
- `:PackerInstall` Clean, then install missing plugins. Supports optional arguments
185+
- `--nolockfile`: Do not apply lockfile if enabled
186+
- `--lockfile=/path/lockfile.lua`: Override lockfile used
187+
- `:PackerUpdate` Clean, then update and install plugins. Supports optional arguments
188+
- `--preview`: Preview updates before applying
189+
- `--nolockfile`: Do not apply lockfile if enabled
190+
- `--lockfile=/path/lockfile.lua`: Override lockfile used
191+
- `:PackerSync` Perform `PackerUpdate` and then `PackerCompile`. Supports optional arguments
192+
- `--preview`: Preview updates before applying
193+
- `--nolockfile`: Do not apply lockfile if enabled
194+
- `--lockfile=/path/lockfile.lua`: Override lockfile used
195+
- `:PackerLoad` Loads opt plugin immediately
196+
- `:PackerLockfile` Updates lockfile from installed plugins. Supports optional arguments
197+
- `--path=/path/lockfile.lua`: Override lockfile output
209198

210199
You can configure Neovim to automatically run `:PackerCompile` whenever `plugins.lua` is updated with
211200
[an autocommand](https://neovim.io/doc/user/autocmd.html#:autocmd):
@@ -363,7 +352,7 @@ default configuration values (and structure of the configuration table) are:
363352
lockfile = {
364353
enable = false, -- Should packer apply lockfile to `installer` and `updater`
365354
path = util.join_paths(stdpath 'config', 'lockfile.lua'), -- Default file location for lockfile
366-
update_on_upgrade = false, -- Should packer update the lockfile after upgrading plugins
355+
regen_on_update = false, -- Should packer update the lockfile after upgrading plugins
367356
},
368357
luarocks = {
369358
python_cmd = 'python' -- Set the python command to use for running hererocks
@@ -421,11 +410,12 @@ use {
421410
ft = string or list, -- Specifies filetypes which load this plugin.
422411
keys = string or list, -- Specifies maps which load this plugin. See "Keybindings".
423412
event = string or list, -- Specifies autocommand events which load this plugin.
424-
fn = string or list -- Specifies functions which load this plugin.
413+
fn = string or list, -- Specifies functions which load this plugin.
425414
cond = string, function, or list of strings/functions, -- Specifies a conditional test to load this plugin
426-
module = string or list -- Specifies Lua module names for require. When requiring a string which starts
415+
module = string or list, -- Specifies Lua module names for require. When requiring a string which starts
427416
-- with one of these module names, the plugin will be loaded.
428-
module_pattern = string/list -- Specifies Lua pattern of Lua module names for require. When requiring a string which matches one of these patterns, the plugin will be loaded.
417+
module_pattern = string/list -- Specifies Lua pattern of Lua module names for require. When requiring a
418+
-- string which matches one of these patterns, the plugin will be loaded.
429419
}
430420
```
431421

@@ -544,14 +534,20 @@ below, `plugins` is an optional table of plugin names; if not provided, the defa
544534
plugins":
545535

546536
- `packer.install(plugins)`: Install the specified plugins if they are not already installed
537+
- `packer.install(opts, plugins)`: First argument can be a table of optional args
538+
- `nolockfile`: `boolean` Should the command use the lockfile
539+
- `lockfile`: `string` Override the default lockfile path to be used
547540
- `packer.update(plugins)`: Update the specified plugins, installing any that are missing
548-
- `packer.update(opts, plugins)`: First argument can be a table specifying options, such as `{preview_updates = true}` to preview potential changes before updating (same as `PackerUpdate --preview`).
541+
- `packer.update(opts, plugins)`: First argument can be a table specifying options
542+
- `preview`: `boolean` Preview potential change before updating
543+
- `nolockfile`: `boolean` Should the command use the lockfile
544+
- `lockfile`: `string` Override the default lockfile path to be used
549545
- `packer.clean()`: Remove any disabled or no longer managed plugins
550546
- `packer.sync(plugins)`: Perform a `clean` followed by an `update`.
551547
- `packer.sync(opts, plugins)`: Can take same optional options as `update`.
552-
- `packer.upgrade(plugins)`: Performs an `update` without applying the lockfile
553548
- `packer.compile(path)`: Compile lazy-loader code and save to `path`.
554-
- `packer.lockfile()`: Updates lockfile based on currently installed plugins
549+
- `packer.lockfile(opts)`: Updates lockfile based on currently installed plugins
550+
- `path`: `string` Override lockfile output path
555551
- `packer.snapshot(snapshot_name, ...)`: Creates a snapshot file that will live under `config.snapshot_path/<snapshot_name>`. If `snapshot_name` is an absolute path, then that will be the location where the snapshot will be taken. Optionally, a list of plugins name can be provided to selectively choose the plugins to snapshot.
556552
- `packer.rollback(snapshot_name, ...)`: Rollback plugins status a snapshot file that will live under `config.snapshot_path/<snapshot_name>`. If `snapshot_name` is an absolute path, then that will be the location where the snapshot will be taken. Optionally, a list of plugins name can be provided to selectively choose which plugins to revert.
557553
- `packer.delete(snapshot_name)`: Deletes a snapshot file under `config.snapshot_path/<snapshot_name>`. If `snapshot_name` is an absolute path, then that will be the location where the snapshot will be deleted.
@@ -592,6 +588,40 @@ name and information table as arguments.
592588
configuration in some sort of source repository. Committing packer's lockfile will ensure that packer will
593589
`install` and `update` plugins to known working commits for their configuration.
594590

591+
Enabling lockfile support will change the default behavior of `install`, `update`, and `sync` commands.
592+
If the lockfile contains a plugin, packer will update to that commit instead of the latest changes. If the
593+
plugin is not found in the lockfile packer will fetch the latest changes.
594+
595+
When wanting to update your local plugins to the latest changes call your packer update command with
596+
`--nolockfile` argument. This will ignore the lockfile and update your plugins to the latest changes.
597+
598+
Some example commands:
599+
600+
```vim
601+
" Generate the lockfile to lockfile.path defined in packer's config
602+
PackerLockfile
603+
604+
" Generating a lockfile to some other path
605+
PackerLockfile --path="/some/other/path.lua"
606+
607+
" Update plugins to the state defined in lockfile
608+
PackerUpdate
609+
610+
" Updating without applying lockfile
611+
PackerUpdate --nolockfile
612+
613+
" Updating a specific plugin without applying lockfile
614+
PackerUpdate --nolockfile plenary.nvim
615+
616+
" Updating plugins and applying a specific lockfile
617+
PackerUpdate --lockfile="/some/other/path.lua"
618+
619+
" Updating a specific plugin with a specific lockfile
620+
PackerUpdate --lockfile="/some/other/path.lua" plenary.nvim
621+
```
622+
623+
The same options that apply to `PackerUpdate` also apply to `PackerInstall` and `PackerSync`.
624+
595625
### User autocommands
596626
`packer` runs most of its operations asyncronously. If you would like to implement automations that
597627
require knowing when the operations are complete, you can use the following `User` autocmds (see

doc/packer.txt

Lines changed: 54 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -118,33 +118,39 @@ configuration. Regenerate compiled loader file.
118118

119119
`PackerInstall` *packer-commands-install*
120120
Clean, then install missing plugins.
121+
Optional arguments:
122+
`--nolockfile` Do not apply lockfile if enabled
123+
`--lockfile=/path/lockfile.lua` Override lockfile used
121124

122125
`PackerUpdate` *packer-commands-update*
123126
Clean, then update and install plugins.
124-
Supports the `--preview` flag as an optional first argument to preview
125-
updates.
127+
Optional arguments:
128+
`--preview` Preview updates
129+
`--nolockfile` Do not apply lockfile if enabled
130+
`--lockfile=/path/lockfile.lua` Override lockfile used
126131

127132
`PackerSync` *packer-commands-sync*
128133
Perform `PackerUpdate` and then `PackerCompile`.
129-
Supports the `--preview` flag as an optional first argument to preview
130-
updates.
131-
132-
`PackerUpdate` *packer-commands-upgrade*
133-
Perform `PackerUpdate` without lockfile.
134+
Optional arguments:
135+
`--preview` Preview updates
136+
`--nolockfile` Do not apply lockfile if enabled
137+
`--lockfile=/path/lockfile.lua` Override lockfile used
134138

135139
`PackerLockfile` *packer-commands-lockfile*
136140
Updates lockfile from installed plugins.
141+
Optional arguments:
142+
`--path=/path/lockfile.lua` Override lockfile output
137143

138144
`PackerLoad` *packer-commands-load*
139145
Loads opt plugin immediately
140146

141-
`PackerSnapshot` *packer-commands-snapshot*
147+
`PackerSnapshot` *packer-commands-snapshot*
142148
Snapshots your plugins to a file
143149

144-
`PackerSnapshotDelete` *packer-commands-delete*
150+
`PackerSnapshotDelete` *packer-commands-delete*
145151
Deletes a snapshot
146152

147-
`PackerSnapshotRollback` *packer-commands-rollback*
153+
`PackerSnapshotRollback` *packer-commands-rollback*
148154
Rolls back plugins' commit specified by the snapshot
149155
==============================================================================
150156
USAGE *packer-usage*
@@ -197,10 +203,9 @@ commands work well for this purpose: >
197203
command! -nargs=* -complete=customlist,v:lua.require'packer'.plugin_complete PackerInstall lua require('packer').install(<f-args>)
198204
command! -nargs=* -complete=customlist,v:lua.require'packer'.plugin_complete PackerUpdate lua require('packer').update(<f-args>)
199205
command! -nargs=* -complete=customlist,v:lua.require'packer'.plugin_complete PackerSync lua require('packer').sync(<f-args>)
200-
command! -nargs=* -complete=customlist,v:lua.require'packer'.plugin_complete PackerUpgrade lua require('packer').upgrade(<f-args>)
206+
command! -nargs=* -complete=customlist,v:lua.require'packer.lockfile'.completion PackerLockfile lua require('packer').lockfile(<f-args>)
201207
command! PackerClean packadd packer.nvim | lua require('plugins').clean()
202208
command! PackerCompile packadd packer.nvim | lua require('plugins').compile('~/.config/nvim/plugin/packer_load.vim')
203-
command! PackerLockfile packadd packer.nvim | lua require('packer').lockfile()
204209
command! -bang -nargs=+ -complete=customlist,v:lua.require'packer'.loader_complete PackerLoad lua require('packer').loader(<f-args>, '<bang>')
205210
206211
CONFIGURATION *packer-configuration*
@@ -505,10 +510,43 @@ They can be configured by changing the value of `config.display.keybindings`
505510
Setting any of its keys to `false` will disable the corresponding keybinding.
506511

507512
LOCKFILE *packer-lockfile*
508-
`packer` provides a `lockfile` to help manage plugin updates. This is useful
509-
for users that store their configuration in some sort of source repository.
510-
Committing packer's lockfile will ensure that packer will `install` and
511-
`update` plugins to known working commits for their configuration.
513+
`packer` provides a `lockfile` to help manage plugin updates. This is useful for users that store their
514+
configuration in some sort of source repository. Committing packer's lockfile will ensure that packer will
515+
`install` and `update` plugins to known working commits for their configuration.
516+
517+
Enabling lockfile support will change the default behavior of `install`, `update`, and `sync` commands.
518+
If the lockfile contains a plugin, packer will update to that commit instead of the latest changes. If the
519+
plugin is not found in the lockfile packer will fetch the latest changes.
520+
521+
When wanting to update your local plugins to the latest changes call your packer update command with
522+
`--nolockfile` argument. This will ignore the lockfile and update your plugins to the latest changes.
523+
524+
Some example commands:
525+
526+
>
527+
" Generate the lockfile to lockfile.path defined in packer's config
528+
PackerLockfile
529+
530+
" Generating a lockfile to some other path
531+
PackerLockfile --path="/some/other/path.lua"
532+
533+
" Update plugins to the state defined in lockfile
534+
PackerUpdate
535+
536+
" Updating without applying lockfile
537+
PackerUpdate --nolockfile
538+
539+
" Updating a specific plugin without applying lockfile
540+
PackerUpdate --nolockfile plenary.nvim
541+
542+
" Updating plugins and applying a specific lockfile
543+
PackerUpdate --lockfile="/some/other/path.lua"
544+
545+
" Updating a specific plugin with a specific lockfile
546+
PackerUpdate --lockfile="/some/other/path.lua" plenary.nvim
547+
<
548+
549+
The same options that apply to `PackerUpdate` also apply to `PackerInstall` and `PackerSync`.
512550

513551
USER AUTOCMDS *packer-user-autocmds*
514552
`packer` runs most of its operations asyncronously. If you would like to
@@ -583,10 +621,6 @@ Additionally, the first argument can be a table specifying options,
583621
such as `update({preview_updates = true}, ...)` to preview potential changes before updating
584622
(same as `PackerUpdate --preview`).
585623

586-
upgrade() *packer.upgrade()*
587-
`upgrade` performes an `update` without applying the `lockfile`. This will
588-
update plugins to their latest versions.
589-
590624
snapshot(snapshot_name, ...) *packer.snapshot()*
591625
`snapshot` takes the rev of all the installed plugins and serializes them into a Lua table which will be saved under `config.snapshot_path` (which is the directory that will hold all the snapshots files) as `config.snapshot_path/<snapshot_name>` or an absolute path provided by the users.
592626
Optionally plugins name can be specified so that only those plugins will be

0 commit comments

Comments
 (0)