mirror of
https://github.com/junegunn/vim-plug.git
synced 2025-12-06 17:14:26 +08:00
Compare commits
36 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da24f714e0 | ||
|
|
c1bbbaf3ef | ||
|
|
f7ebba7b9e | ||
|
|
6272f5e289 | ||
|
|
f43067c7a5 | ||
|
|
e6cba28997 | ||
|
|
f1b8832a13 | ||
|
|
d0c94a9b08 | ||
|
|
3a2e406cd0 | ||
|
|
84cdf61730 | ||
|
|
0aeea1db08 | ||
|
|
8289477d18 | ||
|
|
19b12e2216 | ||
|
|
4c9ebe9c31 | ||
|
|
74dcd13575 | ||
|
|
518f20652f | ||
|
|
665ec057d7 | ||
|
|
bc212dca77 | ||
|
|
8da7b50fb2 | ||
|
|
4ae2e879e1 | ||
|
|
93628b1c3d | ||
|
|
01e126469b | ||
|
|
a7477f04b7 | ||
|
|
0fdb56ba72 | ||
|
|
d89949f16c | ||
|
|
19b8221c14 | ||
|
|
336fadd236 | ||
|
|
a216e38a59 | ||
|
|
d930594686 | ||
|
|
f4261711ae | ||
|
|
61b77bc8e8 | ||
|
|
fe7c7e7b40 | ||
|
|
25afdf138c | ||
|
|
b36fd34da0 | ||
|
|
7e55690f19 | ||
|
|
30ef53d832 |
@@ -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/
|
||||
|
||||
148
README.md
148
README.md
@@ -1,26 +1,22 @@
|
||||

|
||||

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

