mirror of
https://github.com/junegunn/vim-plug.git
synced 2025-12-08 18:04:46 +08:00
Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a2e406cd0 | ||
|
|
84cdf61730 | ||
|
|
0aeea1db08 | ||
|
|
8289477d18 | ||
|
|
19b12e2216 | ||
|
|
4c9ebe9c31 | ||
|
|
74dcd13575 | ||
|
|
518f20652f | ||
|
|
665ec057d7 | ||
|
|
bc212dca77 | ||
|
|
8da7b50fb2 | ||
|
|
4ae2e879e1 | ||
|
|
93628b1c3d | ||
|
|
01e126469b | ||
|
|
a7477f04b7 | ||
|
|
0fdb56ba72 | ||
|
|
d89949f16c | ||
|
|
19b8221c14 | ||
|
|
336fadd236 | ||
|
|
a216e38a59 | ||
|
|
d930594686 | ||
|
|
f4261711ae |
@@ -1,4 +1,7 @@
|
|||||||
language: vim
|
language: ruby
|
||||||
|
rvm:
|
||||||
|
- 1.8.7
|
||||||
|
- 2.0.0
|
||||||
|
|
||||||
before_script: |
|
before_script: |
|
||||||
hg clone https://code.google.com/p/vim/
|
hg clone https://code.google.com/p/vim/
|
||||||
|
|||||||
136
README.md
136
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
|
||||||
|
|
||||||
@@ -28,7 +25,8 @@ and put it in ~/.vim/autoload
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
mkdir -p ~/.vim/autoload
|
mkdir -p ~/.vim/autoload
|
||||||
curl -fLo ~/.vim/autoload/plug.vim https://raw.github.com/junegunn/vim-plug/master/plug.vim
|
curl -fLo ~/.vim/autoload/plug.vim \
|
||||||
|
https://raw.github.com/junegunn/vim-plug/master/plug.vim
|
||||||
```
|
```
|
||||||
|
|
||||||
Edit your .vimrc
|
Edit your .vimrc
|
||||||
@@ -63,14 +61,14 @@ Reload .vimrc and `:PlugInstall` to install plugins.
|
|||||||
|
|
||||||
### Commands
|
### Commands
|
||||||
|
|
||||||
| Command | Description |
|
| Command | Description |
|
||||||
| --------------------------------- | ------------------------------------------------------------------ |
|
| ----------------------------------- | ------------------------------------------------------------------ |
|
||||||
| PlugInstall [name ...] [#threads] | Install plugins |
|
| `PlugInstall [name ...] [#threads]` | Install plugins |
|
||||||
| PlugUpdate [name ...] [#threads] | Install or update plugins |
|
| `PlugUpdate [name ...] [#threads]` | Install or update plugins |
|
||||||
| PlugClean[!] | Remove unused directories (bang version will clean without prompt) |
|
| `PlugClean[!]` | Remove unused directories (bang version will clean without prompt) |
|
||||||
| PlugUpgrade | Upgrade vim-plug itself |
|
| `PlugUpgrade` | Upgrade vim-plug itself |
|
||||||
| PlugStatus | Check the status of plugins |
|
| `PlugStatus` | Check the status of plugins |
|
||||||
| PlugDiff | See the updated changes from the previous PlugUpdate |
|
| `PlugDiff` | See the updated changes from the previous PlugUpdate |
|
||||||
|
|
||||||
### `Plug` options
|
### `Plug` options
|
||||||
|
|
||||||
@@ -123,7 +121,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 +135,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,10 +147,14 @@ 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 and double-quotes when you write `do` option inline
|
||||||
mistakenly recognized as command separator for Plug command.
|
as they are mistakenly recognized as command separator or the start of the
|
||||||
|
trailing comment.
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
Plug 'junegunn/fzf', { 'do': 'yes \| ./install' }
|
Plug 'junegunn/fzf', { 'do': 'yes \| ./install' }
|
||||||
@@ -165,75 +168,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
|
||||||
|
|
||||||
|
|||||||
91
plug.vim
91
plug.vim
@@ -92,13 +92,6 @@ function! plug#begin(...)
|
|||||||
return s:err('Unable to determine plug home. Try calling plug#begin() with a path argument.')
|
return s:err('Unable to determine plug home. Try calling plug#begin() with a path argument.')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !isdirectory(home)
|
|
||||||
try
|
|
||||||
call mkdir(home, 'p')
|
|
||||||
catch
|
|
||||||
return s:err('Invalid plug directory: '. home)
|
|
||||||
endtry
|
|
||||||
endif
|
|
||||||
if !executable('git')
|
if !executable('git')
|
||||||
return s:err('`git` executable not found. vim-plug requires git.')
|
return s:err('`git` executable not found. vim-plug requires git.')
|
||||||
endif
|
endif
|
||||||
@@ -108,17 +101,20 @@ function! plug#begin(...)
|
|||||||
" we want to keep track of the order plugins where registered.
|
" we want to keep track of the order plugins where registered.
|
||||||
let g:plugs_order = []
|
let g:plugs_order = []
|
||||||
|
|
||||||
command! -nargs=+ -bar Plug call s:add(<args>)
|
call s:define_commands()
|
||||||
command! -nargs=* -complete=customlist,s:names PlugInstall call s:install(<f-args>)
|
|
||||||
command! -nargs=* -complete=customlist,s:names PlugUpdate call s:update(<f-args>)
|
|
||||||
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 PlugStatus call s:status()
|
|
||||||
command! -nargs=0 PlugDiff call s:diff()
|
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:define_commands()
|
||||||
|
command! -nargs=+ -bar Plug call s:add(<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=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 PlugStatus call s:status()
|
||||||
|
command! -nargs=0 -bar PlugDiff call s:diff()
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:to_a(v)
|
function! s:to_a(v)
|
||||||
return type(a:v) == s:TYPE.list ? a:v : [a:v]
|
return type(a:v) == s:TYPE.list ? a:v : [a:v]
|
||||||
endfunction
|
endfunction
|
||||||
@@ -365,19 +361,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 +466,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 +490,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 +528,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 +540,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]*$') ?
|
||||||
@@ -559,16 +557,22 @@ function! s:update_impl(pull, args) abort
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if !isdirectory(g:plug_home)
|
||||||
|
try
|
||||||
|
call mkdir(g:plug_home, 'p')
|
||||||
|
catch
|
||||||
|
return s:err(printf('Invalid plug directory: %s.'
|
||||||
|
\ 'Try to call plug#begin with a valid directory', g:plug_home))
|
||||||
|
endtry
|
||||||
|
endif
|
||||||
|
|
||||||
call s:prepare()
|
call s:prepare()
|
||||||
call append(0, a:pull ? 'Updating plugins' : 'Installing plugins')
|
call append(0, a:pull ? 'Updating plugins' : 'Installing plugins')
|
||||||
call append(1, '['. s:lpad('', len(todo)) .']')
|
call append(1, '['. s:lpad('', len(todo)) .']')
|
||||||
normal! 2G
|
normal! 2G
|
||||||
redraw
|
redraw
|
||||||
|
|
||||||
if !isdirectory(g:plug_home)
|
let s:prev_update = { 'errors': [], 'pull': a:pull, 'force': a:force, 'new': {}, 'threads': threads }
|
||||||
call mkdir(g:plug_home, 'p')
|
|
||||||
endif
|
|
||||||
let s:prev_update = { 'errors': [], 'pull': a:pull, 'new': {}, 'threads': threads }
|
|
||||||
if has('ruby') && threads > 1
|
if has('ruby') && threads > 1
|
||||||
try
|
try
|
||||||
let imd = &imd
|
let imd = &imd
|
||||||
@@ -598,7 +602,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
|
||||||
@@ -1002,16 +1006,13 @@ function! s:upgrade()
|
|||||||
call system(printf(
|
call system(printf(
|
||||||
\ 'curl -fLo %s %s && '.cp.' %s %s.old && '.mv.' %s %s',
|
\ 'curl -fLo %s %s && '.cp.' %s %s.old && '.mv.' %s %s',
|
||||||
\ new, s:plug_source, mee, mee, new, mee))
|
\ new, s:plug_source, mee, mee, new, mee))
|
||||||
if v:shell_error == 0
|
if v:shell_error
|
||||||
unlet g:loaded_plug
|
|
||||||
echo 'Downloaded '. s:plug_source
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
return s:err('Error upgrading vim-plug')
|
return s:err('Error upgrading vim-plug')
|
||||||
endif
|
endif
|
||||||
elseif has('ruby')
|
elseif has('ruby')
|
||||||
echo 'Downloading '. s:plug_source
|
echo 'Downloading '. s:plug_source
|
||||||
ruby << EOF
|
try
|
||||||
|
ruby << EOF
|
||||||
require 'open-uri'
|
require 'open-uri'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
me = VIM::evaluate('s:me')
|
me = VIM::evaluate('s:me')
|
||||||
@@ -1023,12 +1024,16 @@ function! s:upgrade()
|
|||||||
FileUtils.cp me, old
|
FileUtils.cp me, old
|
||||||
File.rename new, me
|
File.rename new, me
|
||||||
EOF
|
EOF
|
||||||
unlet g:loaded_plug
|
catch
|
||||||
echo 'Downloaded '. s:plug_source
|
return s:err('Error upgrading vim-plug')
|
||||||
return 1
|
endtry
|
||||||
else
|
else
|
||||||
return s:err('curl executable or ruby support not found')
|
return s:err('curl executable or ruby support not found')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
unlet g:loaded_plug
|
||||||
|
echo 'Downloaded '. s:plug_source
|
||||||
|
return 1
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:upgrade_specs()
|
function! s:upgrade_specs()
|
||||||
@@ -1145,6 +1150,12 @@ endfunction
|
|||||||
let s:first_rtp = s:esc(get(split(&rtp, ','), 0, ''))
|
let s:first_rtp = s:esc(get(split(&rtp, ','), 0, ''))
|
||||||
let s:last_rtp = s:esc(get(split(&rtp, ','), -1, ''))
|
let s:last_rtp = s:esc(get(split(&rtp, ','), -1, ''))
|
||||||
|
|
||||||
|
if exists('g:plugs')
|
||||||
|
let g:plugs_order = get(g:, 'plugs_order', keys(g:plugs))
|
||||||
|
call s:upgrade_specs()
|
||||||
|
call s:define_commands()
|
||||||
|
endif
|
||||||
|
|
||||||
let &cpo = s:cpo_save
|
let &cpo = s:cpo_save
|
||||||
unlet s:cpo_save
|
unlet s:cpo_save
|
||||||
|
|
||||||
|
|||||||
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
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,12 @@ Execute (Initialize test environment):
|
|||||||
endfunction
|
endfunction
|
||||||
command! -nargs=+ -bang AssertExpect call AssertExpect('<bang>' == '!', <args>)
|
command! -nargs=+ -bang AssertExpect call AssertExpect('<bang>' == '!', <args>)
|
||||||
|
|
||||||
|
Execute (Print Ruby version):
|
||||||
|
redir => out
|
||||||
|
silent ruby puts RUBY_VERSION
|
||||||
|
redir END
|
||||||
|
Log substitute(out, '\n', '', 'g')
|
||||||
|
|
||||||
Execute (plug#end() before plug#begin() should fail):
|
Execute (plug#end() before plug#begin() should fail):
|
||||||
redir => out
|
redir => out
|
||||||
AssertEqual 0, plug#end()
|
AssertEqual 0, plug#end()
|
||||||
@@ -506,15 +512,15 @@ Execute (Frozen plugin are not installed nor updated):
|
|||||||
Plug 'junegunn/vim-easy-align', { 'frozen': 1 }
|
Plug 'junegunn/vim-easy-align', { 'frozen': 1 }
|
||||||
call plug#end()
|
call plug#end()
|
||||||
|
|
||||||
redir => output
|
redir => out
|
||||||
silent PlugInstall
|
silent PlugInstall
|
||||||
redir END
|
redir END
|
||||||
Assert output =~ 'No plugin to install'
|
Assert out =~ 'No plugin to install'
|
||||||
|
|
||||||
redir => output
|
redir => out
|
||||||
silent PlugUpdate
|
silent PlugUpdate
|
||||||
redir END
|
redir END
|
||||||
Assert output =~ 'No plugin to update'
|
Assert out =~ 'No plugin to update'
|
||||||
|
|
||||||
Execute (But you can still install it if the name is given as the argument):
|
Execute (But you can still install it if the name is given as the argument):
|
||||||
PlugInstall vim-easy-align
|
PlugInstall vim-easy-align
|
||||||
@@ -621,6 +627,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 +648,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 +674,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