16 Commits
0.5.4 ... 0.5.6

Author SHA1 Message Date
Junegunn Choi
99f6f36b69 Do not print 'D'-message when there was no update (#66)
This commit assumes that the git pull command prints 'Already
up-to-date' when the repository is up-to-date. Let's just hope that it
doesn't change in the future.
2014-09-04 14:10:33 +09:00
Junegunn Choi
3f82808bea Use blackhole register when deleting commit list 2014-09-04 14:09:06 +09:00
Junegunn Choi
7474edf13f Remove unnecessary dot-concatenations
Thanks to @vheon for the tip.
2014-09-04 01:48:27 +09:00
Junegunn Choi
25b0fb7583 Merge pull request #65 from vheon/fix-preview-commit
[PlugDiff] Change directory after wincmd to avoid side-effects on BufEnter/BufLeave
2014-09-04 01:29:57 +09:00
Andrea Cedraro
a868ee4c11 cd to repo root when in preview window on preview commit 2014-09-03 08:47:01 +02:00
Junegunn Choi
49851436ff Use --no-rebase option on git pull (#64) 2014-09-03 02:14:54 +09:00
Junegunn Choi
2f9a94e8c0 Update README 2014-08-26 01:39:12 +09:00
Junegunn Choi
ab3bd3b17c Implement g:plug_url_format (#62) 2014-08-26 01:36:50 +09:00
Junegunn Choi
3572ffde79 Add g:plug_window to README (#57) 2014-08-20 12:38:22 +09:00
Junegunn Choi
18c8b54793 Add test case for g:plug_window (#57) 2014-08-20 12:33:37 +09:00
Junegunn Choi
1752de5b7c Fix indentation 2014-08-20 12:33:37 +09:00
Miles Whittaker
2f3225fc60 User can now specify how plug window opens
Using 'let g:plug_window = "topleft new"' or something similar, the
user can specify how they would like the plug window to open.
2014-08-20 12:33:37 +09:00
Junegunn Choi
1022acad0b Add example for on-demand loading for multiple file types (#59) 2014-08-20 01:27:55 +09:00
Junegunn Choi
68c7fbbf9d Change raw.github.com url (#58)
https://developer.github.com/changes/2014-04-25-user-content-security/
2014-08-19 20:46:27 +09:00
Junegunn Choi
da24f714e0 Use git:: prefix to avoid password prompt on git 1.7 (#56) 2014-08-14 10:04:44 +09:00
Junegunn Choi
c1bbbaf3ef Allow Plug command even when git executable is not found (#52)
- plug#begin() will return 1 even when git executable is not found
    - Commands that require git will not be available
- If you wish to ignore the error message prepend `silent!` to the call
2014-08-11 01:42:19 +09:00
3 changed files with 106 additions and 57 deletions

View File

@@ -1,15 +1,15 @@
![vim-plug](https://raw.github.com/junegunn/vim-plug/master/plug.png)
![vim-plug](https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.png)
![travis-ci](https://travis-ci.org/junegunn/vim-plug.svg?branch=master)
A minimalist Vim plugin manager.
![](https://raw.github.com/junegunn/i/master/vim-plug/installer.gif)
![](https://raw.githubusercontent.com/junegunn/i/master/vim-plug/installer.gif)
### Pros.
- Easier to setup: Single file. No boilerplate code required.
- Easier to use: Concise, intuitive syntax
- [Super-fast](https://raw.github.com/junegunn/i/master/vim-plug/40-in-4.gif)
- [Super-fast](https://raw.githubusercontent.com/junegunn/i/master/vim-plug/40-in-4.gif)
parallel installation/update (requires
[+ruby](https://github.com/junegunn/vim-plug/wiki/ruby))
- On-demand loading to achieve
@@ -20,13 +20,13 @@ A minimalist Vim plugin manager.
### Usage
[Download plug.vim](https://raw.github.com/junegunn/vim-plug/master/plug.vim)
[Download plug.vim](https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim)
and put it in ~/.vim/autoload
```sh
mkdir -p ~/.vim/autoload
curl -fLo ~/.vim/autoload/plug.vim \
https://raw.github.com/junegunn/vim-plug/master/plug.vim
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
```
Edit your .vimrc
@@ -82,13 +82,15 @@ Reload .vimrc and `:PlugInstall` to install plugins.
| `for` | On-demand loading: File types |
| `frozen` | Do not install/update plugin unless explicitly given as the argument |
### Options for parallel installer
### Global options
| 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
@@ -121,6 +123,9 @@ Plug 'junegunn/vim-github-dashboard', { 'on': ['GHDashboard', 'GHActivity'] }
" Loaded when clojure file is opened
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
" Multiple file types
Plug 'kovisoft/paredit', { 'for': ['clojure', 'scheme'] }
" On-demand loading on both conditions
Plug 'junegunn/vader.vim', { 'on': 'Vader', 'for': 'vader' }
```

View File

@@ -5,7 +5,7 @@
"
" mkdir -p ~/.vim/autoload
" curl -fLo ~/.vim/autoload/plug.vim \
" https://raw.github.com/junegunn/vim-plug/master/plug.vim
" https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
"
" Edit your .vimrc
"
@@ -68,7 +68,7 @@ let g:loaded_plug = 1
let s:cpo_save = &cpo
set cpo&vim
let s:plug_source = 'https://raw.github.com/junegunn/vim-plug/master/plug.vim'
let s:plug_source = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
let s:plug_buf = get(s:, 'plug_buf', -1)
let s:mac_gui = has('gui_macvim') && has('gui_running')
let s:is_win = has('win32') || has('win64')
@@ -93,10 +93,6 @@ function! plug#begin(...)
return s:err('Unable to determine plug home. Try calling plug#begin() with a path argument.')
endif
if !executable('git')
return s:err('`git` executable not found. vim-plug requires git.')
endif
let g:plug_home = home
let g:plugs = {}
" we want to keep track of the order plugins where registered.
@@ -108,10 +104,13 @@ endfunction
function! s:define_commands()
command! -nargs=+ -bar Plug call s:add(<args>)
if !executable('git')
return s:err('`git` executable not found. vim-plug requires git.')
endif
command! -nargs=* -bar -bang -complete=customlist,s:names PlugInstall call s:install('<bang>' == '!', <f-args>)
command! -nargs=* -bar -bang -complete=customlist,s:names PlugUpdate call s:update('<bang>' == '!', <f-args>)
command! -nargs=0 -bar -bang PlugClean call s:clean('<bang>' == '!')
command! -nargs=0 -bar PlugUpgrade if s:upgrade() | execute 'source '. s:me | endif
command! -nargs=0 -bar PlugUpgrade if s:upgrade() | execute 'source' s:me | endif
command! -nargs=0 -bar PlugStatus call s:status()
command! -nargs=0 -bar PlugDiff call s:diff()
endfunction
@@ -123,7 +122,7 @@ endfunction
function! s:source(from, ...)
for pattern in a:000
for vim in split(globpath(a:from, pattern), '\n')
execute 'source '.vim
execute 'source' vim
endfor
endfor
endfunction
@@ -304,21 +303,21 @@ function! s:lod_ft(pat, names)
call s:lod(g:plugs[name], ['plugin', 'after/plugin'])
endfor
call s:reorg_rtp()
execute 'autocmd! PlugLOD FileType ' . a:pat
execute 'autocmd! PlugLOD FileType' a:pat
silent! doautocmd filetypeplugin FileType
silent! doautocmd filetypeindent FileType
endfunction
function! s:lod_cmd(cmd, bang, l1, l2, args, name)
execute 'delc '.a:cmd
execute 'delc' a:cmd
call s:lod(g:plugs[a:name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
call s:reorg_rtp()
execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args)
endfunction
function! s:lod_map(map, name, prefix)
execute 'unmap '.a:map
execute 'iunmap '.a:map
execute 'unmap' a:map
execute 'iunmap' a:map
call s:lod(g:plugs[a:name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
call s:reorg_rtp()
let extra = ''
@@ -380,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 }
@@ -402,7 +402,7 @@ function! plug#helptags()
for spec in values(g:plugs)
let docd = join([spec.dir, 'doc'], '/')
if isdirectory(docd)
silent! execute 'helptags '. s:esc(docd)
silent! execute 'helptags' s:esc(docd)
endif
endfor
return 1
@@ -459,19 +459,23 @@ function! s:lastline(msg)
return get(lines, -1, '')
endfunction
function! s:new_window()
execute get(g:, 'plug_window', 'vertical topleft new')
endfunction
function! s:prepare()
if bufexists(s:plug_buf)
let winnr = bufwinnr(s:plug_buf)
if winnr < 0
vertical topleft new
execute 'buffer ' . s:plug_buf
call s:new_window()
execute 'buffer' s:plug_buf
else
execute winnr . 'wincmd w'
endif
setlocal modifiable
silent %d _
else
vertical topleft new
call s:new_window()
nnoremap <silent> <buffer> q :if b:plug_preview==1<bar>pc<bar>endif<bar>q<cr>
nnoremap <silent> <buffer> R :silent! call <SID>retry()<cr>
nnoremap <silent> <buffer> D :PlugDiff<cr>
@@ -499,7 +503,7 @@ function! s:assign_name()
let name = printf('%s (%s)', prefix, idx)
let idx = idx + 1
endwhile
silent! execute 'f '.fnameescape(name)
silent! execute 'f' fnameescape(name)
endfunction
function! s:do(pull, force, todo)
@@ -507,7 +511,7 @@ function! s:do(pull, force, todo)
if !isdirectory(spec.dir)
continue
endif
execute 'cd '.s:esc(spec.dir)
execute 'cd' s:esc(spec.dir)
let installed = has_key(s:prev_update.new, name)
let updated = installed ? 0 :
\ (a:pull && !empty(s:system_chomp('git log --pretty=format:"%h" "HEAD...HEAD@{1}"')))
@@ -554,7 +558,8 @@ function! s:finish(pull)
if !empty(s:prev_update.errors)
call add(msgs, "Press 'R' to retry.")
endif
if a:pull
if a:pull && !empty(filter(getline(5, '$'),
\ "v:val =~ '^- ' && stridx(v:val, 'Already up-to-date') < 0"))
call add(msgs, "Press 'D' to see the updated changes.")
endif
echo join(msgs, ' ')
@@ -661,12 +666,12 @@ function! s:update_serial(pull, todo)
for [name, spec] in items(todo)
let done[name] = 1
if isdirectory(spec.dir)
execute 'cd '.s:esc(spec.dir)
execute 'cd' s:esc(spec.dir)
let [valid, msg] = s:git_valid(spec, 0, 0)
if valid
let result = a:pull ?
\ s:system(
\ printf('git checkout -q %s 2>&1 && git pull origin %s 2>&1 && git submodule update --init --recursive 2>&1',
\ printf('git checkout -q %s 2>&1 && git pull --no-rebase origin %s 2>&1 && git submodule update --init --recursive 2>&1',
\ s:shellesc(spec.branch), s:shellesc(spec.branch))) : 'Already installed'
let error = a:pull ? v:shell_error != 0 : 0
else
@@ -871,14 +876,14 @@ function! s:update_parallel(pull, todo, threads)
else
[false, [data.chomp, "PlugClean required."].join($/)]
end
elsif current_uri.sub(/git:@/, '') != uri.sub(/git:@/, '')
elsif current_uri.sub(/git::?@/, '') != uri.sub(/git::?@/, '')
[false, ["Invalid URI: #{current_uri}",
"Expected: #{uri}",
"PlugClean required."].join($/)]
else
if pull
log.call name, 'Updating ...', :update
bt.call "#{cd} #{dir} && git checkout -q #{branch} 2>&1 && (git pull origin #{branch} #{progress} 2>&1 && #{subm})", name, :update
bt.call "#{cd} #{dir} && git checkout -q #{branch} 2>&1 && (git pull --no-rebase origin #{branch} #{progress} 2>&1 && #{subm})", name, :update
else
[true, skip]
end
@@ -914,8 +919,8 @@ function! s:progress_bar(line, bar, total)
endfunction
function! s:compare_git_uri(a, b)
let a = substitute(a:a, 'git:@', '', '')
let b = substitute(a:b, 'git:@', '', '')
let a = substitute(a:a, 'git:\{1,2}@', '', '')
let b = substitute(a:b, 'git:\{1,2}@', '', '')
return a ==# b
endfunction
@@ -941,7 +946,7 @@ function! s:git_valid(spec, check_branch, cd)
let ret = 1
let msg = 'OK'
if isdirectory(a:spec.dir)
if a:cd | execute 'cd ' . s:esc(a:spec.dir) | endif
if a:cd | execute 'cd' s:esc(a:spec.dir) | endif
let result = split(s:system('git rev-parse --abbrev-ref HEAD 2>&1 && git config remote.origin.url'), '\n')
let remote = result[-1]
if v:shell_error
@@ -1172,14 +1177,14 @@ function! s:preview_commit()
return
endif
execute 'cd '.s:esc(g:plugs[name].dir)
execute 'pedit '.sha
execute 'pedit' sha
wincmd P
setlocal filetype=git buftype=nofile nobuflisted
execute 'silent read !git show '.sha
normal! ggdd
wincmd p
execute 'cd' s:esc(g:plugs[name].dir)
execute 'silent read !git show' sha
cd -
normal! gg"_dd
wincmd p
endfunction
function! s:section(flags)
@@ -1198,7 +1203,7 @@ function! s:diff()
continue
endif
execute 'cd '.s:esc(v.dir)
execute 'cd' s:esc(v.dir)
let diff = system('git log --pretty=format:"%h %s (%cr)" "HEAD...HEAD@{1}"')
if !v:shell_error && !empty(diff)
call append(1, '')
@@ -1228,11 +1233,11 @@ function! s:revert()
return
endif
execute 'cd '.s:esc(g:plugs[name].dir)
execute 'cd' s:esc(g:plugs[name].dir)
call system('git reset --hard HEAD@{1} && git checkout '.s:esc(g:plugs[name].branch))
cd -
setlocal modifiable
normal! dap
normal! "_dap
setlocal nomodifiable
echo 'Reverted.'
endfunction

View File

@@ -1,5 +1,5 @@
Execute (Initialize test environment):
Save &rtp, g:plugs, g:plug_home
Save &rtp, g:plugs, g:plug_home, g:plug_window
let first_rtp = split(&rtp, ',')[0]
let last_rtp = split(&rtp, ',')[-1]
@@ -11,8 +11,7 @@ Execute (Initialize test environment):
execute 'set rtp^='.plug
let basertp = &rtp
unlet! g:plugs
unlet! g:plug_home
unlet! g:plugs g:plug_home g:plug_window
set t_Co=256
colo default
@@ -75,7 +74,7 @@ Execute (Subsequent plug#begin() calls will reuse g:plug_home):
Execute (Test Plug command):
" Git repo with branch
Plug 'junegunn/seoul256.vim', 'yes-t_co'
AssertEqual 'https://git:@github.com/junegunn/seoul256.vim.git', g:plugs['seoul256.vim'].uri
AssertEqual 'https://git::@github.com/junegunn/seoul256.vim.git', g:plugs['seoul256.vim'].uri
AssertEqual join([temp_plugged, 'seoul256.vim/'], '/'), g:plugs['seoul256.vim'].dir
AssertEqual 'yes-t_co', g:plugs['seoul256.vim'].branch
@@ -84,7 +83,7 @@ Execute (Test Plug command):
" Git repo with tag
Plug 'junegunn/goyo.vim', '1.5.2'
AssertEqual 'https://git:@github.com/junegunn/goyo.vim.git', g:plugs['goyo.vim'].uri
AssertEqual 'https://git::@github.com/junegunn/goyo.vim.git', g:plugs['goyo.vim'].uri
AssertEqual join([temp_plugged, 'goyo.vim/'], '/'), g:plugs['goyo.vim'].dir
AssertEqual '1.5.2', g:plugs['goyo.vim'].branch
@@ -99,7 +98,7 @@ Execute (Test Plug command):
" vim-scripts/
Plug 'beauty256'
AssertEqual 'https://git:@github.com/vim-scripts/beauty256.git', g:plugs.beauty256.uri
AssertEqual 'https://git::@github.com/vim-scripts/beauty256.git', g:plugs.beauty256.uri
AssertEqual 'master', g:plugs.beauty256.branch
AssertEqual 4, len(g:plugs)
@@ -199,8 +198,8 @@ Execute (PlugStatus):
call PlugStatusSorted()
Expect:
Expected: https://git:@github.com/junegunn.choi/seoul256.vim.git
Invalid URI: https://git:@github.com/junegunn/seoul256.vim.git
Expected: https://git::@github.com/junegunn.choi/seoul256.vim.git
Invalid URI: https://git::@github.com/junegunn/seoul256.vim.git
PlugClean required.
- vim-emoji: OK
Finished. 1 error(s).
@@ -233,7 +232,7 @@ Execute (PlugStatus):
call PlugStatusSorted()
Expect:
Expected: https://git:@github.com/junegunn/vim-emoji.git
Expected: https://git::@github.com/junegunn/vim-emoji.git
Invalid URI: https://bitbucket.org/junegunn/vim-emoji.git
Not found. Try PlugInstall.
PlugClean required.
@@ -848,12 +847,52 @@ Execute (Load plugin from PlugStatus screen with L key in visual mode):
Assert exists('g:z2'), 'z2 loaded'
q
**********************************************************************
~ g:plug_window
**********************************************************************
Execute (Open plug window in a new tab):
" Without g:plug_window, plug window is open on the left split
let tabnr = tabpagenr()
PlugStatus
AssertEqual tabnr, tabpagenr()
AssertEqual 1, winnr()
" PlugStatus again inside the window should not change the view
normal S
AssertEqual tabnr, tabpagenr()
AssertEqual 1, winnr()
q
" Define g:plug_window so that plug window is open in a new tab
let g:plug_window = 'tabnew'
PlugStatus
AssertNotEqual tabnr, tabpagenr()
" PlugStatus again inside the window should not change the view
let tabnr = tabpagenr()
normal S
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 temp_plugged vader plug basertp save_rtp repo lnum fzf out
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
silent! delf PlugUpdated