From f58d090bb263fdf79d0131f18df29598f7e1b77f Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Wed, 30 Jul 2014 19:20:51 +0900 Subject: [PATCH] Add `dir` option: managed plugins outside `g:plug_home` --- README.md | 1 + plug.vim | 7 +++++-- test/workflow.vader | 21 +++++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c793019..ebc8be0 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,7 @@ Reload .vimrc and `:PlugInstall` to install plugins. | -------------- | -------------------------------------------------------------------- | | `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 | diff --git a/plug.vim b/plug.vim index 051a49c..44a218a 100644 --- a/plug.vim +++ b/plug.vim @@ -319,8 +319,8 @@ function! s:add(force, repo, ...) return endif - let spec = extend(a:0 == 1 ? s:parse_options(a:1) : copy(s:base_spec), - \ s:infer_properties(name, repo)) + let spec = extend(s:infer_properties(name, repo), + \ a:0 == 1 ? s:parse_options(a:1) : copy(s:base_spec)) if !a:force let s:extended[name] = spec endif @@ -342,6 +342,9 @@ function! s:parse_options(arg) if has_key(opts, 'tag') let opts.branch = remove(opts, 'tag') endif + if has_key(opts, 'dir') + let opts.dir = s:dirpath(expand(opts.dir)) + endif else throw 'Invalid argument type (expected: string or dictionary)' endif diff --git a/test/workflow.vader b/test/workflow.vader index 405a759..1f3fffe 100644 --- a/test/workflow.vader +++ b/test/workflow.vader @@ -660,6 +660,27 @@ Execute (Using Funcref): Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclinstalled2'), \ 'vim-pseudocl/vim-pseudoclinstalled2 should exist' + +********************************************************************** +~ Overriding `dir` +********************************************************************** + +Execute (Using custom dir): + Assert isdirectory(g:plugs['vim-easy-align'].dir) + + call plug#begin() + Plug 'junegunn/vim-easy-align', { 'dir': $TMPDIR.'easy-align' } + call plug#end() + AssertEqual $TMPDIR.'easy-align/', g:plugs['vim-easy-align'].dir + + PlugClean! + Assert !isdirectory(g:plugs['vim-easy-align'].dir) + q + + PlugInstall + q + Assert isdirectory(g:plugs['vim-easy-align'].dir) + Execute (Cleanup): call system('rm -rf '.temp_plugged) call rename('fzf', 'fzf-staged')