Skip to content

Commit

Permalink
README: Lambda expression as post-update hook
Browse files Browse the repository at this point in the history
  • Loading branch information
junegunn committed Feb 22, 2024
1 parent eee20c7 commit 6154433
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,14 @@ If the value starts with `:`, it will be recognized as a Vim command.
Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
```

To call a Vim function, you can pass a lambda expression like so:

```vim
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
```

If you need more control, you can pass a reference to a Vim function that
takes a single argument.
takes a dictionary argument.

```vim
function! BuildYCM(info)
Expand All @@ -328,14 +334,13 @@ endfunction
Plug 'ycm-core/YouCompleteMe', { 'do': function('BuildYCM') }
```

Both forms of post-update hook are executed inside the directory of the plugin
and only run when the repository has changed, but you can force it to run
unconditionally with the bang-versions of the commands: `PlugInstall!` and
`PlugUpdate!`.
A post-update hook is executed inside the directory of the plugin and only run
when the repository has changed, but you can force it to run unconditionally
with the bang-versions of the commands: `PlugInstall!` and `PlugUpdate!`.

Make sure to escape BARs and double-quotes when you write the `do` option inline
as they are mistakenly recognized as command separator or the start of the
trailing comment.
Make sure to escape BARs and double-quotes when you write the `do` option
inline as they are mistakenly recognized as command separator or the start of
the trailing comment.

```vim
Plug 'junegunn/fzf', { 'do': 'yes \| ./install' }
Expand Down
17 changes: 9 additions & 8 deletions doc/plug.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
plug.txt plug Last change: January 19 2023
plug.txt plug Last change: February 23 2024
PLUG - TABLE OF CONTENTS *plug* *plug-toc*
==============================================================================

Expand Down Expand Up @@ -297,13 +297,15 @@ In that case, use the `do` option to describe the task to be performed.
Plug 'ycm-core/YouCompleteMe', { 'do': './install.py' }
<
If the value starts with `:`, it will be recognized as a Vim command.

*:GoInstallBinaries*
>
Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
<
To call a Vim function, you can pass a lambda expression like so:
>
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
<
If you need more control, you can pass a reference to a Vim function that
takes a single argument.
takes a dictionary argument.
>
function! BuildYCM(info)
" info is a dictionary with 3 fields
Expand All @@ -317,10 +319,9 @@ takes a single argument.
Plug 'ycm-core/YouCompleteMe', { 'do': function('BuildYCM') }
<
Both forms of post-update hook are executed inside the directory of the plugin
and only run when the repository has changed, but you can force it to run
unconditionally with the bang-versions of the commands: `PlugInstall!` and
`PlugUpdate!`.
A post-update hook is executed inside the directory of the plugin and only run
when the repository has changed, but you can force it to run unconditionally
with the bang-versions of the commands: `PlugInstall!` and `PlugUpdate!`.

Make sure to escape BARs and double-quotes when you write the `do` option
inline as they are mistakenly recognized as command separator or the start of
Expand Down

0 comments on commit 6154433

Please sign in to comment.