Browse Source

Implement g:plug_url_format (#62)

Junegunn Choi 11 years ago
parent
commit
ab3bd3b17c
3 changed files with 22 additions and 7 deletions
  1. 7 6
      README.md
  2. 2 1
      plug.vim
  3. 13 0
      test/workflow.vader

+ 7 - 6
README.md

@@ -84,12 +84,13 @@ Reload .vimrc and `:PlugInstall` to install plugins.
 
 ### Global options
 
-| Flag             | Default                | Description                          |
-| ---------------- | ---------------------- | ------------------------------------ |
-| `g:plug_window`  | `vertical topleft new` | Command to open plug window          |
-| `g:plug_threads` | 16                     | Default number of threads to use     |
-| `g:plug_timeout` | 60                     | Time limit of each task in seconds   |
-| `g:plug_retries` | 2                      | Number of retries in case of timeout |
+| Flag                | Default                           | Description                          |
+| ------------------- | --------------------------------- | ------------------------------------ |
+| `g:plug_threads`    | 16                                | Default number of threads to use     |
+| `g:plug_timeout`    | 60                                | Time limit of each task in seconds   |
+| `g:plug_retries`    | 2                                 | Number of retries in case of timeout |
+| `g:plug_window`     | `vertical topleft new`            | Command to open plug window          |
+| `g:plug_url_format` | 'https://git::@github.com/%s.git' | `printf` format to build repo URL    |
 
 ### Keybindings
 

+ 2 - 1
plug.vim

@@ -379,7 +379,8 @@ function! s:infer_properties(name, repo)
       if repo !~ '/'
         let repo = 'vim-scripts/'. repo
       endif
-      let uri = 'https://git::@github.com/' . repo . '.git'
+      let fmt = get(g:, 'plug_url_format', 'https://git::@github.com/%s.git')
+      let uri = printf(fmt, repo)
     endif
     let dir = s:dirpath( fnamemodify(join([g:plug_home, a:name], '/'), ':p') )
     return { 'dir': dir, 'uri': uri }

+ 13 - 0
test/workflow.vader

@@ -874,11 +874,24 @@ Execute (Open plug window in a new tab):
   AssertEqual tabnr, tabpagenr()
   q
 
+**********************************************************************
+~ g:plug_url_format
+**********************************************************************
+Execute (Using g:plug_url_format):
+  call plug#begin()
+  let g:plug_url_format = 'git@bitbucket.org:%s.git'
+  Plug 'junegunn/seoul256.vim'
+  let g:plug_url_format = 'git@bitsocket.org:%s.git'
+  Plug 'beauty256'
+  AssertEqual 'git@bitbucket.org:junegunn/seoul256.vim.git', g:plugs['seoul256.vim'].uri
+  AssertEqual 'git@bitsocket.org:vim-scripts/beauty256.git', g:plugs['beauty256'].uri
+
 Execute (Cleanup):
   silent! call system('rm -rf '.temp_plugged)
   silent! call rename('fzf', 'fzf-staged')
   silent! unlet g:plugs
   silent! unlet g:plug_home
+  silent! unlet g:plug_url_format
   silent! unlet temp_plugged vader plug basertp save_rtp repo lnum fzf out tabnr
   silent! delf PlugStatusSorted
   silent! delf AssertExpect