mirror of
https://github.com/junegunn/vim-plug.git
synced 2025-12-08 18:04:46 +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: |
|
before_script: |
|
||||||
hg clone https://code.google.com/p/vim/
|
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
|
```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
|
||||||
@@ -60,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
|
||||||
|
|
||||||
@@ -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
|
unconditionally with the bang-versions of the commands: `PlugInstall!` and
|
||||||
`PlugUpdate!`.
|
`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' }
|
||||||
|
|||||||
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.')
|
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=* -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()
|
|
||||||
|
|
||||||
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
|
||||||
@@ -561,15 +557,21 @@ function! s:update_impl(pull, force, 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)
|
|
||||||
call mkdir(g:plug_home, 'p')
|
|
||||||
endif
|
|
||||||
let s:prev_update = { 'errors': [], 'pull': a:pull, 'force': a:force, '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
|
||||||
@@ -1004,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')
|
||||||
@@ -1025,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()
|
||||||
@@ -1147,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
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user