Browse Source

Install frozen plugin if it's not found (#113)

Junegunn Choi 11 years ago
parent
commit
bd2cb9d2de
3 changed files with 41 additions and 11 deletions
  1. 9 9
      README.md
  2. 6 1
      plug.vim
  3. 26 1
      test/workflow.vader

+ 9 - 9
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 `<Plug>`-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 `<Plug>`-mappings |
+| `for`          | On-demand loading: File types                    |
+| `frozen`       | Do not update unless explicitly specified        |
 
 ### Global options
 

+ 6 - 1
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)

+ 26 - 1
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