From 7d494b4a7bb41fb57545e3e70a9e490304516436 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Tue, 26 Jan 2016 03:01:20 +0900 Subject: [PATCH] Add 'as' option (#371) --- README.md | 1 + plug.vim | 6 +++--- test/workflow.vader | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 061d7ca..8e5b3ef 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,7 @@ Reload .vimrc and `:PlugInstall` to install plugins. | `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 | diff --git a/plug.vim b/plug.vim index 57a5100..ab1c1f7 100644 --- a/plug.vim +++ b/plug.vim @@ -450,9 +450,9 @@ function! s:add(repo, ...) try let repo = s:trim(a:repo) - let name = fnamemodify(repo, ':t:s?\.git$??') - let spec = extend(s:infer_properties(name, repo), - \ a:0 == 1 ? s:parse_options(a:1) : s:base_spec) + let opts = a:0 == 1 ? s:parse_options(a:1) : s:base_spec + let name = get(opts, 'as', fnamemodify(repo, ':t:s?\.git$??')) + let spec = extend(s:infer_properties(name, repo), opts) if !has_key(g:plugs, name) call add(g:plugs_order, name) endif diff --git a/test/workflow.vader b/test/workflow.vader index 50bf6bc..75d908e 100644 --- a/test/workflow.vader +++ b/test/workflow.vader @@ -1341,3 +1341,19 @@ Execute (Commit hash support - cleared): let hash = system(printf('cd %s && git rev-parse HEAD', g:plugs['vim-emoji'].dir))[:-2] AssertNotEqual '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a', hash q + +Execute (#371 - 'as' option): + call plug#begin() + Plug 'jg/goyo.vim' + Plug 'junegunn/goyo.vim', {'as': 'yogo'} + call plug#end() + AssertEqual ['goyo.vim', 'yogo'], sort(keys(g:plugs)) + Log g:plugs + Assert g:plugs.yogo.dir =~# '/yogo/$' + + call plug#begin() + Plug 'junegunn/goyo.vim', {'as': 'yogo', 'dir': '/tmp/gogo'} + call plug#end() + AssertEqual ['yogo'], sort(keys(g:plugs)) + AssertEqual '/tmp/gogo/', g:plugs.yogo.dir +