14 Commits
0.5.5 ... 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
3 changed files with 93 additions and 43 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) ![travis-ci](https://travis-ci.org/junegunn/vim-plug.svg?branch=master)
A minimalist Vim plugin manager. 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. ### Pros.
- Easier to setup: Single file. No boilerplate code required. - Easier to setup: Single file. No boilerplate code required.
- Easier to use: Concise, intuitive syntax - 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 parallel installation/update (requires
[+ruby](https://github.com/junegunn/vim-plug/wiki/ruby)) [+ruby](https://github.com/junegunn/vim-plug/wiki/ruby))
- On-demand loading to achieve - On-demand loading to achieve
@@ -20,13 +20,13 @@ A minimalist Vim plugin manager.
### Usage ### 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 and put it in ~/.vim/autoload
```sh ```sh
mkdir -p ~/.vim/autoload mkdir -p ~/.vim/autoload
curl -fLo ~/.vim/autoload/plug.vim \ 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 Edit your .vimrc
@@ -82,13 +82,15 @@ Reload .vimrc and `:PlugInstall` to install plugins.
| `for` | On-demand loading: File types | | `for` | On-demand loading: File types |
| `frozen` | Do not install/update plugin unless explicitly given as the argument | | `frozen` | Do not install/update plugin unless explicitly given as the argument |
### Options for parallel installer ### Global options
| Flag | Default | Description | | Flag | Default | Description |
| ---------------- | ------- | ------------------------------------ | | ------------------- | --------------------------------- | ------------------------------------ |
| `g:plug_threads` | 16 | Default number of threads to use | | `g:plug_threads` | 16 | Default number of threads to use |
| `g:plug_timeout` | 60 | Time limit of each task in seconds | | `g:plug_timeout` | 60 | Time limit of each task in seconds |
| `g:plug_retries` | 2 | Number of retries in case of timeout | | `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 ### Keybindings
@@ -121,6 +123,9 @@ Plug 'junegunn/vim-github-dashboard', { 'on': ['GHDashboard', 'GHActivity'] }
" Loaded when clojure file is opened " Loaded when clojure file is opened
Plug 'tpope/vim-fireplace', { 'for': 'clojure' } Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
" Multiple file types
Plug 'kovisoft/paredit', { 'for': ['clojure', 'scheme'] }
" On-demand loading on both conditions " On-demand loading on both conditions
Plug 'junegunn/vader.vim', { 'on': 'Vader', 'for': 'vader' } Plug 'junegunn/vader.vim', { 'on': 'Vader', 'for': 'vader' }
``` ```

View File

@@ -5,7 +5,7 @@
" "
" mkdir -p ~/.vim/autoload " mkdir -p ~/.vim/autoload
" curl -fLo ~/.vim/autoload/plug.vim \ " 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 " Edit your .vimrc
" "
@@ -68,7 +68,7 @@ let g:loaded_plug = 1
let s:cpo_save = &cpo let s:cpo_save = &cpo
set cpo&vim 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:plug_buf = get(s:, 'plug_buf', -1)
let s:mac_gui = has('gui_macvim') && has('gui_running') let s:mac_gui = has('gui_macvim') && has('gui_running')
let s:is_win = has('win32') || has('win64') let s:is_win = has('win32') || has('win64')
@@ -110,7 +110,7 @@ function! s:define_commands()
command! -nargs=* -bar -bang -complete=customlist,s:names PlugInstall call s:install('<bang>' == '!', <f-args>) 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=* -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 -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 PlugStatus call s:status()
command! -nargs=0 -bar PlugDiff call s:diff() command! -nargs=0 -bar PlugDiff call s:diff()
endfunction endfunction
@@ -122,7 +122,7 @@ endfunction
function! s:source(from, ...) function! s:source(from, ...)
for pattern in a:000 for pattern in a:000
for vim in split(globpath(a:from, pattern), '\n') for vim in split(globpath(a:from, pattern), '\n')
execute 'source '.vim execute 'source' vim
endfor endfor
endfor endfor
endfunction endfunction
@@ -303,21 +303,21 @@ function! s:lod_ft(pat, names)
call s:lod(g:plugs[name], ['plugin', 'after/plugin']) call s:lod(g:plugs[name], ['plugin', 'after/plugin'])
endfor endfor
call s:reorg_rtp() call s:reorg_rtp()
execute 'autocmd! PlugLOD FileType ' . a:pat execute 'autocmd! PlugLOD FileType' a:pat
silent! doautocmd filetypeplugin FileType silent! doautocmd filetypeplugin FileType
silent! doautocmd filetypeindent FileType silent! doautocmd filetypeindent FileType
endfunction endfunction
function! s:lod_cmd(cmd, bang, l1, l2, args, name) 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:lod(g:plugs[a:name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
call s:reorg_rtp() call s:reorg_rtp()
execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args) execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args)
endfunction endfunction
function! s:lod_map(map, name, prefix) function! s:lod_map(map, name, prefix)
execute 'unmap '.a:map execute 'unmap' a:map
execute 'iunmap '.a:map execute 'iunmap' a:map
call s:lod(g:plugs[a:name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) call s:lod(g:plugs[a:name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
call s:reorg_rtp() call s:reorg_rtp()
let extra = '' let extra = ''
@@ -379,7 +379,8 @@ function! s:infer_properties(name, repo)
if repo !~ '/' if repo !~ '/'
let repo = 'vim-scripts/'. repo let repo = 'vim-scripts/'. repo
endif 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 endif
let dir = s:dirpath( fnamemodify(join([g:plug_home, a:name], '/'), ':p') ) let dir = s:dirpath( fnamemodify(join([g:plug_home, a:name], '/'), ':p') )
return { 'dir': dir, 'uri': uri } return { 'dir': dir, 'uri': uri }
@@ -401,7 +402,7 @@ function! plug#helptags()
for spec in values(g:plugs) for spec in values(g:plugs)
let docd = join([spec.dir, 'doc'], '/') let docd = join([spec.dir, 'doc'], '/')
if isdirectory(docd) if isdirectory(docd)
silent! execute 'helptags '. s:esc(docd) silent! execute 'helptags' s:esc(docd)
endif endif
endfor endfor
return 1 return 1
@@ -458,19 +459,23 @@ function! s:lastline(msg)
return get(lines, -1, '') return get(lines, -1, '')
endfunction endfunction
function! s:new_window()
execute get(g:, 'plug_window', 'vertical topleft new')
endfunction
function! s:prepare() function! s:prepare()
if bufexists(s:plug_buf) if bufexists(s:plug_buf)
let winnr = bufwinnr(s:plug_buf) let winnr = bufwinnr(s:plug_buf)
if winnr < 0 if winnr < 0
vertical topleft new call s:new_window()
execute 'buffer ' . s:plug_buf execute 'buffer' s:plug_buf
else else
execute winnr . 'wincmd w' execute winnr . 'wincmd w'
endif endif
setlocal modifiable setlocal modifiable
silent %d _ silent %d _
else 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> 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> R :silent! call <SID>retry()<cr>
nnoremap <silent> <buffer> D :PlugDiff<cr> nnoremap <silent> <buffer> D :PlugDiff<cr>
@@ -498,7 +503,7 @@ function! s:assign_name()
let name = printf('%s (%s)', prefix, idx) let name = printf('%s (%s)', prefix, idx)
let idx = idx + 1 let idx = idx + 1
endwhile endwhile
silent! execute 'f '.fnameescape(name) silent! execute 'f' fnameescape(name)
endfunction endfunction
function! s:do(pull, force, todo) function! s:do(pull, force, todo)
@@ -506,7 +511,7 @@ function! s:do(pull, force, todo)
if !isdirectory(spec.dir) if !isdirectory(spec.dir)
continue continue
endif endif
execute 'cd '.s:esc(spec.dir) execute 'cd' s:esc(spec.dir)
let installed = has_key(s:prev_update.new, name) let installed = has_key(s:prev_update.new, name)
let updated = installed ? 0 : let updated = installed ? 0 :
\ (a:pull && !empty(s:system_chomp('git log --pretty=format:"%h" "HEAD...HEAD@{1}"'))) \ (a:pull && !empty(s:system_chomp('git log --pretty=format:"%h" "HEAD...HEAD@{1}"')))
@@ -553,7 +558,8 @@ function! s:finish(pull)
if !empty(s:prev_update.errors) if !empty(s:prev_update.errors)
call add(msgs, "Press 'R' to retry.") call add(msgs, "Press 'R' to retry.")
endif 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.") call add(msgs, "Press 'D' to see the updated changes.")
endif endif
echo join(msgs, ' ') echo join(msgs, ' ')
@@ -660,12 +666,12 @@ function! s:update_serial(pull, todo)
for [name, spec] in items(todo) for [name, spec] in items(todo)
let done[name] = 1 let done[name] = 1
if isdirectory(spec.dir) 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) let [valid, msg] = s:git_valid(spec, 0, 0)
if valid if valid
let result = a:pull ? let result = a:pull ?
\ s:system( \ 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' \ s:shellesc(spec.branch), s:shellesc(spec.branch))) : 'Already installed'
let error = a:pull ? v:shell_error != 0 : 0 let error = a:pull ? v:shell_error != 0 : 0
else else
@@ -877,7 +883,7 @@ function! s:update_parallel(pull, todo, threads)
else else
if pull if pull
log.call name, 'Updating ...', :update 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 else
[true, skip] [true, skip]
end end
@@ -940,7 +946,7 @@ function! s:git_valid(spec, check_branch, cd)
let ret = 1 let ret = 1
let msg = 'OK' let msg = 'OK'
if isdirectory(a:spec.dir) 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 result = split(s:system('git rev-parse --abbrev-ref HEAD 2>&1 && git config remote.origin.url'), '\n')
let remote = result[-1] let remote = result[-1]
if v:shell_error if v:shell_error
@@ -1171,14 +1177,14 @@ function! s:preview_commit()
return return
endif endif
execute 'cd '.s:esc(g:plugs[name].dir) execute 'pedit' sha
execute 'pedit '.sha
wincmd P wincmd P
setlocal filetype=git buftype=nofile nobuflisted setlocal filetype=git buftype=nofile nobuflisted
execute 'silent read !git show '.sha execute 'cd' s:esc(g:plugs[name].dir)
normal! ggdd execute 'silent read !git show' sha
wincmd p
cd - cd -
normal! gg"_dd
wincmd p
endfunction endfunction
function! s:section(flags) function! s:section(flags)
@@ -1197,7 +1203,7 @@ function! s:diff()
continue continue
endif 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}"') let diff = system('git log --pretty=format:"%h %s (%cr)" "HEAD...HEAD@{1}"')
if !v:shell_error && !empty(diff) if !v:shell_error && !empty(diff)
call append(1, '') call append(1, '')
@@ -1227,11 +1233,11 @@ function! s:revert()
return return
endif 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)) call system('git reset --hard HEAD@{1} && git checkout '.s:esc(g:plugs[name].branch))
cd - cd -
setlocal modifiable setlocal modifiable
normal! dap normal! "_dap
setlocal nomodifiable setlocal nomodifiable
echo 'Reverted.' echo 'Reverted.'
endfunction endfunction

View File

@@ -1,5 +1,5 @@
Execute (Initialize test environment): 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 first_rtp = split(&rtp, ',')[0]
let last_rtp = split(&rtp, ',')[-1] let last_rtp = split(&rtp, ',')[-1]
@@ -11,8 +11,7 @@ Execute (Initialize test environment):
execute 'set rtp^='.plug execute 'set rtp^='.plug
let basertp = &rtp let basertp = &rtp
unlet! g:plugs unlet! g:plugs g:plug_home g:plug_window
unlet! g:plug_home
set t_Co=256 set t_Co=256
colo default colo default
@@ -848,12 +847,52 @@ Execute (Load plugin from PlugStatus screen with L key in visual mode):
Assert exists('g:z2'), 'z2 loaded' Assert exists('g:z2'), 'z2 loaded'
q 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): Execute (Cleanup):
silent! call system('rm -rf '.temp_plugged) silent! call system('rm -rf '.temp_plugged)
silent! call rename('fzf', 'fzf-staged') silent! call rename('fzf', 'fzf-staged')
silent! unlet g:plugs silent! unlet g:plugs
silent! unlet g:plug_home 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 PlugStatusSorted
silent! delf AssertExpect silent! delf AssertExpect
silent! delf PlugUpdated silent! delf PlugUpdated