Merge pull request #387 from junegunn/as

Add 'as' option
This commit is contained in:
Junegunn Choi 2016-01-26 03:39:21 +09:00
commit c88ab60007
3 changed files with 20 additions and 3 deletions

View file

@ -113,6 +113,7 @@ Reload .vimrc and `:PlugInstall` to install plugins.
| `branch`/`tag`/`commit` | Branch/tag/commit of the repository to use | | `branch`/`tag`/`commit` | Branch/tag/commit of the repository to use |
| `rtp` | Subdirectory that contains Vim plugin | | `rtp` | Subdirectory that contains Vim plugin |
| `dir` | Custom directory for the plugin | | `dir` | Custom directory for the plugin |
| `as` | Use different name for the plugin |
| `do` | Post-update hook (string or funcref) | | `do` | Post-update hook (string or funcref) |
| `on` | On-demand loading: Commands or `<Plug>`-mappings | | `on` | On-demand loading: Commands or `<Plug>`-mappings |
| `for` | On-demand loading: File types | | `for` | On-demand loading: File types |

View file

@ -450,9 +450,9 @@ function! s:add(repo, ...)
try try
let repo = s:trim(a:repo) let repo = s:trim(a:repo)
let name = fnamemodify(repo, ':t:s?\.git$??') let opts = a:0 == 1 ? s:parse_options(a:1) : s:base_spec
let spec = extend(s:infer_properties(name, repo), let name = get(opts, 'as', fnamemodify(repo, ':t:s?\.git$??'))
\ a:0 == 1 ? s:parse_options(a:1) : s:base_spec) let spec = extend(s:infer_properties(name, repo), opts)
if !has_key(g:plugs, name) if !has_key(g:plugs, name)
call add(g:plugs_order, name) call add(g:plugs_order, name)
endif endif

View file

@ -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] let hash = system(printf('cd %s && git rev-parse HEAD', g:plugs['vim-emoji'].dir))[:-2]
AssertNotEqual '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a', hash AssertNotEqual '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a', hash
q 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