mirror of
https://github.com/junegunn/vim-plug.git
synced 2025-12-12 11:51:49 +08:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
93628b1c3d | ||
|
|
01e126469b | ||
|
|
a7477f04b7 | ||
|
|
0fdb56ba72 | ||
|
|
d89949f16c | ||
|
|
19b8221c14 | ||
|
|
336fadd236 | ||
|
|
a216e38a59 | ||
|
|
d930594686 | ||
|
|
f4261711ae |
110
README.md
110
README.md
@@ -1,25 +1,22 @@
|
|||||||

|

|
||||||

|

|
||||||
|
|
||||||
A single-file Vim plugin manager.
|
A minimalist Vim plugin manager.
|
||||||
|
|
||||||
Somewhere between [Pathogen](https://github.com/tpope/vim-pathogen) and
|
|
||||||
[Vundle](https://github.com/gmarik/vundle), but with faster parallel installer.
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### Pros.
|
### Pros.
|
||||||
|
|
||||||
- Easier to setup
|
- Easier to setup: Single file. No boilerplate code required.
|
||||||
- Parallel installation/update (requires
|
- Easier to use: Concise, intuitive syntax
|
||||||
[+ruby](http://junegunn.kr/2013/09/installing-vim-with-ruby-support/))
|
- [Super-fast](https://raw.github.com/junegunn/i/master/vim-plug/40-in-4.gif)
|
||||||
- Smallest possible feature set
|
parallel installation/update (requires
|
||||||
- Branch/tag support
|
[+ruby](https://github.com/junegunn/vim-plug/wiki/ruby))
|
||||||
- On-demand loading
|
- On-demand loading to achieve
|
||||||
|
[fast startup time](http://junegunn.kr/images/vim-startup-time.png)
|
||||||
### Cons.
|
- Post-update hooks
|
||||||
|
- Can choose a specific branch or tag for each plugin
|
||||||
- Everything else
|
- Support for externally managed plugins
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
@@ -123,7 +120,7 @@ Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
|
|||||||
Plug 'junegunn/vader.vim', { 'on': 'Vader', 'for': 'vader' }
|
Plug 'junegunn/vader.vim', { 'on': 'Vader', 'for': 'vader' }
|
||||||
```
|
```
|
||||||
|
|
||||||
### Post-installation/update hooks
|
### Post-update hooks
|
||||||
|
|
||||||
There are some plugins that require extra steps after installation or update.
|
There are some plugins that require extra steps after installation or update.
|
||||||
In that case, use `do` option to describe the task to be performed.
|
In that case, use `do` option to describe the task to be performed.
|
||||||
@@ -137,10 +134,11 @@ takes a single argument.
|
|||||||
|
|
||||||
```vim
|
```vim
|
||||||
function! BuildYCM(info)
|
function! BuildYCM(info)
|
||||||
" info is a dictionary with two fields
|
" info is a dictionary with 3 fields
|
||||||
" - name: name of the plugin
|
" - name: name of the plugin
|
||||||
" - status: 'installed' or 'updated'
|
" - status: 'installed', 'updated', or 'unchanged'
|
||||||
if a:info.status == 'installed'
|
" - force: set on PlugInstall! or PlugUpdate!
|
||||||
|
if a:info.status == 'installed' || a:info.force
|
||||||
!./install.sh
|
!./install.sh
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@@ -148,7 +146,10 @@ endfunction
|
|||||||
Plug 'Valloric/YouCompleteMe', { 'do': function('BuildYCM') }
|
Plug 'Valloric/YouCompleteMe', { 'do': function('BuildYCM') }
|
||||||
```
|
```
|
||||||
|
|
||||||
Both forms of post-update hook are executed inside the directory of the plugin.
|
Both forms of post-update hook are executed inside the directory of the plugin
|
||||||
|
and only run when the repository has changed, but you can force it to run
|
||||||
|
unconditionally with the bang-versions of the commands: `PlugInstall!` and
|
||||||
|
`PlugUpdate!`.
|
||||||
|
|
||||||
Make sure to escape BARs when you write `do` option inline as they are
|
Make sure to escape BARs when you write `do` option inline as they are
|
||||||
mistakenly recognized as command separator for Plug command.
|
mistakenly recognized as command separator for Plug command.
|
||||||
@@ -165,75 +166,16 @@ let g:fzf_install = 'yes | ./install'
|
|||||||
Plug 'junegunn/fzf', { 'do': g:fzf_install }
|
Plug 'junegunn/fzf', { 'do': g:fzf_install }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### FAQ/Troubleshooting
|
||||||
|
|
||||||
|
See [FAQ/Troubleshooting](https://github.com/junegunn/vim-plug/wiki/faq).
|
||||||
|
|
||||||
### Articles
|
### Articles
|
||||||
|
|
||||||
- [Writing my own Vim plugin manager](http://junegunn.kr/2013/09/writing-my-own-vim-plugin-manager)
|
- [Writing my own Vim plugin manager](http://junegunn.kr/2013/09/writing-my-own-vim-plugin-manager)
|
||||||
- [Thoughts on Vim plugin dependency](http://junegunn.kr/2013/09/thoughts-on-vim-plugin-dependency)
|
|
||||||
- *Support for Plugfile has been removed since 0.5.0*
|
|
||||||
- [Vim plugins and startup time](http://junegunn.kr/2014/07/vim-plugins-and-startup-time)
|
- [Vim plugins and startup time](http://junegunn.kr/2014/07/vim-plugins-and-startup-time)
|
||||||
|
- ~~[Thoughts on Vim plugin dependency](http://junegunn.kr/2013/09/thoughts-on-vim-plugin-dependency)~~
|
||||||
### FAQ/Troubleshooting
|
- *Support for Plugfile has been removed since 0.5.0*
|
||||||
|
|
||||||
#### Plugins are not installed/updated in parallel
|
|
||||||
|
|
||||||
Your Vim does not support Ruby interface. `:echo has('ruby')` should print 1.
|
|
||||||
In order to setup Vim with Ruby support, you may refer to [this
|
|
||||||
article](http://junegunn.kr/2013/09/installing-vim-with-ruby-support).
|
|
||||||
|
|
||||||
#### *Vim: Caught deadly signal SEGV*
|
|
||||||
|
|
||||||
If your Vim crashes with the above message, first check if its Ruby interface is
|
|
||||||
working correctly with the following command:
|
|
||||||
|
|
||||||
```vim
|
|
||||||
:ruby puts RUBY_VERSION
|
|
||||||
```
|
|
||||||
|
|
||||||
If Vim crashes even with this command, it is likely that Ruby interface is
|
|
||||||
broken, and you have to rebuild Vim with a working version of Ruby.
|
|
||||||
(`brew remove vim && brew install vim` or `./configure && make ...`)
|
|
||||||
|
|
||||||
If you're on OS X, one possibility is that you had installed Vim with
|
|
||||||
[Homebrew](http://brew.sh/) while using a Ruby installed with
|
|
||||||
[RVM](http://rvm.io/) or [rbenv](https://github.com/sstephenson/rbenv) and later
|
|
||||||
removed that version of Ruby.
|
|
||||||
|
|
||||||
[Please let me know](https://github.com/junegunn/vim-plug/issues) if you can't
|
|
||||||
resolve the problem. In the meantime, you can set `g:plug_threads` to 1, so that
|
|
||||||
Ruby installer is not used at all.
|
|
||||||
|
|
||||||
#### Errors on fish shell
|
|
||||||
|
|
||||||
If vim-plug doesn't work correctly on fish shell, you might need to add `set
|
|
||||||
shell=/bin/sh` to your .vimrc.
|
|
||||||
|
|
||||||
Refer to the following links for the details:
|
|
||||||
- http://badsimplicity.com/vim-fish-e484-cant-open-file-tmpvrdnvqe0-error/
|
|
||||||
- https://github.com/junegunn/vim-plug/issues/12
|
|
||||||
|
|
||||||
#### Freezing plugin version with commit hash
|
|
||||||
|
|
||||||
vim-plug does not allow you to freeze the version of a plugin with its commit
|
|
||||||
hash. This is by design. I don't believe a user of a plugin should be looking
|
|
||||||
at its individual commits. Instead, one should be choosing the right version
|
|
||||||
using release tags or versioned branches (e.g. 1.2.3, stable, devel, etc.)
|
|
||||||
|
|
||||||
```vim
|
|
||||||
Plug 'junegunn/vim-easy-align', '2.9.2'
|
|
||||||
```
|
|
||||||
|
|
||||||
If the repository doesn't come with such tags or branches, you should think of
|
|
||||||
it as "unstable" or "in development", and always use its latest revision.
|
|
||||||
|
|
||||||
If you really must choose a certain untagged revision, consider forking the
|
|
||||||
repository.
|
|
||||||
|
|
||||||
#### Migrating from other plugin managers
|
|
||||||
|
|
||||||
vim-plug does not require any extra statement other than `plug#begin()` and
|
|
||||||
`plug#end()`. You can remove `filetype off`, `filetype plugin indent on` and
|
|
||||||
`syntax on` from your .vimrc as they are automatically handled by
|
|
||||||
`plug#end()`.
|
|
||||||
|
|
||||||
### License
|
### License
|
||||||
|
|
||||||
|
|||||||
32
plug.vim
32
plug.vim
@@ -109,8 +109,8 @@ function! plug#begin(...)
|
|||||||
let g:plugs_order = []
|
let g:plugs_order = []
|
||||||
|
|
||||||
command! -nargs=+ -bar Plug call s:add(<args>)
|
command! -nargs=+ -bar Plug call s:add(<args>)
|
||||||
command! -nargs=* -complete=customlist,s:names PlugInstall call s:install(<f-args>)
|
command! -nargs=* -bang -complete=customlist,s:names PlugInstall call s:install(!empty('<bang>'), <f-args>)
|
||||||
command! -nargs=* -complete=customlist,s:names PlugUpdate call s:update(<f-args>)
|
command! -nargs=* -bang -complete=customlist,s:names PlugUpdate call s:update(!empty('<bang>'), <f-args>)
|
||||||
command! -nargs=0 -bang PlugClean call s:clean('<bang>' == '!')
|
command! -nargs=0 -bang PlugClean call s:clean('<bang>' == '!')
|
||||||
command! -nargs=0 PlugUpgrade if s:upgrade() | call s:upgrade_specs() | execute 'source '. s:me | endif
|
command! -nargs=0 PlugUpgrade if s:upgrade() | call s:upgrade_specs() | execute 'source '. s:me | endif
|
||||||
command! -nargs=0 PlugStatus call s:status()
|
command! -nargs=0 PlugStatus call s:status()
|
||||||
@@ -365,19 +365,19 @@ function! s:infer_properties(name, repo)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:install(...)
|
function! s:install(force, ...)
|
||||||
call s:update_impl(0, a:000)
|
call s:update_impl(0, a:force, a:000)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:update(...)
|
function! s:update(force, ...)
|
||||||
call s:update_impl(1, a:000)
|
call s:update_impl(1, a:force, a:000)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:helptags()
|
function! s: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 '. join([spec.dir, 'doc'], '/')
|
silent! execute 'helptags '. s:esc(docd)
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
@@ -470,15 +470,16 @@ function! s:assign_name()
|
|||||||
silent! execute 'f '.fnameescape(name)
|
silent! execute 'f '.fnameescape(name)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:do(pull, todo)
|
function! s:do(pull, force, todo)
|
||||||
for [name, spec] in items(a:todo)
|
for [name, spec] in items(a: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)
|
||||||
if installed || (a:pull &&
|
let updated = installed ? 0 :
|
||||||
\ !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}"')))
|
||||||
|
if a:force || installed || updated
|
||||||
call append(3, '- Post-update hook for '. name .' ... ')
|
call append(3, '- Post-update hook for '. name .' ... ')
|
||||||
let type = type(spec.do)
|
let type = type(spec.do)
|
||||||
if type == s:TYPE.string
|
if type == s:TYPE.string
|
||||||
@@ -493,7 +494,8 @@ function! s:do(pull, todo)
|
|||||||
endtry
|
endtry
|
||||||
elseif type == s:TYPE.funcref
|
elseif type == s:TYPE.funcref
|
||||||
try
|
try
|
||||||
call spec.do({ 'name': name, 'status': (installed ? 'installed' : 'updated') })
|
let status = installed ? 'installed' : (updated ? 'updated' : 'unchanged')
|
||||||
|
call spec.do({ 'name': name, 'status': status, 'force': a:force })
|
||||||
let result = 'Done!'
|
let result = 'Done!'
|
||||||
catch
|
catch
|
||||||
let result = 'Error: ' . v:exception
|
let result = 'Error: ' . v:exception
|
||||||
@@ -530,7 +532,7 @@ function! s:retry()
|
|||||||
if empty(s:prev_update.errors)
|
if empty(s:prev_update.errors)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
call s:update_impl(s:prev_update.pull,
|
call s:update_impl(s:prev_update.pull, s:prev_update.force,
|
||||||
\ extend(copy(s:prev_update.errors), [s:prev_update.threads]))
|
\ extend(copy(s:prev_update.errors), [s:prev_update.threads]))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -542,7 +544,7 @@ function! s:names(...)
|
|||||||
return filter(keys(g:plugs), 'stridx(v:val, a:1) == 0 && s:is_managed(v:val)')
|
return filter(keys(g:plugs), 'stridx(v:val, a:1) == 0 && s:is_managed(v:val)')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:update_impl(pull, args) abort
|
function! s:update_impl(pull, force, args) abort
|
||||||
let st = reltime()
|
let st = reltime()
|
||||||
let args = copy(a:args)
|
let args = copy(a:args)
|
||||||
let threads = (len(args) > 0 && args[-1] =~ '^[1-9][0-9]*$') ?
|
let threads = (len(args) > 0 && args[-1] =~ '^[1-9][0-9]*$') ?
|
||||||
@@ -568,7 +570,7 @@ function! s:update_impl(pull, args) abort
|
|||||||
if !isdirectory(g:plug_home)
|
if !isdirectory(g:plug_home)
|
||||||
call mkdir(g:plug_home, 'p')
|
call mkdir(g:plug_home, 'p')
|
||||||
endif
|
endif
|
||||||
let s:prev_update = { 'errors': [], 'pull': a:pull, 'new': {}, 'threads': threads }
|
let s:prev_update = { 'errors': [], 'pull': a:pull, 'force': a:force, 'new': {}, 'threads': threads }
|
||||||
if has('ruby') && threads > 1
|
if has('ruby') && threads > 1
|
||||||
try
|
try
|
||||||
let imd = &imd
|
let imd = &imd
|
||||||
@@ -598,7 +600,7 @@ function! s:update_impl(pull, args) abort
|
|||||||
else
|
else
|
||||||
call s:update_serial(a:pull, todo)
|
call s:update_serial(a:pull, todo)
|
||||||
endif
|
endif
|
||||||
call s:do(a:pull, filter(copy(todo), 'has_key(v:val, "do")'))
|
call s:do(a:pull, a:force, filter(copy(todo), 'has_key(v:val, "do")'))
|
||||||
call s:finish(a:pull)
|
call s:finish(a:pull)
|
||||||
call setline(1, 'Updated. Elapsed time: ' . split(reltimestr(reltime(st)))[0] . ' sec.')
|
call setline(1, 'Updated. Elapsed time: ' . split(reltimestr(reltime(st)))[0] . ' sec.')
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
1
test/run
1
test/run
@@ -33,6 +33,7 @@ make_dirs xxx/after
|
|||||||
|
|
||||||
cat > /tmp/mini-vimrc << VIMRC
|
cat > /tmp/mini-vimrc << VIMRC
|
||||||
set rtp+=vader.vim
|
set rtp+=vader.vim
|
||||||
|
set shell=/bin/bash
|
||||||
source $PLUG_SRC
|
source $PLUG_SRC
|
||||||
VIMRC
|
VIMRC
|
||||||
|
|
||||||
|
|||||||
@@ -621,6 +621,14 @@ Execute (When already installed):
|
|||||||
Assert !filereadable(g:plugs['vim-easy-align'].dir.'/installed2'),
|
Assert !filereadable(g:plugs['vim-easy-align'].dir.'/installed2'),
|
||||||
\ 'vim-easy-align/installed2 should not exist'
|
\ 'vim-easy-align/installed2 should not exist'
|
||||||
Assert !filereadable(g:plugs['vim-pseudocl'].dir.'/installed2'),
|
Assert !filereadable(g:plugs['vim-pseudocl'].dir.'/installed2'),
|
||||||
|
\ 'vim-pseudocl/installed2 should not exist'
|
||||||
|
|
||||||
|
Execute (PlugInstall!):
|
||||||
|
PlugInstall!
|
||||||
|
q
|
||||||
|
Assert filereadable(g:plugs['vim-easy-align'].dir.'/installed2'),
|
||||||
|
\ 'vim-easy-align/installed2 should exist'
|
||||||
|
Assert filereadable(g:plugs['vim-pseudocl'].dir.'/installed2'),
|
||||||
\ 'vim-pseudocl/installed2 should exist'
|
\ 'vim-pseudocl/installed2 should exist'
|
||||||
|
|
||||||
Execute (When already updated):
|
Execute (When already updated):
|
||||||
@@ -634,11 +642,19 @@ Execute (When already updated):
|
|||||||
Assert !filereadable(g:plugs['vim-easy-align'].dir.'/updated2'),
|
Assert !filereadable(g:plugs['vim-easy-align'].dir.'/updated2'),
|
||||||
\ 'vim-easy-align/updated2 should not exist'
|
\ 'vim-easy-align/updated2 should not exist'
|
||||||
Assert !filereadable(g:plugs['vim-pseudocl'].dir.'/updated2'),
|
Assert !filereadable(g:plugs['vim-pseudocl'].dir.'/updated2'),
|
||||||
|
\ 'vim-pseudocl/updated2 should not exist'
|
||||||
|
|
||||||
|
Execute (PlugUpdate!):
|
||||||
|
PlugUpdate!
|
||||||
|
q
|
||||||
|
Assert filereadable(g:plugs['vim-easy-align'].dir.'/updated2'),
|
||||||
|
\ 'vim-easy-align/updated2 should exist'
|
||||||
|
Assert filereadable(g:plugs['vim-pseudocl'].dir.'/updated2'),
|
||||||
\ 'vim-pseudocl/updated2 should exist'
|
\ 'vim-pseudocl/updated2 should exist'
|
||||||
|
|
||||||
Execute (Using Funcref):
|
Execute (Using Funcref):
|
||||||
function! PlugUpdated(info)
|
function! PlugUpdated(info)
|
||||||
call system('touch '. a:info.name . a:info.status . len(a:info))
|
call system('touch '. a:info.name . a:info.status . a:info.force . len(a:info))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call plug#begin()
|
call plug#begin()
|
||||||
@@ -652,11 +668,26 @@ Execute (Using Funcref):
|
|||||||
PlugUpdate
|
PlugUpdate
|
||||||
Log getline(1, '$')
|
Log getline(1, '$')
|
||||||
q
|
q
|
||||||
Assert filereadable(g:plugs['vim-easy-align'].dir.'/vim-easy-alignupdated2'),
|
Assert filereadable(g:plugs['vim-easy-align'].dir.'/vim-easy-alignupdated03'),
|
||||||
\ 'vim-easy-align/vim-easy-alignupdated2 should exist'
|
\ 'vim-easy-align/vim-easy-alignupdated03 should exist'
|
||||||
Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclinstalled2'),
|
Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclinstalled03'),
|
||||||
\ 'vim-pseudocl/vim-pseudoclinstalled2 should exist'
|
\ 'vim-pseudocl/vim-pseudoclinstalled03 should exist'
|
||||||
|
|
||||||
|
call system('rm -rf '.g:plugs['vim-pseudocl'].dir)
|
||||||
|
PlugInstall!
|
||||||
|
q
|
||||||
|
Assert filereadable(g:plugs['vim-easy-align'].dir.'/vim-easy-alignunchanged13'),
|
||||||
|
\ 'vim-easy-align/vim-easy-alignunchanged13 should exist'
|
||||||
|
Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclinstalled13'),
|
||||||
|
\ 'vim-pseudocl/vim-pseudoclinstalled13 should exist'
|
||||||
|
|
||||||
|
call system('cd '.g:plugs['vim-easy-align'].dir.' && git reset --hard HEAD^')
|
||||||
|
PlugUpdate!
|
||||||
|
q
|
||||||
|
Assert filereadable(g:plugs['vim-easy-align'].dir.'/vim-easy-alignupdated13'),
|
||||||
|
\ 'vim-easy-align/vim-easy-alignupdated13 should exist'
|
||||||
|
Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclunchanged13'),
|
||||||
|
\ 'vim-pseudocl/vim-pseudoclunchanged13 should exist'
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
~ Overriding `dir`
|
~ Overriding `dir`
|
||||||
|
|||||||
Reference in New Issue
Block a user