mirror of
https://github.com/junegunn/vim-plug.git
synced 2025-12-07 01:24:27 +08:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a2e406cd0 | ||
|
|
84cdf61730 | ||
|
|
0aeea1db08 | ||
|
|
8289477d18 | ||
|
|
19b12e2216 | ||
|
|
4c9ebe9c31 | ||
|
|
74dcd13575 | ||
|
|
518f20652f | ||
|
|
665ec057d7 | ||
|
|
bc212dca77 | ||
|
|
8da7b50fb2 | ||
|
|
4ae2e879e1 |
@@ -1,4 +1,7 @@
|
||||
language: vim
|
||||
language: ruby
|
||||
rvm:
|
||||
- 1.8.7
|
||||
- 2.0.0
|
||||
|
||||
before_script: |
|
||||
hg clone https://code.google.com/p/vim/
|
||||
|
||||
24
README.md
24
README.md
@@ -25,7 +25,8 @@ 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
|
||||
curl -fLo ~/.vim/autoload/plug.vim \
|
||||
https://raw.github.com/junegunn/vim-plug/master/plug.vim
|
||||
```
|
||||
|
||||
Edit your .vimrc
|
||||
@@ -60,14 +61,14 @@ Reload .vimrc and `:PlugInstall` to install plugins.
|
||||
|
||||
### Commands
|
||||
|
||||
| Command | Description |
|
||||
| --------------------------------- | ------------------------------------------------------------------ |
|
||||
| PlugInstall [name ...] [#threads] | Install plugins |
|
||||
| PlugUpdate [name ...] [#threads] | Install or update plugins |
|
||||
| PlugClean[!] | Remove unused directories (bang version will clean without prompt) |
|
||||
| PlugUpgrade | Upgrade vim-plug itself |
|
||||
| PlugStatus | Check the status of plugins |
|
||||
| PlugDiff | See the updated changes from the previous PlugUpdate |
|
||||
| Command | Description |
|
||||
| ----------------------------------- | ------------------------------------------------------------------ |
|
||||
| `PlugInstall [name ...] [#threads]` | Install plugins |
|
||||
| `PlugUpdate [name ...] [#threads]` | Install or update plugins |
|
||||
| `PlugClean[!]` | Remove unused directories (bang version will clean without prompt) |
|
||||
| `PlugUpgrade` | Upgrade vim-plug itself |
|
||||
| `PlugStatus` | Check the status of plugins |
|
||||
| `PlugDiff` | See the updated changes from the previous PlugUpdate |
|
||||
|
||||
### `Plug` options
|
||||
|
||||
@@ -151,8 +152,9 @@ 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
|
||||
mistakenly recognized as command separator for Plug command.
|
||||
Make sure to escape BARs and double-quotes when you write `do` option inline
|
||||
as they are mistakenly recognized as command separator or the start of the
|
||||
trailing comment.
|
||||
|
||||
```vim
|
||||
Plug 'junegunn/fzf', { 'do': 'yes \| ./install' }
|
||||
|
||||
63
plug.vim
63
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.')
|
||||
endif
|
||||
|
||||
if !isdirectory(home)
|
||||
try
|
||||
call mkdir(home, 'p')
|
||||
catch
|
||||
return s:err('Invalid plug directory: '. home)
|
||||
endtry
|
||||
endif
|
||||
if !executable('git')
|
||||
return s:err('`git` executable not found. vim-plug requires git.')
|
||||
endif
|
||||
@@ -108,17 +101,20 @@ function! plug#begin(...)
|
||||
" we want to keep track of the order plugins where registered.
|
||||
let g:plugs_order = []
|
||||
|
||||
command! -nargs=+ -bar Plug call s:add(<args>)
|
||||
command! -nargs=* -bang -complete=customlist,s:names PlugInstall call s:install(!empty('<bang>'), <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 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()
|
||||
|
||||
call s:define_commands()
|
||||
return 1
|
||||
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)
|
||||
return type(a:v) == s:TYPE.list ? a:v : [a:v]
|
||||
endfunction
|
||||
@@ -561,15 +557,21 @@ function! s:update_impl(pull, force, args) abort
|
||||
return
|
||||
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 append(0, a:pull ? 'Updating plugins' : 'Installing plugins')
|
||||
call append(1, '['. s:lpad('', len(todo)) .']')
|
||||
normal! 2G
|
||||
redraw
|
||||
|
||||
if !isdirectory(g:plug_home)
|
||||
call mkdir(g:plug_home, 'p')
|
||||
endif
|
||||
let s:prev_update = { 'errors': [], 'pull': a:pull, 'force': a:force, 'new': {}, 'threads': threads }
|
||||
if has('ruby') && threads > 1
|
||||
try
|
||||
@@ -1004,16 +1006,13 @@ function! s:upgrade()
|
||||
call system(printf(
|
||||
\ 'curl -fLo %s %s && '.cp.' %s %s.old && '.mv.' %s %s',
|
||||
\ new, s:plug_source, mee, mee, new, mee))
|
||||
if v:shell_error == 0
|
||||
unlet g:loaded_plug
|
||||
echo 'Downloaded '. s:plug_source
|
||||
return 1
|
||||
else
|
||||
if v:shell_error
|
||||
return s:err('Error upgrading vim-plug')
|
||||
endif
|
||||
elseif has('ruby')
|
||||
echo 'Downloading '. s:plug_source
|
||||
ruby << EOF
|
||||
try
|
||||
ruby << EOF
|
||||
require 'open-uri'
|
||||
require 'fileutils'
|
||||
me = VIM::evaluate('s:me')
|
||||
@@ -1025,12 +1024,16 @@ function! s:upgrade()
|
||||
FileUtils.cp me, old
|
||||
File.rename new, me
|
||||
EOF
|
||||
unlet g:loaded_plug
|
||||
echo 'Downloaded '. s:plug_source
|
||||
return 1
|
||||
catch
|
||||
return s:err('Error upgrading vim-plug')
|
||||
endtry
|
||||
else
|
||||
return s:err('curl executable or ruby support not found')
|
||||
endif
|
||||
|
||||
unlet g:loaded_plug
|
||||
echo 'Downloaded '. s:plug_source
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! s:upgrade_specs()
|
||||
@@ -1147,6 +1150,12 @@ endfunction
|
||||
let s:first_rtp = s:esc(get(split(&rtp, ','), 0, ''))
|
||||
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
|
||||
unlet s:cpo_save
|
||||
|
||||
|
||||
@@ -33,6 +33,12 @@ Execute (Initialize test environment):
|
||||
endfunction
|
||||
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):
|
||||
redir => out
|
||||
AssertEqual 0, plug#end()
|
||||
@@ -506,15 +512,15 @@ Execute (Frozen plugin are not installed nor updated):
|
||||
Plug 'junegunn/vim-easy-align', { 'frozen': 1 }
|
||||
call plug#end()
|
||||
|
||||
redir => output
|
||||
redir => out
|
||||
silent PlugInstall
|
||||
redir END
|
||||
Assert output =~ 'No plugin to install'
|
||||
Assert out =~ 'No plugin to install'
|
||||
|
||||
redir => output
|
||||
redir => out
|
||||
silent PlugUpdate
|
||||
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):
|
||||
PlugInstall vim-easy-align
|
||||
|
||||
Reference in New Issue
Block a user