|
||||
|
||||
### Pros.
|
||||
|
||||
- Easier to setup
|
||||
- Parallel installation/update (requires
|
||||
[+ruby](http://junegunn.kr/2013/09/installing-vim-with-ruby-support/))
|
||||
- Smallest possible feature set
|
||||
- Branch/tag support
|
||||
- On-demand loading
|
||||
- Dependency resolution using `Plugfile` (experimental)
|
||||
|
||||
### Cons.
|
||||
|
||||
- Everything else
|
||||
- Easier to setup: Single file. No boilerplate code required.
|
||||
- Easier to use: Concise, intuitive syntax
|
||||
- [Super-fast](https://raw.github.com/junegunn/i/master/vim-plug/40-in-4.gif)
|
||||
parallel installation/update (requires
|
||||
[+ruby](https://github.com/junegunn/vim-plug/wiki/ruby))
|
||||
- On-demand loading to achieve
|
||||
[fast startup time](http://junegunn.kr/images/vim-startup-time.png)
|
||||
- Post-update hooks
|
||||
- Can choose a specific branch or tag for each plugin
|
||||
- Support for externally managed plugins
|
||||
|
||||
### Usage
|
||||
|
||||
@@ -29,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
|
||||
@@ -51,8 +48,11 @@ Plug 'https://github.com/junegunn/vim-github-dashboard.git'
|
||||
" Plugin options
|
||||
Plug 'nsf/gocode', { 'tag': 'go.weekly.2012-03-13', 'rtp': 'vim' }
|
||||
|
||||
" Locally-managed plugin
|
||||
Plug '~/.fzf'
|
||||
" Plugin outside ~/.vim/plugged with post-update hook
|
||||
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': 'yes \| ./install' }
|
||||
|
||||
" Unmanaged plugin (manually installed and updated)
|
||||
Plug '~/my-prototype-plugin'
|
||||
|
||||
call plug#end()
|
||||
```
|
||||
@@ -61,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
|
||||
|
||||
@@ -96,6 +96,10 @@ Reload .vimrc and `:PlugInstall` to install plugins.
|
||||
- `S` - `PlugStatus`
|
||||
- `R` - Retry failed update or installation tasks
|
||||
- `q` - Close the window
|
||||
- `:PlugStatus`
|
||||
- `L` - Load plugin
|
||||
- `:PlugDiff`
|
||||
- `X` - Revert the update
|
||||
|
||||
### Example: A small [sensible](https://github.com/tpope/vim-sensible) Vim configuration
|
||||
|
||||
@@ -121,7 +125,7 @@ Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
|
||||
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.
|
||||
In that case, use `do` option to describe the task to be performed.
|
||||
@@ -135,10 +139,11 @@ takes a single argument.
|
||||
|
||||
```vim
|
||||
function! BuildYCM(info)
|
||||
" info is a dictionary with two fields
|
||||
" - name: name of the plugin
|
||||
" - status: 'installed' or 'updated'
|
||||
if a:info.status == 'installed'
|
||||
" info is a dictionary with 3 fields
|
||||
" - name: name of the plugin
|
||||
" - status: 'installed', 'updated', or 'unchanged'
|
||||
" - force: set on PlugInstall! or PlugUpdate!
|
||||
if a:info.status == 'installed' || a:info.force
|
||||
!./install.sh
|
||||
endif
|
||||
endfunction
|
||||
@@ -146,10 +151,14 @@ endfunction
|
||||
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
|
||||
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' }
|
||||
@@ -163,79 +172,16 @@ let g:fzf_install = 'yes | ./install'
|
||||
Plug 'junegunn/fzf', { 'do': g:fzf_install }
|
||||
```
|
||||
|
||||
### Dependency resolution
|
||||
### FAQ/Troubleshooting
|
||||
|
||||
See [Dependency
|
||||
Resolution](https://github.com/junegunn/vim-plug/wiki/Dependency-Resolution).
|
||||
See [FAQ/Troubleshooting](https://github.com/junegunn/vim-plug/wiki/faq).
|
||||
|
||||
### Articles
|
||||
|
||||
- [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)
|
||||
- [Vim plugins and startup time](http://junegunn.kr/2014/07/vim-plugins-and-startup-time)
|
||||
|
||||
### FAQ/Troubleshooting
|
||||
|
||||
#### 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()`.
|
||||
- ~~[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*
|
||||
|
||||
### License
|
||||
|
||||
|
||||
553
plug.vim
553
plug.vim
@@ -25,8 +25,11 @@
|
||||
" " Plugin options
|
||||
" Plug 'nsf/gocode', { 'tag': 'go.weekly.2012-03-13', 'rtp': 'vim' }
|
||||
"
|
||||
" " Locally-managed plugin
|
||||
" Plug '~/.fzf'
|
||||
" " Plugin outside ~/.vim/plugged with post-update hook
|
||||
" Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': 'yes \| ./install' }
|
||||
"
|
||||
" " Unmanaged plugin (manually installed and updated)
|
||||
" Plug '~/my-prototype-plugin'
|
||||
"
|
||||
" call plug#end()
|
||||
"
|
||||
@@ -66,18 +69,18 @@ let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
let s:plug_source = 'https://raw.github.com/junegunn/vim-plug/master/plug.vim'
|
||||
let s:plug_file = 'Plugfile'
|
||||
let 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:is_win = has('win32') || has('win64')
|
||||
let s:me = expand('<sfile>:p')
|
||||
let s:base_spec = { 'branch': 'master', 'frozen': 0, 'local': 0 }
|
||||
let s:base_spec = { 'branch': 'master', 'frozen': 0 }
|
||||
let s:TYPE = {
|
||||
\ 'string': type(''),
|
||||
\ 'list': type([]),
|
||||
\ 'dict': type({}),
|
||||
\ 'funcref': type(function('call'))
|
||||
\ }
|
||||
let s:loaded = get(s:, 'loaded', {})
|
||||
|
||||
function! plug#begin(...)
|
||||
if a:0 > 0
|
||||
@@ -90,47 +93,45 @@ 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
|
||||
|
||||
let g:plug_home = home
|
||||
let g:plugs = {}
|
||||
" we want to keep track of the order plugins where registered.
|
||||
let g:plugs_order = []
|
||||
|
||||
command! -nargs=+ -bar Plug call s:add(1, <args>)
|
||||
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()
|
||||
|
||||
call s:define_commands()
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! s:define_commands()
|
||||
command! -nargs=+ -bar Plug call s:add(<args>)
|
||||
if !executable('git')
|
||||
return s:err('`git` executable not found. vim-plug requires git.')
|
||||
endif
|
||||
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
|
||||
|
||||
function! s:source(from, ...)
|
||||
for pattern in a:000
|
||||
for vim in split(globpath(a:from, pattern), '\n')
|
||||
execute 'source '.vim
|
||||
endfor
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! plug#end()
|
||||
let reload = !has('vim_starting')
|
||||
if !exists('g:plugs')
|
||||
return s:err('Call plug#begin() first')
|
||||
endif
|
||||
let keys = keys(g:plugs)
|
||||
let plugfiles = s:find_plugfiles()
|
||||
while !empty(keys)
|
||||
" No need to look for Plugfiles more than once
|
||||
let keys = keys(s:extend(keys, plugfiles))
|
||||
endwhile
|
||||
|
||||
if exists('#PlugLOD')
|
||||
augroup PlugLOD
|
||||
@@ -147,14 +148,16 @@ function! plug#end()
|
||||
" need to loop through the plugins in reverse
|
||||
for name in reverse(copy(g:plugs_order))
|
||||
let plug = g:plugs[name]
|
||||
if !has_key(plug, 'on') && !has_key(plug, 'for')
|
||||
call s:add_rtp(s:rtp(plug))
|
||||
if get(s:loaded, plug.dir, 0) || !has_key(plug, 'on') && !has_key(plug, 'for')
|
||||
let rtp = s:add_rtp(plug)
|
||||
if reload
|
||||
call s:source(rtp, 'plugin/**/*.vim', 'after/plugin/**/*.vim')
|
||||
endif
|
||||
continue
|
||||
endif
|
||||
|
||||
if has_key(plug, 'on')
|
||||
let commands = s:to_a(plug.on)
|
||||
for cmd in commands
|
||||
for cmd in s:to_a(plug.on)
|
||||
if cmd =~ '^<Plug>.\+'
|
||||
if empty(mapcheck(cmd)) && empty(mapcheck(cmd, 'i'))
|
||||
for [mode, map_prefix, key_prefix] in
|
||||
@@ -173,10 +176,11 @@ function! plug#end()
|
||||
endif
|
||||
|
||||
if has_key(plug, 'for')
|
||||
for vim in split(globpath(s:rtp(plug), 'ftdetect/**/*.vim'), '\n')
|
||||
execute 'source '.vim
|
||||
endfor
|
||||
for key in s:to_a(plug.for)
|
||||
let types = s:to_a(plug.for)
|
||||
if !empty(types)
|
||||
call s:source(s:rtp(plug), 'ftdetect/**/*.vim', 'after/ftdetect/**/*.vim')
|
||||
endif
|
||||
for key in types
|
||||
if !has_key(lod, key)
|
||||
let lod[key] = []
|
||||
endif
|
||||
@@ -245,12 +249,15 @@ function! s:esc(path)
|
||||
return substitute(a:path, ' ', '\\ ', 'g')
|
||||
endfunction
|
||||
|
||||
function! s:add_rtp(rtp)
|
||||
execute 'set rtp^='.s:esc(a:rtp)
|
||||
let after = globpath(a:rtp, 'after')
|
||||
function! s:add_rtp(plug)
|
||||
let rtp = s:rtp(a:plug)
|
||||
execute 'set rtp^='.s:esc(rtp)
|
||||
let after = globpath(rtp, 'after')
|
||||
if isdirectory(after)
|
||||
execute 'set rtp+='.s:esc(after)
|
||||
endif
|
||||
let s:loaded[a:plug.dir] = 1
|
||||
return rtp
|
||||
endfunction
|
||||
|
||||
function! s:reorg_rtp()
|
||||
@@ -264,28 +271,46 @@ function! s:reorg_rtp()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! plug#load(...)
|
||||
if a:0 == 0
|
||||
return s:err('Argument missing: plugin name(s) required')
|
||||
endif
|
||||
if !exists('g:plugs')
|
||||
return s:err('plug#begin was not called')
|
||||
endif
|
||||
let unknowns = filter(copy(a:000), '!has_key(g:plugs, v:val)')
|
||||
if !empty(unknowns)
|
||||
let s = len(unknowns) > 1 ? 's' : ''
|
||||
return s:err(printf('Unknown plugin%s: %s', s, join(unknowns, ', ')))
|
||||
end
|
||||
for name in a:000
|
||||
call s:lod(g:plugs[name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
||||
endfor
|
||||
call s:reorg_rtp()
|
||||
silent! doautocmd BufRead
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! s:lod(plug, types)
|
||||
let rtp = s:rtp(a:plug)
|
||||
call s:add_rtp(rtp)
|
||||
let rtp = s:add_rtp(a:plug)
|
||||
for dir in a:types
|
||||
for vim in split(globpath(rtp, dir.'/**/*.vim'), '\n')
|
||||
execute 'source '.vim
|
||||
endfor
|
||||
call s:source(rtp, dir.'/**/*.vim')
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:lod_ft(pat, names)
|
||||
for name in a:names
|
||||
call s:lod(g:plugs[name], ['plugin', 'after'])
|
||||
call s:lod(g:plugs[name], ['plugin', 'after/plugin'])
|
||||
endfor
|
||||
call s:reorg_rtp()
|
||||
execute 'autocmd! PlugLOD FileType ' . a:pat
|
||||
silent! doautocmd filetypeplugin FileType
|
||||
silent! doautocmd filetypeindent FileType
|
||||
endfunction
|
||||
|
||||
function! s:lod_cmd(cmd, bang, l1, l2, args, name)
|
||||
execute 'delc '.a:cmd
|
||||
call s:lod(g:plugs[a:name], ['plugin', 'ftdetect', 'after'])
|
||||
call s:lod(g:plugs[a:name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
||||
call s:reorg_rtp()
|
||||
execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args)
|
||||
endfunction
|
||||
@@ -293,7 +318,7 @@ endfunction
|
||||
function! s:lod_map(map, name, prefix)
|
||||
execute 'unmap '.a:map
|
||||
execute 'iunmap '.a:map
|
||||
call s:lod(g:plugs[a:name], ['plugin', 'ftdetect', 'after'])
|
||||
call s:lod(g:plugs[a:name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
||||
call s:reorg_rtp()
|
||||
let extra = ''
|
||||
while 1
|
||||
@@ -306,7 +331,7 @@ function! s:lod_map(map, name, prefix)
|
||||
call feedkeys(a:prefix . substitute(a:map, '^<Plug>', "\<Plug>", '') . extra)
|
||||
endfunction
|
||||
|
||||
function! s:add(force, repo, ...)
|
||||
function! s:add(repo, ...)
|
||||
if a:0 > 1
|
||||
return s:err('Invalid number of arguments (1..2)')
|
||||
endif
|
||||
@@ -314,19 +339,11 @@ function! s:add(force, repo, ...)
|
||||
try
|
||||
let repo = s:trim(a:repo)
|
||||
let name = fnamemodify(repo, ':t:s?\.git$??')
|
||||
if !a:force && has_key(g:plugs, name)
|
||||
let s:extended[name] = g:plugs[name]
|
||||
return
|
||||
endif
|
||||
|
||||
let spec = extend(s:infer_properties(name, repo),
|
||||
\ a:0 == 1 ? s:parse_options(a:1) : copy(s:base_spec))
|
||||
if !a:force
|
||||
let s:extended[name] = spec
|
||||
endif
|
||||
|
||||
\ a:0 == 1 ? s:parse_options(a:1) : s:base_spec)
|
||||
let g:plugs[name] = spec
|
||||
let g:plugs_order += [name]
|
||||
let s:loaded[spec.dir] = 0
|
||||
catch
|
||||
return s:err(v:exception)
|
||||
endtry
|
||||
@@ -354,7 +371,7 @@ endfunction
|
||||
function! s:infer_properties(name, repo)
|
||||
let repo = a:repo
|
||||
if s:is_local_plug(repo)
|
||||
let properties = { 'dir': s:dirpath(expand(repo)), 'local': 1 }
|
||||
return { 'dir': s:dirpath(expand(repo)) }
|
||||
else
|
||||
if repo =~ ':'
|
||||
let uri = repo
|
||||
@@ -362,32 +379,32 @@ function! s:infer_properties(name, repo)
|
||||
if repo !~ '/'
|
||||
let repo = 'vim-scripts/'. repo
|
||||
endif
|
||||
let uri = 'https://git:@github.com/' . repo . '.git'
|
||||
let uri = 'https://git::@github.com/' . repo . '.git'
|
||||
endif
|
||||
let dir = s:dirpath( fnamemodify(join([g:plug_home, a:name], '/'), ':p') )
|
||||
let properties = { 'dir': dir, 'uri': uri }
|
||||
return { 'dir': dir, 'uri': uri }
|
||||
endif
|
||||
return properties
|
||||
endfunction
|
||||
|
||||
function! s:install(...)
|
||||
call s:update_impl(0, a:000)
|
||||
function! s:install(force, ...)
|
||||
call s:update_impl(0, a:force, a:000)
|
||||
endfunction
|
||||
|
||||
function! s:update(...)
|
||||
call s:update_impl(1, a:000)
|
||||
function! s:update(force, ...)
|
||||
call s:update_impl(1, a:force, a:000)
|
||||
endfunction
|
||||
|
||||
function! s:apply()
|
||||
function! plug#helptags()
|
||||
if !exists('g:plugs')
|
||||
return s:err('plug#begin was not called')
|
||||
endif
|
||||
for spec in values(g:plugs)
|
||||
let docd = join([spec.dir, 'doc'], '/')
|
||||
if isdirectory(docd)
|
||||
silent! execute 'helptags '. join([spec.dir, 'doc'], '/')
|
||||
silent! execute 'helptags '. s:esc(docd)
|
||||
endif
|
||||
endfor
|
||||
runtime! plugin/*.vim
|
||||
runtime! after/*.vim
|
||||
silent! source $MYVIMRC
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! s:syntax()
|
||||
@@ -407,6 +424,7 @@ function! s:syntax()
|
||||
syn match plugCommit /^ [0-9a-z]\{7} .*/ contains=plugRelDate,plugSha
|
||||
syn match plugSha /\(^ \)\@<=[0-9a-z]\{7}/ contained
|
||||
syn match plugRelDate /([^)]*)$/ contained
|
||||
syn match plugNotLoaded /(not loaded)$/
|
||||
syn match plugError /^x.*/
|
||||
syn keyword Function PlugInstall PlugStatus PlugUpdate PlugClean
|
||||
hi def link plug1 Title
|
||||
@@ -427,6 +445,8 @@ function! s:syntax()
|
||||
hi def link plugError Error
|
||||
hi def link plugRelDate Comment
|
||||
hi def link plugSha Identifier
|
||||
|
||||
hi def link plugNotLoaded Comment
|
||||
endfunction
|
||||
|
||||
function! s:lpad(str, len)
|
||||
@@ -447,6 +467,7 @@ function! s:prepare()
|
||||
else
|
||||
execute winnr . 'wincmd w'
|
||||
endif
|
||||
setlocal modifiable
|
||||
silent %d _
|
||||
else
|
||||
vertical topleft new
|
||||
@@ -461,7 +482,9 @@ function! s:prepare()
|
||||
call s:assign_name()
|
||||
endif
|
||||
silent! unmap <buffer> <cr>
|
||||
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap cursorline
|
||||
silent! unmap <buffer> L
|
||||
silent! unmap <buffer> X
|
||||
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap cursorline modifiable
|
||||
setf vim-plug
|
||||
call s:syntax()
|
||||
endfunction
|
||||
@@ -478,15 +501,16 @@ function! s:assign_name()
|
||||
silent! execute 'f '.fnameescape(name)
|
||||
endfunction
|
||||
|
||||
function! s:do(pull, todo)
|
||||
function! s:do(pull, force, todo)
|
||||
for [name, spec] in items(a:todo)
|
||||
if !isdirectory(spec.dir)
|
||||
continue
|
||||
endif
|
||||
execute 'cd '.s:esc(spec.dir)
|
||||
let installed = has_key(s:prev_update.new, name)
|
||||
if installed || (a:pull &&
|
||||
\ !empty(s:system_chomp('git log --pretty=format:"%h" "HEAD...HEAD@{1}"')))
|
||||
let updated = installed ? 0 :
|
||||
\ (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 .' ... ')
|
||||
let type = type(spec.do)
|
||||
if type == s:TYPE.string
|
||||
@@ -501,7 +525,8 @@ function! s:do(pull, todo)
|
||||
endtry
|
||||
elseif type == s:TYPE.funcref
|
||||
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!'
|
||||
catch
|
||||
let result = 'Error: ' . v:exception
|
||||
@@ -518,10 +543,11 @@ endfunction
|
||||
function! s:finish(pull)
|
||||
call append(3, '- Finishing ... ')
|
||||
redraw
|
||||
call s:apply()
|
||||
call s:syntax()
|
||||
call plug#helptags()
|
||||
call plug#end()
|
||||
call setline(4, getline(4) . 'Done!')
|
||||
normal! gg
|
||||
call s:syntax()
|
||||
redraw
|
||||
let msgs = []
|
||||
if !empty(s:prev_update.errors)
|
||||
@@ -537,7 +563,7 @@ function! s:retry()
|
||||
if empty(s:prev_update.errors)
|
||||
return
|
||||
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]))
|
||||
endfunction
|
||||
|
||||
@@ -549,7 +575,7 @@ function! s:names(...)
|
||||
return filter(keys(g:plugs), 'stridx(v:val, a:1) == 0 && s:is_managed(v:val)')
|
||||
endfunction
|
||||
|
||||
function! s:update_impl(pull, args) abort
|
||||
function! s:update_impl(pull, force, args) abort
|
||||
let st = reltime()
|
||||
let args = copy(a:args)
|
||||
let threads = (len(args) > 0 && args[-1] =~ '^[1-9][0-9]*$') ?
|
||||
@@ -566,17 +592,22 @@ function! s:update_impl(pull, 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 len = len(g:plugs)
|
||||
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
|
||||
try
|
||||
let imd = &imd
|
||||
@@ -606,44 +637,11 @@ function! s:update_impl(pull, args) abort
|
||||
else
|
||||
call s:update_serial(a:pull, todo)
|
||||
endif
|
||||
call s:do(a:pull, filter(copy(todo), 'has_key(v:val, "do")'))
|
||||
if len(g:plugs) > len
|
||||
call plug#end()
|
||||
endif
|
||||
call s:do(a:pull, a:force, filter(copy(todo), 'has_key(v:val, "do")'))
|
||||
call s:finish(a:pull)
|
||||
call setline(1, 'Updated. Elapsed time: ' . split(reltimestr(reltime(st)))[0] . ' sec.')
|
||||
endfunction
|
||||
|
||||
function! s:find_plugfiles()
|
||||
let plugfiles = {}
|
||||
for pf in split(globpath(g:plug_home, '*/'.s:plug_file), '\n')
|
||||
let plugfiles[fnamemodify(pf, ':h:t')] = pf
|
||||
endfor
|
||||
return plugfiles
|
||||
endfunction
|
||||
|
||||
function! s:extend(names, ...)
|
||||
let s:extended = {}
|
||||
let plugfiles = a:0 > 0 ? a:1 : s:find_plugfiles()
|
||||
try
|
||||
command! -nargs=+ Plug call s:add(0, <args>)
|
||||
for name in a:names
|
||||
let spec = g:plugs[name]
|
||||
if spec.local
|
||||
let plugfile = globpath(s:rtp(spec), s:plug_file)
|
||||
if filereadable(plugfile)
|
||||
execute 'source '. s:esc(plugfile)
|
||||
endif
|
||||
elseif has_key(plugfiles, name)
|
||||
execute 'source '. s:esc(plugfiles[name])
|
||||
endif
|
||||
endfor
|
||||
finally
|
||||
command! -nargs=+ Plug call s:add(1, <args>)
|
||||
endtry
|
||||
return s:extended
|
||||
endfunction
|
||||
|
||||
function! s:update_progress(pull, cnt, bar, total)
|
||||
call setline(1, (a:pull ? 'Updating' : 'Installing').
|
||||
\ ' plugins ('.a:cnt.'/'.a:total.')')
|
||||
@@ -659,50 +657,39 @@ function! s:update_serial(pull, todo)
|
||||
let done = {}
|
||||
let bar = ''
|
||||
|
||||
while !empty(todo)
|
||||
for [name, spec] in items(todo)
|
||||
let done[name] = 1
|
||||
if isdirectory(spec.dir)
|
||||
execute 'cd '.s:esc(spec.dir)
|
||||
let [valid, msg] = s:git_valid(spec, 0, 0)
|
||||
if valid
|
||||
let result = a:pull ?
|
||||
\ s:system(
|
||||
\ printf('git checkout -q %s 2>&1 && git pull origin %s 2>&1 && git submodule update --init --recursive 2>&1',
|
||||
\ s:shellesc(spec.branch), s:shellesc(spec.branch))) : 'Already installed'
|
||||
let error = a:pull ? v:shell_error != 0 : 0
|
||||
else
|
||||
let result = msg
|
||||
let error = 1
|
||||
endif
|
||||
cd -
|
||||
for [name, spec] in items(todo)
|
||||
let done[name] = 1
|
||||
if isdirectory(spec.dir)
|
||||
execute 'cd '.s:esc(spec.dir)
|
||||
let [valid, msg] = s:git_valid(spec, 0, 0)
|
||||
if valid
|
||||
let result = a:pull ?
|
||||
\ s:system(
|
||||
\ printf('git checkout -q %s 2>&1 && git pull origin %s 2>&1 && git submodule update --init --recursive 2>&1',
|
||||
\ s:shellesc(spec.branch), s:shellesc(spec.branch))) : 'Already installed'
|
||||
let error = a:pull ? v:shell_error != 0 : 0
|
||||
else
|
||||
let result = s:system(
|
||||
\ printf('git clone --recursive %s -b %s %s 2>&1 && cd %s && git submodule update --init --recursive 2>&1',
|
||||
\ s:shellesc(spec.uri),
|
||||
\ s:shellesc(spec.branch),
|
||||
\ s:shellesc(s:trim(spec.dir)),
|
||||
\ s:shellesc(spec.dir)))
|
||||
let error = v:shell_error != 0
|
||||
if !error | let s:prev_update.new[name] = 1 | endif
|
||||
let result = msg
|
||||
let error = 1
|
||||
endif
|
||||
let bar .= error ? 'x' : '='
|
||||
if error
|
||||
call add(s:prev_update.errors, name)
|
||||
endif
|
||||
call append(3, s:format_message(!error, name, result))
|
||||
call s:update_progress(a:pull, len(done), bar, total)
|
||||
endfor
|
||||
|
||||
let extended = s:extend(keys(todo))
|
||||
if !empty(extended)
|
||||
let todo = filter(extended, '!has_key(done, v:key)')
|
||||
let total += len(todo)
|
||||
call s:update_progress(a:pull, len(done), bar, total)
|
||||
cd -
|
||||
else
|
||||
break
|
||||
let result = s:system(
|
||||
\ printf('git clone --recursive %s -b %s %s 2>&1 && cd %s && git submodule update --init --recursive 2>&1',
|
||||
\ s:shellesc(spec.uri),
|
||||
\ s:shellesc(spec.branch),
|
||||
\ s:shellesc(s:trim(spec.dir)),
|
||||
\ s:shellesc(spec.dir)))
|
||||
let error = v:shell_error != 0
|
||||
if !error | let s:prev_update.new[name] = 1 | endif
|
||||
endif
|
||||
endwhile
|
||||
let bar .= error ? 'x' : '='
|
||||
if error
|
||||
call add(s:prev_update.errors, name)
|
||||
endif
|
||||
call append(3, s:format_message(!error, name, result))
|
||||
call s:update_progress(a:pull, len(done), bar, total)
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:update_parallel(pull, todo, threads)
|
||||
@@ -728,7 +715,20 @@ function! s:update_parallel(pull, todo, threads)
|
||||
%["#{arg.gsub('"', '\"')}"]
|
||||
end
|
||||
|
||||
require 'set'
|
||||
def killall pid
|
||||
pids = [pid]
|
||||
unless `which pgrep`.empty?
|
||||
children = pids
|
||||
until children.empty?
|
||||
children = children.map { |pid|
|
||||
`pgrep -P #{pid}`.lines.map { |l| l.chomp }
|
||||
}.flatten
|
||||
pids += children
|
||||
end
|
||||
end
|
||||
pids.each { |pid| Process.kill 'TERM', pid.to_i rescue nil }
|
||||
end
|
||||
|
||||
require 'thread'
|
||||
require 'fileutils'
|
||||
require 'timeout'
|
||||
@@ -736,7 +736,7 @@ function! s:update_parallel(pull, todo, threads)
|
||||
iswin = VIM::evaluate('s:is_win').to_i == 1
|
||||
pull = VIM::evaluate('a:pull').to_i == 1
|
||||
base = VIM::evaluate('g:plug_home')
|
||||
all = VIM::evaluate('copy(a:todo)')
|
||||
all = VIM::evaluate('a:todo')
|
||||
limit = VIM::evaluate('get(g:, "plug_timeout", 60)')
|
||||
tries = VIM::evaluate('get(g:, "plug_retries", 2)') + 1
|
||||
nthr = VIM::evaluate('a:threads').to_i
|
||||
@@ -811,17 +811,7 @@ function! s:update_parallel(pull, todo, threads)
|
||||
[$? == 0, data.chomp]
|
||||
rescue Timeout::Error, Interrupt => e
|
||||
if fd && !fd.closed?
|
||||
pids = [fd.pid]
|
||||
unless `which pgrep`.empty?
|
||||
children = pids
|
||||
until children.empty?
|
||||
children = children.map { |pid|
|
||||
`pgrep -P #{pid}`.lines.map { |l| l.chomp }
|
||||
}.flatten
|
||||
pids += children
|
||||
end
|
||||
end
|
||||
pids.each { |pid| Process.kill 'TERM', pid.to_i rescue nil }
|
||||
killall fd.pid
|
||||
fd.close
|
||||
end
|
||||
if e.is_a?(Timeout::Error) && tried < tries
|
||||
@@ -859,63 +849,52 @@ function! s:update_parallel(pull, todo, threads)
|
||||
end
|
||||
} if VIM::evaluate('s:mac_gui') == 1
|
||||
|
||||
processed = Set.new
|
||||
progress = iswin ? '' : '--progress'
|
||||
until all.empty?
|
||||
names = all.keys
|
||||
processed.merge names
|
||||
[names.length, nthr].min.times do
|
||||
mtx.synchronize do
|
||||
threads << Thread.new {
|
||||
while pair = take1.call
|
||||
name = pair.first
|
||||
dir, uri, branch = pair.last.values_at *%w[dir uri branch]
|
||||
branch = esc branch
|
||||
subm = "git submodule update --init --recursive 2>&1"
|
||||
exists = File.directory? dir
|
||||
ok, result =
|
||||
if exists
|
||||
dir = esc dir
|
||||
ret, data = bt.call "#{cd} #{dir} && git rev-parse --abbrev-ref HEAD 2>&1 && git config remote.origin.url", nil, nil
|
||||
current_uri = data.lines.to_a.last
|
||||
if !ret
|
||||
if data =~ /^Interrupted|^Timeout/
|
||||
[false, data]
|
||||
else
|
||||
[false, [data.chomp, "PlugClean required."].join($/)]
|
||||
end
|
||||
elsif current_uri.sub(/git:@/, '') != uri.sub(/git:@/, '')
|
||||
[false, ["Invalid URI: #{current_uri}",
|
||||
"Expected: #{uri}",
|
||||
"PlugClean required."].join($/)]
|
||||
[all.length, nthr].min.times do
|
||||
mtx.synchronize do
|
||||
threads << Thread.new {
|
||||
while pair = take1.call
|
||||
name = pair.first
|
||||
dir, uri, branch = pair.last.values_at *%w[dir uri branch]
|
||||
branch = esc branch
|
||||
subm = "git submodule update --init --recursive 2>&1"
|
||||
exists = File.directory? dir
|
||||
ok, result =
|
||||
if exists
|
||||
dir = esc dir
|
||||
ret, data = bt.call "#{cd} #{dir} && git rev-parse --abbrev-ref HEAD 2>&1 && git config remote.origin.url", nil, nil
|
||||
current_uri = data.lines.to_a.last
|
||||
if !ret
|
||||
if data =~ /^Interrupted|^Timeout/
|
||||
[false, data]
|
||||
else
|
||||
if pull
|
||||
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
|
||||
else
|
||||
[true, skip]
|
||||
end
|
||||
[false, [data.chomp, "PlugClean required."].join($/)]
|
||||
end
|
||||
elsif current_uri.sub(/git::?@/, '') != uri.sub(/git::?@/, '')
|
||||
[false, ["Invalid URI: #{current_uri}",
|
||||
"Expected: #{uri}",
|
||||
"PlugClean required."].join($/)]
|
||||
else
|
||||
d = esc dir.sub(%r{[\\/]+$}, '')
|
||||
log.call name, 'Installing ...', :install
|
||||
bt.call "(git clone #{progress} --recursive #{uri} -b #{branch} #{d} 2>&1 && cd #{esc dir} && #{subm})", name, :install
|
||||
if pull
|
||||
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
|
||||
else
|
||||
[true, skip]
|
||||
end
|
||||
end
|
||||
mtx.synchronize { VIM::command("let s:prev_update.new['#{name}'] = 1") } if !exists && ok
|
||||
log.call name, result, ok
|
||||
end
|
||||
} if running
|
||||
end
|
||||
else
|
||||
d = esc dir.sub(%r{[\\/]+$}, '')
|
||||
log.call name, 'Installing ...', :install
|
||||
bt.call "(git clone #{progress} --recursive #{uri} -b #{branch} #{d} 2>&1 && cd #{esc dir} && #{subm})", name, :install
|
||||
end
|
||||
mtx.synchronize { VIM::command("let s:prev_update.new['#{name}'] = 1") } if !exists && ok
|
||||
log.call name, result, ok
|
||||
end
|
||||
} if running
|
||||
end
|
||||
threads.each { |t| t.join rescue nil }
|
||||
mtx.synchronize { threads.clear }
|
||||
extended = Hash[(VIM::evaluate("s:extend(#{names.inspect})") || {}).reject { |k, _|
|
||||
processed.include? k
|
||||
}]
|
||||
tot += extended.length
|
||||
all.merge!(extended)
|
||||
logh.call
|
||||
end
|
||||
threads.each { |t| t.join rescue nil }
|
||||
logh.call
|
||||
refresh.kill if refresh
|
||||
watcher.kill
|
||||
EOF
|
||||
@@ -934,8 +913,8 @@ function! s:progress_bar(line, bar, total)
|
||||
endfunction
|
||||
|
||||
function! s:compare_git_uri(a, b)
|
||||
let a = substitute(a:a, 'git:@', '', '')
|
||||
let b = substitute(a:b, 'git:@', '', '')
|
||||
let a = substitute(a:a, 'git:\{1,2}@', '', '')
|
||||
let b = substitute(a:b, 'git:\{1,2}@', '', '')
|
||||
return a ==# b
|
||||
endfunction
|
||||
|
||||
@@ -1062,16 +1041,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')
|
||||
@@ -1083,18 +1059,21 @@ 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()
|
||||
for spec in values(g:plugs)
|
||||
let spec.frozen = get(spec, 'frozen', 0)
|
||||
let spec.local = get(spec, 'local', 0)
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
@@ -1104,6 +1083,7 @@ function! s:status()
|
||||
call append(1, '')
|
||||
|
||||
let ecnt = 0
|
||||
let unloaded = 0
|
||||
let [cnt, total] = [0, len(g:plugs)]
|
||||
for [name, spec] in items(g:plugs)
|
||||
if has_key(spec, 'uri')
|
||||
@@ -1121,6 +1101,11 @@ function! s:status()
|
||||
endif
|
||||
let cnt += 1
|
||||
let ecnt += !valid
|
||||
" `s:loaded` entry can be missing if PlugUpgraded
|
||||
if valid && get(s:loaded, spec.dir, -1) == 0
|
||||
let unloaded = 1
|
||||
let msg .= ' (not loaded)'
|
||||
endif
|
||||
call s:progress_bar(2, repeat('=', cnt), total)
|
||||
call append(3, s:format_message(valid, name, msg))
|
||||
normal! 2G
|
||||
@@ -1128,6 +1113,24 @@ function! s:status()
|
||||
endfor
|
||||
call setline(1, 'Finished. '.ecnt.' error(s).')
|
||||
normal! gg
|
||||
setlocal nomodifiable
|
||||
if unloaded
|
||||
echo "Press 'L' on each line to load plugin"
|
||||
nnoremap <silent> <buffer> L :call <SID>status_load(line('.'))<cr>
|
||||
xnoremap <silent> <buffer> L :call <SID>status_load(line('.'))<cr>
|
||||
end
|
||||
endfunction
|
||||
|
||||
function! s:status_load(lnum)
|
||||
let line = getline(a:lnum)
|
||||
let matches = matchlist(line, '^- \([^:]*\):.*(not loaded)$')
|
||||
if !empty(matches)
|
||||
let name = matches[1]
|
||||
call plug#load(name)
|
||||
setlocal modifiable
|
||||
call setline(a:lnum, substitute(line, ' (not loaded)$', '', ''))
|
||||
setlocal nomodifiable
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:is_preview_window_open()
|
||||
@@ -1139,34 +1142,43 @@ function! s:is_preview_window_open()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
function! s:find_name(lnum)
|
||||
for lnum in reverse(range(1, a:lnum))
|
||||
let line = getline(lnum)
|
||||
if empty(line)
|
||||
return ''
|
||||
endif
|
||||
let name = matchstr(line, '\(^- \)\@<=[^:]\+')
|
||||
if !empty(name)
|
||||
return name
|
||||
endif
|
||||
endfor
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! s:preview_commit()
|
||||
if b:plug_preview < 0
|
||||
let b:plug_preview = !s:is_preview_window_open()
|
||||
endif
|
||||
|
||||
let sha = matchstr(getline('.'), '\(^ \)\@<=[0-9a-z]\{7}')
|
||||
if !empty(sha)
|
||||
let lnum = line('.')
|
||||
while lnum > 1
|
||||
let lnum -= 1
|
||||
let line = getline(lnum)
|
||||
let name = matchstr(line, '\(^- \)\@<=[^:]\+')
|
||||
if !empty(name)
|
||||
let dir = g:plugs[name].dir
|
||||
if isdirectory(dir)
|
||||
execute 'cd '.s:esc(dir)
|
||||
execute 'pedit '.sha
|
||||
wincmd P
|
||||
setlocal filetype=git buftype=nofile nobuflisted
|
||||
execute 'silent read !git show '.sha
|
||||
normal! ggdd
|
||||
wincmd p
|
||||
cd -
|
||||
endif
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
if empty(sha)
|
||||
return
|
||||
endif
|
||||
|
||||
let name = s:find_name(line('.'))
|
||||
if empty(name) || !has_key(g:plugs, name) || !isdirectory(g:plugs[name].dir)
|
||||
return
|
||||
endif
|
||||
|
||||
execute 'cd '.s:esc(g:plugs[name].dir)
|
||||
execute 'pedit '.sha
|
||||
wincmd P
|
||||
setlocal filetype=git buftype=nofile nobuflisted
|
||||
execute 'silent read !git show '.sha
|
||||
normal! ggdd
|
||||
wincmd p
|
||||
cd -
|
||||
endfunction
|
||||
|
||||
function! s:section(flags)
|
||||
@@ -1200,12 +1212,39 @@ function! s:diff()
|
||||
|
||||
call setline(1, cnt == 0 ? 'No updates.' : 'Last update:')
|
||||
nnoremap <silent> <buffer> <cr> :silent! call <SID>preview_commit()<cr>
|
||||
nnoremap <silent> <buffer> X :call <SID>revert()<cr>
|
||||
normal! gg
|
||||
setlocal nomodifiable
|
||||
if cnt > 0
|
||||
echo "Press 'X' on each block to revert the update"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:revert()
|
||||
let name = s:find_name(line('.'))
|
||||
if empty(name) || !has_key(g:plugs, name) ||
|
||||
\ input(printf('Revert the update of %s? (Y/N) ', name)) !~? '^y'
|
||||
return
|
||||
endif
|
||||
|
||||
execute 'cd '.s:esc(g:plugs[name].dir)
|
||||
call system('git reset --hard HEAD@{1} && git checkout '.s:esc(g:plugs[name].branch))
|
||||
cd -
|
||||
setlocal modifiable
|
||||
normal! dap
|
||||
setlocal nomodifiable
|
||||
echo 'Reverted.'
|
||||
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
|
||||
|
||||
|
||||
26
test/run
26
test/run
@@ -14,8 +14,34 @@ if [ ! -d fzf-staged ]; then
|
||||
git clone https://github.com/junegunn/fzf.git fzf-staged
|
||||
fi
|
||||
|
||||
make_dirs() {
|
||||
mkdir -p "$1"
|
||||
cd "$1"
|
||||
mkdir -p autoload colors ftdetect ftplugin indent plugin syntax
|
||||
for d in *; do
|
||||
cat > $d/xxx.vim << EOF
|
||||
" echom expand('<sfile>')
|
||||
let g:$2 = get(g:, '$2', [])
|
||||
call add(g:$2, '${1:4}/$d')
|
||||
EOF
|
||||
done
|
||||
cd - > /dev/null
|
||||
}
|
||||
|
||||
make_dirs xxx/ xxx
|
||||
make_dirs xxx/after xxx
|
||||
mkdir xxx/doc
|
||||
cat > xxx/doc/xxx.txt << DOC
|
||||
hello *xxx*
|
||||
DOC
|
||||
|
||||
make_dirs yyy/ yyy
|
||||
make_dirs z1/ z1
|
||||
make_dirs z2/ z2
|
||||
|
||||
cat > /tmp/mini-vimrc << VIMRC
|
||||
set rtp+=vader.vim
|
||||
set shell=/bin/bash
|
||||
source $PLUG_SRC
|
||||
VIMRC
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Execute (Initialize test environment):
|
||||
Save &rtp, g:plugs, g:plug_home, $MYVIMRC
|
||||
Save &rtp, g:plugs, g:plug_home
|
||||
|
||||
let first_rtp = split(&rtp, ',')[0]
|
||||
let last_rtp = split(&rtp, ',')[-1]
|
||||
@@ -33,10 +33,11 @@ Execute (Initialize test environment):
|
||||
endfunction
|
||||
command! -nargs=+ -bang AssertExpect call AssertExpect('<bang>' == '!', <args>)
|
||||
|
||||
let g:vimrc_reloaded = 0
|
||||
let vimrc = tempname()
|
||||
call writefile(['let g:vimrc_reloaded += 1'], vimrc)
|
||||
let $MYVIMRC = vimrc
|
||||
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
|
||||
@@ -74,7 +75,7 @@ Execute (Subsequent plug#begin() calls will reuse g:plug_home):
|
||||
Execute (Test Plug command):
|
||||
" Git repo with branch
|
||||
Plug 'junegunn/seoul256.vim', 'yes-t_co'
|
||||
AssertEqual 'https://git:@github.com/junegunn/seoul256.vim.git', g:plugs['seoul256.vim'].uri
|
||||
AssertEqual 'https://git::@github.com/junegunn/seoul256.vim.git', g:plugs['seoul256.vim'].uri
|
||||
AssertEqual join([temp_plugged, 'seoul256.vim/'], '/'), g:plugs['seoul256.vim'].dir
|
||||
AssertEqual 'yes-t_co', g:plugs['seoul256.vim'].branch
|
||||
|
||||
@@ -83,7 +84,7 @@ Execute (Test Plug command):
|
||||
|
||||
" Git repo with tag
|
||||
Plug 'junegunn/goyo.vim', '1.5.2'
|
||||
AssertEqual 'https://git:@github.com/junegunn/goyo.vim.git', g:plugs['goyo.vim'].uri
|
||||
AssertEqual 'https://git::@github.com/junegunn/goyo.vim.git', g:plugs['goyo.vim'].uri
|
||||
AssertEqual join([temp_plugged, 'goyo.vim/'], '/'), g:plugs['goyo.vim'].dir
|
||||
AssertEqual '1.5.2', g:plugs['goyo.vim'].branch
|
||||
|
||||
@@ -98,7 +99,7 @@ Execute (Test Plug command):
|
||||
|
||||
" vim-scripts/
|
||||
Plug 'beauty256'
|
||||
AssertEqual 'https://git:@github.com/vim-scripts/beauty256.git', g:plugs.beauty256.uri
|
||||
AssertEqual 'https://git::@github.com/vim-scripts/beauty256.git', g:plugs.beauty256.uri
|
||||
AssertEqual 'master', g:plugs.beauty256.branch
|
||||
|
||||
AssertEqual 4, len(g:plugs)
|
||||
@@ -133,7 +134,6 @@ Execute (Yet, plugins are not available):
|
||||
|
||||
Execute (PlugInstall):
|
||||
PlugInstall
|
||||
AssertEqual 1, g:vimrc_reloaded
|
||||
q
|
||||
|
||||
Execute (Plugin available after installation):
|
||||
@@ -167,7 +167,6 @@ Expect:
|
||||
Execute (PlugUpdate to set the right branch):
|
||||
PlugUpdate
|
||||
call PlugStatusSorted()
|
||||
AssertEqual 2, g:vimrc_reloaded
|
||||
|
||||
Expect:
|
||||
- goyo.vim: OK
|
||||
@@ -200,8 +199,8 @@ Execute (PlugStatus):
|
||||
call PlugStatusSorted()
|
||||
|
||||
Expect:
|
||||
Expected: https://git:@github.com/junegunn.choi/seoul256.vim.git
|
||||
Invalid URI: https://git:@github.com/junegunn/seoul256.vim.git
|
||||
Expected: https://git::@github.com/junegunn.choi/seoul256.vim.git
|
||||
Invalid URI: https://git::@github.com/junegunn/seoul256.vim.git
|
||||
PlugClean required.
|
||||
- vim-emoji: OK
|
||||
Finished. 1 error(s).
|
||||
@@ -234,7 +233,7 @@ Execute (PlugStatus):
|
||||
call PlugStatusSorted()
|
||||
|
||||
Expect:
|
||||
Expected: https://git:@github.com/junegunn/vim-emoji.git
|
||||
Expected: https://git::@github.com/junegunn/vim-emoji.git
|
||||
Invalid URI: https://bitbucket.org/junegunn/vim-emoji.git
|
||||
Not found. Try PlugInstall.
|
||||
PlugClean required.
|
||||
@@ -254,7 +253,6 @@ Execute (PlugClean! to remove vim-emoji):
|
||||
Execute (PlugUpdate to install both again):
|
||||
PlugUpdate
|
||||
AssertExpect '^- [^:]*:', 2
|
||||
AssertEqual 3, g:vimrc_reloaded
|
||||
Assert !empty(globpath(&rtp, 'colors/seoul256.vim')), 'seoul256.vim should be found'
|
||||
Assert !empty(globpath(&rtp, 'autoload/emoji.vim')), 'vim-emoji should be found'
|
||||
q
|
||||
@@ -262,7 +260,6 @@ Execute (PlugUpdate to install both again):
|
||||
Execute (PlugUpdate only to find out plugins are up-to-date, D key to check):
|
||||
PlugUpdate
|
||||
AssertExpect 'Already up-to-date', 2
|
||||
AssertEqual 4, g:vimrc_reloaded
|
||||
normal D
|
||||
AssertEqual 'No updates.', getline(1)
|
||||
q
|
||||
@@ -310,6 +307,13 @@ Execute (Rollback recent updates, PlugUpdate, then PlugDiff):
|
||||
AssertEqual lnum, line('.')
|
||||
AssertEqual 3, col('.')
|
||||
|
||||
" X key to revert the update
|
||||
AssertExpect '^- ', 2
|
||||
execute "normal Xn\<cr>"
|
||||
AssertExpect '^- ', 2
|
||||
execute "normal Xy\<cr>"
|
||||
AssertExpect '^- ', 1
|
||||
|
||||
" q will close preview window as well
|
||||
normal q
|
||||
|
||||
@@ -320,6 +324,7 @@ Execute (Rollback recent updates, PlugUpdate, then PlugDiff):
|
||||
" q should not close preview window if it's already open
|
||||
pedit
|
||||
PlugDiff
|
||||
AssertExpect '^- ', 1
|
||||
execute "normal ]]j\<cr>"
|
||||
normal q
|
||||
|
||||
@@ -333,8 +338,8 @@ Execute (Plug window in a new tab):
|
||||
set buftype=nofile
|
||||
PlugUpdate
|
||||
normal D
|
||||
AssertEqual 'No updates.', getline(1)
|
||||
q
|
||||
AssertExpect '^- ', 1
|
||||
normal q
|
||||
AssertEqual 'new-tab', expand('%')
|
||||
q
|
||||
q
|
||||
@@ -357,7 +362,8 @@ Execute (Trying to execute on-demand commands when plugin is not installed):
|
||||
|
||||
Execute (New set of plugins):
|
||||
call plug#begin()
|
||||
Plug 'junegunn/vim-fnr' " Depends on vim-pseudocl
|
||||
Plug 'junegunn/vim-fnr'
|
||||
Plug 'junegunn/vim-pseudocl'
|
||||
Plug 'junegunn/vim-easy-align', { 'on': 'EasyAlign' }
|
||||
Plug 'junegunn/vim-redis', { 'for': 'redis' }
|
||||
call plug#end()
|
||||
@@ -368,24 +374,29 @@ Execute (Check commands):
|
||||
|
||||
Execute (Partial PlugInstall):
|
||||
PlugInstall vim-fnr vim-easy-align
|
||||
AssertExpect 'vim-pseudocl', 1
|
||||
PlugInstall vim-fnr vim-easy-align 1
|
||||
AssertExpect 'vim-pseudocl', 1
|
||||
AssertExpect 'vim-fnr', 1
|
||||
q
|
||||
|
||||
Execute (Check dependent plugin):
|
||||
Assert &rtp =~ 'pseudocl', &rtp
|
||||
PlugInstall vim-fnr vim-easy-align 1
|
||||
AssertExpect 'vim-fnr', 1
|
||||
AssertExpect 'vim-easy-align', 1
|
||||
AssertEqual first_rtp, split(&rtp, ',')[0]
|
||||
AssertEqual last_rtp, split(&rtp, ',')[-1]
|
||||
q
|
||||
|
||||
Given (Unaligned code):
|
||||
a=1
|
||||
aa=2
|
||||
|
||||
Execute (Check installed plugins):
|
||||
if has('vim_starting')
|
||||
Log 'Vader is run from commandline'
|
||||
runtime! plugin/**/*.vim
|
||||
endif
|
||||
Assert exists(':FNR'), 'FNR command should be found'
|
||||
Assert exists(':EasyAlign'), 'EasyAlign command should be found'
|
||||
Assert !exists(':RedisExecute'), 'RedisExecute command still should not be found'
|
||||
|
||||
Assert exists(':EasyAlign'), 'EasyAlign command should be found'
|
||||
%EasyAlign=
|
||||
|
||||
Expect (Aligned code):
|
||||
@@ -509,15 +520,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
|
||||
@@ -624,6 +635,14 @@ Execute (When already installed):
|
||||
Assert !filereadable(g:plugs['vim-easy-align'].dir.'/installed2'),
|
||||
\ 'vim-easy-align/installed2 should not exist'
|
||||
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'
|
||||
|
||||
Execute (When already updated):
|
||||
@@ -637,11 +656,19 @@ Execute (When already updated):
|
||||
Assert !filereadable(g:plugs['vim-easy-align'].dir.'/updated2'),
|
||||
\ 'vim-easy-align/updated2 should not exist'
|
||||
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'
|
||||
|
||||
Execute (Using Funcref):
|
||||
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
|
||||
|
||||
call plug#begin()
|
||||
@@ -655,11 +682,26 @@ Execute (Using Funcref):
|
||||
PlugUpdate
|
||||
Log getline(1, '$')
|
||||
q
|
||||
Assert filereadable(g:plugs['vim-easy-align'].dir.'/vim-easy-alignupdated2'),
|
||||
\ 'vim-easy-align/vim-easy-alignupdated2 should exist'
|
||||
Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclinstalled2'),
|
||||
\ 'vim-pseudocl/vim-pseudoclinstalled2 should exist'
|
||||
Assert filereadable(g:plugs['vim-easy-align'].dir.'/vim-easy-alignupdated03'),
|
||||
\ 'vim-easy-align/vim-easy-alignupdated03 should exist'
|
||||
Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclinstalled03'),
|
||||
\ '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`
|
||||
@@ -668,6 +710,7 @@ Execute (Using Funcref):
|
||||
Execute (Using custom dir):
|
||||
Assert isdirectory(g:plugs['vim-easy-align'].dir)
|
||||
|
||||
call system('rm -rf '.$TMPDIR.'easy-align')
|
||||
call plug#begin()
|
||||
Plug 'junegunn/vim-easy-align', { 'dir': $TMPDIR.'easy-align' }
|
||||
call plug#end()
|
||||
@@ -681,19 +724,142 @@ Execute (Using custom dir):
|
||||
q
|
||||
Assert isdirectory(g:plugs['vim-easy-align'].dir)
|
||||
|
||||
Execute (Cleanup):
|
||||
call system('rm -rf '.temp_plugged)
|
||||
call rename('fzf', 'fzf-staged')
|
||||
**********************************************************************
|
||||
~ On-demand loading load order
|
||||
**********************************************************************
|
||||
Before (Clear global vars):
|
||||
let g:xxx = []
|
||||
set rtp-=$PWD/xxx/
|
||||
set rtp-=$PWD/xxx/after
|
||||
|
||||
unlet g:plugs
|
||||
unlet g:plug_home
|
||||
unlet g:vimrc_reloaded
|
||||
unlet temp_plugged vader plug basertp save_rtp repo lnum fzf out
|
||||
delf PlugStatusSorted
|
||||
delf AssertExpect
|
||||
delf PlugUpdated
|
||||
delc AssertExpect
|
||||
unmap /
|
||||
unmap ?
|
||||
Execute (Immediate loading):
|
||||
call plug#begin()
|
||||
Plug '$PWD/xxx'
|
||||
call plug#end()
|
||||
|
||||
" FIXME:
|
||||
" Different result when Vader is run from commandline with `-c` option
|
||||
Log g:xxx
|
||||
if has('vim_starting')
|
||||
AssertEqual ['/ftdetect', 'after/ftdetect'], g:xxx
|
||||
else
|
||||
AssertEqual ['/plugin', 'after/plugin', '/ftdetect', 'after/ftdetect'], g:xxx
|
||||
endif
|
||||
|
||||
Execute (Command-based on-demand loading):
|
||||
call plug#begin()
|
||||
Plug '$PWD/xxx', { 'on': 'XXX' }
|
||||
call plug#end()
|
||||
|
||||
AssertEqual [], g:xxx
|
||||
|
||||
silent! XXX
|
||||
AssertEqual ['/ftdetect', 'after/ftdetect', '/plugin', 'after/plugin'], g:xxx
|
||||
|
||||
setf xxx
|
||||
AssertEqual ['/ftdetect', 'after/ftdetect', '/plugin', 'after/plugin', '/ftplugin', 'after/ftplugin', '/indent', 'after/indent', '/syntax', 'after/syntax'], g:xxx
|
||||
|
||||
Execute (Filetype-based on-demand loading):
|
||||
call plug#begin()
|
||||
Plug '$PWD/xxx', { 'for': 'xxx' }
|
||||
call plug#end()
|
||||
|
||||
AssertEqual ['/ftdetect', 'after/ftdetect'], g:xxx
|
||||
|
||||
setf xxx
|
||||
AssertEqual ['/ftdetect', 'after/ftdetect', '/plugin', 'after/plugin', '/ftplugin', 'after/ftplugin', '/indent', 'after/indent', '/syntax', 'after/syntax'], g:xxx
|
||||
|
||||
Before:
|
||||
|
||||
**********************************************************************
|
||||
~ plug#helptags()
|
||||
**********************************************************************
|
||||
|
||||
Execute (plug#helptags):
|
||||
silent! call delete(expand('$PWD/xxx/doc/tags'))
|
||||
Assert !filereadable(expand('$PWD/xxx/doc/tags'))
|
||||
AssertEqual 1, plug#helptags()
|
||||
Assert filereadable(expand('$PWD/xxx/doc/tags'))
|
||||
|
||||
**********************************************************************
|
||||
~ Manual loading
|
||||
**********************************************************************
|
||||
|
||||
Execute (plug#load - invalid arguments):
|
||||
AssertEqual 0, plug#load()
|
||||
AssertEqual 0, plug#load('non-existent-plugin')
|
||||
AssertEqual 0, plug#load('non-existent-plugin', 'another-non-existent-plugin')
|
||||
AssertEqual 1, plug#load('xxx')
|
||||
AssertEqual 0, plug#load('xxx', 'non-existent-plugin')
|
||||
AssertEqual 0, plug#load('non-existent-plugin', 'xxx')
|
||||
|
||||
Execute (on: []):
|
||||
call plug#begin()
|
||||
Plug 'junegunn/rust.vim', { 'on': [] }
|
||||
call plug#end()
|
||||
PlugInstall
|
||||
q
|
||||
|
||||
Execute (PlugStatus reports (not loaded)):
|
||||
PlugStatus
|
||||
AssertExpect 'not loaded', 1
|
||||
q
|
||||
|
||||
Execute (plug#load to load it):
|
||||
tabnew test.rs
|
||||
" Vader will switch tab to [Vader-workbench] after Log
|
||||
" Log &filetype
|
||||
AssertEqual 1, plug#load('rust.vim')
|
||||
AssertEqual 'rust', &filetype
|
||||
q
|
||||
|
||||
Execute (PlugStatus should not contain (not loaded)):
|
||||
PlugStatus
|
||||
AssertExpect 'not loaded', 0
|
||||
q
|
||||
|
||||
Execute (Load plugin from PlugStatus screen with L key in normal mode):
|
||||
call plug#begin()
|
||||
Plug '$PWD/yyy', { 'on': [] }
|
||||
call plug#end()
|
||||
|
||||
PlugStatus
|
||||
AssertExpect 'not loaded', 1
|
||||
Assert !exists('g:yyy'), 'yyy not loaded'
|
||||
/not loaded
|
||||
normal L
|
||||
AssertExpect 'not loaded', 0
|
||||
Assert exists('g:yyy'), 'yyy loaded'
|
||||
q
|
||||
|
||||
Execute (Load plugin from PlugStatus screen with L key in visual mode):
|
||||
call plug#begin()
|
||||
Plug '$PWD/z1', { 'on': [] }
|
||||
Plug '$PWD/z2', { 'for': [] }
|
||||
call plug#end()
|
||||
|
||||
PlugStatus
|
||||
AssertExpect 'not loaded', 2
|
||||
Assert !exists('g:z1'), 'z1 not loaded'
|
||||
Assert !exists('g:z2'), 'z2 not loaded'
|
||||
normal ggVGL
|
||||
AssertExpect 'not loaded', 0
|
||||
Assert exists('g:z1'), 'z1 loaded'
|
||||
Assert exists('g:z2'), 'z2 loaded'
|
||||
q
|
||||
|
||||
Execute (Cleanup):
|
||||
silent! call system('rm -rf '.temp_plugged)
|
||||
silent! call rename('fzf', 'fzf-staged')
|
||||
silent! unlet g:plugs
|
||||
silent! unlet g:plug_home
|
||||
silent! unlet temp_plugged vader plug basertp save_rtp repo lnum fzf out
|
||||
silent! delf PlugStatusSorted
|
||||
silent! delf AssertExpect
|
||||
silent! delf PlugUpdated
|
||||
silent! delc AssertExpect
|
||||
silent! unmap /
|
||||
silent! unmap ?
|
||||
|
||||
Restore
|
||||
|
||||
|
||||
Reference in New Issue
Block a user