فهرست منبع

Add 'as' option (#371)

Junegunn Choi 10 سال پیش
والد
کامیت
7d494b4a7b
3فایلهای تغییر یافته به همراه20 افزوده شده و 3 حذف شده
  1. 1 0
      README.md
  2. 3 3
      plug.vim
  3. 16 0
      test/workflow.vader

+ 1 - 0
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 `<Plug>`-mappings |
 | `for`                   | On-demand loading: File types                    |

+ 3 - 3
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

+ 16 - 0
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
+