mirror of
https://github.com/junegunn/vim-plug.git
synced 2024-12-19 18:47:29 -07:00
Added 'via' option, to allow to switch between https and ssh
This commit is contained in:
parent
820cc63569
commit
df9ee1e869
12
plug.vim
12
plug.vim
@ -54,6 +54,7 @@
|
||||
"| `on` | On-demand loading: Commands or `<Plug>`-mappings |
|
||||
"| `for` | On-demand loading: File types |
|
||||
"| `frozen` | Do not update unless explicitly specified |
|
||||
"| `via` | Use either https or ssh to clone |
|
||||
"
|
||||
" More information: https://github.com/junegunn/vim-plug
|
||||
"
|
||||
@ -484,7 +485,7 @@ function! s:Plug(repo, ...)
|
||||
let repo = s:trim(a:repo)
|
||||
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)
|
||||
let spec = extend(s:infer_properties(name, repo, opts), opts)
|
||||
if !has_key(g:plugs, name)
|
||||
call add(g:plugs_order, name)
|
||||
endif
|
||||
@ -511,8 +512,9 @@ function! s:parse_options(arg)
|
||||
return opts
|
||||
endfunction
|
||||
|
||||
function! s:infer_properties(name, repo)
|
||||
function! s:infer_properties(name, repo, opts)
|
||||
let repo = a:repo
|
||||
let opts = a:opts
|
||||
if s:is_local_plug(repo)
|
||||
return { 'dir': s:dirpath(expand(repo)) }
|
||||
else
|
||||
@ -522,7 +524,11 @@ function! s:infer_properties(name, repo)
|
||||
if repo !~ '/'
|
||||
let repo = 'vim-scripts/'. repo
|
||||
endif
|
||||
let fmt = get(g:, 'plug_url_format', 'https://git::@github.com/%s.git')
|
||||
let default = 'https://git::@github.com/%s.git'
|
||||
if has_key(opts, 'via') && opts.via ==# 'ssh'
|
||||
let default = 'git@github.com:%s.git'
|
||||
endif
|
||||
let fmt = get(g:, 'plug_url_format', default)
|
||||
let uri = printf(fmt, repo)
|
||||
endif
|
||||
let dir = s:dirpath( fnamemodify(join([g:plug_home, a:name], '/'), ':p') )
|
||||
|
Loading…
Reference in New Issue
Block a user