From bd2cb9d2de81c5058d8f02c0a24a1b11654e0ea4 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Wed, 22 Oct 2014 13:02:17 +0900 Subject: [PATCH] Install frozen plugin if it's not found (#113) --- README.md | 18 +++++++++--------- plug.vim | 7 ++++++- test/workflow.vader | 27 ++++++++++++++++++++++++++- 3 files changed, 41 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 50763af..c5827ba 100644 --- a/README.md +++ b/README.md @@ -74,15 +74,15 @@ Reload .vimrc and `:PlugInstall` to install plugins. ### `Plug` options -| Option | Description | -| -------------- | -------------------------------------------------------------------- | -| `branch`/`tag` | Branch or tag of the repository to use | -| `rtp` | Subdirectory that contains Vim plugin | -| `dir` | Custom directory for the plugin | -| `do` | Post-update hook (string or funcref) | -| `on` | On-demand loading: Commands or ``-mappings | -| `for` | On-demand loading: File types | -| `frozen` | Do not install/update plugin unless explicitly given as the argument | +| Option | Description | +| -------------- | ------------------------------------------------ | +| `branch`/`tag` | Branch or tag of the repository to use | +| `rtp` | Subdirectory that contains Vim plugin | +| `dir` | Custom directory for the plugin | +| `do` | Post-update hook (string or funcref) | +| `on` | On-demand loading: Commands or ``-mappings | +| `for` | On-demand loading: File types | +| `frozen` | Do not update unless explicitly specified | ### Global options diff --git a/plug.vim b/plug.vim index 433a739..7842d24 100644 --- a/plug.vim +++ b/plug.vim @@ -613,6 +613,11 @@ function! s:do(pull, force, todo) endfunction function! s:finish(pull) + let new_frozen = len(filter(keys(s:update.new), 'g:plugs[v:val].frozen')) + if new_frozen + let s = new_frozen > 1 ? 's' : '' + call append(3, printf('- Installed %d frozen plugin%s', new_frozen, s)) + endif call append(3, '- Finishing ... ') redraw call plug#helptags() @@ -652,7 +657,7 @@ function! s:update_impl(pull, force, args) abort \ remove(args, -1) : get(g:, 'plug_threads', 16) let managed = filter(copy(g:plugs), 's:is_managed(v:key)') - let todo = empty(args) ? filter(managed, '!v:val.frozen') : + let todo = empty(args) ? filter(managed, '!v:val.frozen || !isdirectory(v:val.dir)') : \ filter(managed, 'index(args, v:key) >= 0') if empty(todo) diff --git a/test/workflow.vader b/test/workflow.vader index 509382f..f0f2d09 100644 --- a/test/workflow.vader +++ b/test/workflow.vader @@ -517,12 +517,37 @@ Execute (Common parent): ********************************************************************** ~ Frozen plugins ********************************************************************** +- We've decided to install plugins that are frozen: see #113 +Execute (Frozen plugin are not ~~installed nor~~ updated): + " Remove plugins + call plug#begin() + call plug#end() + PlugClean! + q -Execute (Frozen plugin are not installed nor updated): + " vim-easy-align is not found, so it will be installed even though it's frozen call plug#begin() Plug 'junegunn/vim-easy-align', { 'frozen': 1 } call plug#end() + PlugInstall + AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "vim-easy-align"')) + q + " Remove plugins again + call plug#begin() + call plug#end() + PlugClean! + q + + " PlugUpdate will do the same + call plug#begin() + Plug 'junegunn/vim-easy-align', { 'frozen': 1 } + call plug#end() + PlugInstall + AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "vim-easy-align"')) + q + + " Since vim-easy-align already exists, PlugInstall or PlugUpdate will skip it redir => out silent PlugInstall redir END