From d977fa37866a48f1001b5adaadbbdbf88baf35e8 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 31 Mar 2024 00:53:55 +0900 Subject: [PATCH] Do not remove 'frozen' plugins on PlugClean Close #1152 --- README.md | 22 +++++++++++----------- doc/plug.txt | 10 +++++----- plug.vim | 2 +- test/workflow.vader | 8 ++++++++ 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 30fe3b8..8cb6966 100644 --- a/README.md +++ b/README.md @@ -234,7 +234,7 @@ More examples can be found in: | ----------------------------------- | ------------------------------------------------------------------ | | `PlugInstall [name ...] [#threads]` | Install plugins | | `PlugUpdate [name ...] [#threads]` | Install or update plugins | -| `PlugClean[!]` | Remove unlisted plugins (bang version will clean without prompt) | +| `PlugClean[!]` | Remove unlisted plugins (bang version will clean without prompt) | | `PlugUpgrade` | Upgrade vim-plug itself | | `PlugStatus` | Check the status of plugins | | `PlugDiff` | Examine changes from the previous update and the pending changes | @@ -242,16 +242,16 @@ More examples can be found in: ### `Plug` options -| Option | Description | -| ----------------------- | ------------------------------------------------ | -| `branch`/`tag`/`commit` | Branch/tag/commit of the repository to use | -| `rtp` | Subdirectory that contains Vim plugin | -| `dir` | Custom directory for the plugin | -| `as` | Use different name 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 | +| Option | Description | +| ----------------------- | ----------------------------------------------------------- | +| `branch`/`tag`/`commit` | Branch/tag/commit of the repository to use | +| `rtp` | Subdirectory that contains Vim plugin | +| `dir` | Custom directory for the plugin | +| `as` | Use different name 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 remove and do not update unless explicitly specified | ### Global options diff --git a/doc/plug.txt b/doc/plug.txt index 9733404..23c96f4 100644 --- a/doc/plug.txt +++ b/doc/plug.txt @@ -1,4 +1,4 @@ -plug.txt plug Last change: March 14 2024 +plug.txt plug Last change: March 31 2024 PLUG - TABLE OF CONTENTS *plug* *plug-toc* ============================================================================== @@ -188,9 +188,9 @@ More examples can be found in: *-mappings* - ------------------------+----------------------------------------------- + ------------------------+------------------------------------------------------------ Option | Description ~ - ------------------------+----------------------------------------------- + ------------------------+------------------------------------------------------------ `branch` / `tag` / `commit` | Branch/tag/commit of the repository to use `rtp` | Subdirectory that contains Vim plugin `dir` | Custom directory for the plugin @@ -198,8 +198,8 @@ More examples can be found in: `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 - ------------------------+----------------------------------------------- + `frozen` | Do not remove and do not update unless explicitly specified + ------------------------+------------------------------------------------------------ < Global options >____________________________________________________________~ diff --git a/plug.vim b/plug.vim index 723f908..940811a 100644 --- a/plug.vim +++ b/plug.vim @@ -2435,7 +2435,7 @@ function! s:clean(force) let errs = {} let [cnt, total] = [0, len(g:plugs)] for [name, spec] in items(g:plugs) - if !s:is_managed(name) + if !s:is_managed(name) || get(spec, 'frozen', 0) call add(dirs, spec.dir) else let [err, clean] = s:git_validate(spec, 1) diff --git a/test/workflow.vader b/test/workflow.vader index 83d075e..aa40ca6 100644 --- a/test/workflow.vader +++ b/test/workflow.vader @@ -804,6 +804,14 @@ Execute (Check &rtp after SomeCommand): AssertEqual g:first_rtp, split(&rtp, ',')[0] AssertEqual g:last_rtp, split(&rtp, ',')[-1] +Execute (PlugClean should not care about frozen plugins): + call plug#begin() + Plug 'xxx/vim-easy-align', { 'frozen': 1 } + call plug#end() + PlugClean + AssertExpect 'Already clean', 1 + q + Execute (Common parent): call plug#begin() Plug 'junegunn/vim-pseudocl'