From df9ee1e869efcfd605da5cd07535878c21f3226a Mon Sep 17 00:00:00 2001 From: Robert Perce Date: Wed, 16 Mar 2016 20:43:40 -0500 Subject: [PATCH] Added 'via' option, to allow to switch between https and ssh --- plug.vim | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plug.vim b/plug.vim index 9cb02f7..bdad07e 100644 --- a/plug.vim +++ b/plug.vim @@ -54,6 +54,7 @@ "| `on` | On-demand loading: Commands or ``-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') )