14 Commits
0.5.0 ... 0.5.2

Author SHA1 Message Date
Junegunn Choi
93628b1c3d Forced run of post-update hooks using bang commands
PlugInstall! / PlugUpdate!
2014-08-02 12:13:52 +09:00
Junegunn Choi
01e126469b Remove duplicate expression and escape helptags directory 2014-08-02 02:52:56 +09:00
Junegunn Choi
a7477f04b7 Update README 2014-08-02 01:12:01 +09:00
Junegunn Choi
0fdb56ba72 Update README 2014-08-02 01:00:59 +09:00
Junegunn Choi
d89949f16c Update README.md 2014-08-01 23:46:50 +09:00
Junegunn Choi
19b8221c14 Update README 2014-08-01 23:37:19 +09:00
Junegunn Choi
336fadd236 Remove FAQ/Troubleshooting section and add link to wiki page 2014-08-01 23:33:26 +09:00
Junegunn Choi
a216e38a59 Merge pull request #44 from FriedSock/test_refactoring
Force use of bash for Vader tests.
2014-08-01 23:26:26 +09:00
Jack Bracewell
d930594686 Force use of bash for Vader tests.
If not using a bash compatible shell (like fish), then this will be
set as the default Vim shell. Leading to half the tests failing with
E484: CAN’T OPEN FILE
2014-08-01 15:16:21 +01:00
Junegunn Choi
f4261711ae Update README 2014-08-01 02:01:31 +09:00
Junegunn Choi
61b77bc8e8 Fix many subtle issues regarding on-demand loading etc.
- On-demand loading
    - Fix loading of unwanted files (e.g. colors/*.vim, syntax/*.vim, etc.)
- Filetyp-based on-demand loading
    - Load `after/ftdetect` as well
    - Make sure indent files are loaded by invoking
      `doautocmd filetypeindent FileType`
- Ensure plugin loaded when it was added after Vim started
- Do not reload $MYVIMRC after installtion/update
    - Instead simply call plug#end()
2014-07-31 16:34:41 +09:00
Junegunn Choi
fe7c7e7b40 Minor tweaks 2014-07-31 03:04:59 +09:00
Junegunn Choi
25afdf138c Refactoring
- Remove dead code
- Extract method
2014-07-31 01:01:59 +09:00
Junegunn Choi
b36fd34da0 Ensure files under after are loaded when first installed 2014-07-31 00:17:21 +09:00
4 changed files with 208 additions and 169 deletions

112
README.md
View File

@@ -1,25 +1,22 @@
![vim-plug](https://raw.github.com/junegunn/vim-plug/master/plug.png) ![vim-plug](https://raw.github.com/junegunn/vim-plug/master/plug.png)
![travis-ci](https://travis-ci.org/junegunn/vim-plug.svg?branch=master) ![travis-ci](https://travis-ci.org/junegunn/vim-plug.svg?branch=master)
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.
![](https://raw.github.com/junegunn/i/master/vim-plug/installer.gif) ![](https://raw.github.com/junegunn/i/master/vim-plug/installer.gif)
### Pros. ### Pros.
- Easier to setup - Easier to setup: Single file. No boilerplate code required.
- Parallel installation/update (requires - Easier to use: Concise, intuitive syntax
[+ruby](http://junegunn.kr/2013/09/installing-vim-with-ruby-support/)) - [Super-fast](https://raw.github.com/junegunn/i/master/vim-plug/40-in-4.gif)
- Smallest possible feature set parallel installation/update (requires
- Branch/tag support [+ruby](https://github.com/junegunn/vim-plug/wiki/ruby))
- On-demand loading - On-demand loading to achieve
[fast startup time](http://junegunn.kr/images/vim-startup-time.png)
### Cons. - Post-update hooks
- Can choose a specific branch or tag for each plugin
- Everything else - Support for externally managed plugins
### Usage ### Usage
@@ -123,7 +120,7 @@ Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
Plug 'junegunn/vader.vim', { 'on': 'Vader', 'for': 'vader' } Plug 'junegunn/vader.vim', { 'on': 'Vader', 'for': 'vader' }
``` ```
### Post-installation/update hooks ### Post-update hooks
There are some plugins that require extra steps after installation or update. There are some plugins that require extra steps after installation or update.
In that case, use `do` option to describe the task to be performed. In that case, use `do` option to describe the task to be performed.
@@ -137,10 +134,11 @@ takes a single argument.
```vim ```vim
function! BuildYCM(info) function! BuildYCM(info)
" info is a dictionary with two fields " info is a dictionary with 3 fields
" - name: name of the plugin " - name: name of the plugin
" - status: 'installed' or 'updated' " - status: 'installed', 'updated', or 'unchanged'
if a:info.status == 'installed' " - force: set on PlugInstall! or PlugUpdate!
if a:info.status == 'installed' || a:info.force
!./install.sh !./install.sh
endif endif
endfunction endfunction
@@ -148,7 +146,10 @@ endfunction
Plug 'Valloric/YouCompleteMe', { 'do': function('BuildYCM') } Plug 'Valloric/YouCompleteMe', { 'do': function('BuildYCM') }
``` ```
Both forms of post-update hook are executed inside the directory of the plugin. Both forms of post-update hook are executed inside the directory of the plugin
and only run when the repository has changed, but you can force it to run
unconditionally with the bang-versions of the commands: `PlugInstall!` and
`PlugUpdate!`.
Make sure to escape BARs when you write `do` option inline as they are Make sure to escape BARs when you write `do` option inline as they are
mistakenly recognized as command separator for Plug command. mistakenly recognized as command separator for Plug command.
@@ -165,75 +166,16 @@ let g:fzf_install = 'yes | ./install'
Plug 'junegunn/fzf', { 'do': g:fzf_install } Plug 'junegunn/fzf', { 'do': g:fzf_install }
``` ```
### FAQ/Troubleshooting
See [FAQ/Troubleshooting](https://github.com/junegunn/vim-plug/wiki/faq).
### Articles ### Articles
- [Writing my own Vim plugin manager](http://junegunn.kr/2013/09/writing-my-own-vim-plugin-manager) - [Writing my own Vim plugin manager](http://junegunn.kr/2013/09/writing-my-own-vim-plugin-manager)
- [Thoughts on Vim plugin dependency](http://junegunn.kr/2013/09/thoughts-on-vim-plugin-dependency)
- *Support for Plugfile has been removed since 0.5.0*
- [Vim plugins and startup time](http://junegunn.kr/2014/07/vim-plugins-and-startup-time) - [Vim plugins and startup time](http://junegunn.kr/2014/07/vim-plugins-and-startup-time)
- ~~[Thoughts on Vim plugin dependency](http://junegunn.kr/2013/09/thoughts-on-vim-plugin-dependency)~~
### FAQ/Troubleshooting - *Support for Plugfile has been removed since 0.5.0*
#### Plugins are not installed/updated in parallel
Your Vim does not support Ruby interface. `:echo has('ruby')` should print 1.
In order to setup Vim with Ruby support, you may refer to [this
article](http://junegunn.kr/2013/09/installing-vim-with-ruby-support).
#### *Vim: Caught deadly signal SEGV*
If your Vim crashes with the above message, first check if its Ruby interface is
working correctly with the following command:
```vim
:ruby puts RUBY_VERSION
```
If Vim crashes even with this command, it is likely that Ruby interface is
broken, and you have to rebuild Vim with a working version of Ruby.
(`brew remove vim && brew install vim` or `./configure && make ...`)
If you're on OS X, one possibility is that you had installed Vim with
[Homebrew](http://brew.sh/) while using a Ruby installed with
[RVM](http://rvm.io/) or [rbenv](https://github.com/sstephenson/rbenv) and later
removed that version of Ruby.
[Please let me know](https://github.com/junegunn/vim-plug/issues) if you can't
resolve the problem. In the meantime, you can set `g:plug_threads` to 1, so that
Ruby installer is not used at all.
#### Errors on fish shell
If vim-plug doesn't work correctly on fish shell, you might need to add `set
shell=/bin/sh` to your .vimrc.
Refer to the following links for the details:
- http://badsimplicity.com/vim-fish-e484-cant-open-file-tmpvrdnvqe0-error/
- https://github.com/junegunn/vim-plug/issues/12
#### Freezing plugin version with commit hash
vim-plug does not allow you to freeze the version of a plugin with its commit
hash. This is by design. I don't believe a user of a plugin should be looking
at its individual commits. Instead, one should be choosing the right version
using release tags or versioned branches (e.g. 1.2.3, stable, devel, etc.)
```vim
Plug 'junegunn/vim-easy-align', '2.9.2'
```
If the repository doesn't come with such tags or branches, you should think of
it as "unstable" or "in development", and always use its latest revision.
If you really must choose a certain untagged revision, consider forking the
repository.
#### Migrating from other plugin managers
vim-plug does not require any extra statement other than `plug#begin()` and
`plug#end()`. You can remove `filetype off`, `filetype plugin indent on` and
`syntax on` from your .vimrc as they are automatically handled by
`plug#end()`.
### License ### License

117
plug.vim
View File

@@ -73,7 +73,7 @@ let s:plug_buf = -1
let s:mac_gui = has('gui_macvim') && has('gui_running') let s:mac_gui = has('gui_macvim') && has('gui_running')
let s:is_win = has('win32') || has('win64') let s:is_win = has('win32') || has('win64')
let s:me = expand('<sfile>:p') 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 = { let s:TYPE = {
\ 'string': type(''), \ 'string': type(''),
\ 'list': type([]), \ 'list': type([]),
@@ -109,8 +109,8 @@ function! plug#begin(...)
let g:plugs_order = [] let g:plugs_order = []
command! -nargs=+ -bar Plug call s:add(<args>) command! -nargs=+ -bar Plug call s:add(<args>)
command! -nargs=* -complete=customlist,s:names PlugInstall call s:install(<f-args>) command! -nargs=* -bang -complete=customlist,s:names PlugInstall call s:install(!empty('<bang>'), <f-args>)
command! -nargs=* -complete=customlist,s:names PlugUpdate call s:update(<f-args>) command! -nargs=* -bang -complete=customlist,s:names PlugUpdate call s:update(!empty('<bang>'), <f-args>)
command! -nargs=0 -bang PlugClean call s:clean('<bang>' == '!') command! -nargs=0 -bang PlugClean call s:clean('<bang>' == '!')
command! -nargs=0 PlugUpgrade if s:upgrade() | call s:upgrade_specs() | execute 'source '. s:me | endif command! -nargs=0 PlugUpgrade if s:upgrade() | call s:upgrade_specs() | execute 'source '. s:me | endif
command! -nargs=0 PlugStatus call s:status() command! -nargs=0 PlugStatus call s:status()
@@ -123,7 +123,16 @@ 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
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() function! plug#end()
let reload = !has('vim_starting')
if !exists('g:plugs') if !exists('g:plugs')
return s:err('Call plug#begin() first') return s:err('Call plug#begin() first')
endif endif
@@ -144,13 +153,16 @@ function! plug#end()
for name in reverse(copy(g:plugs_order)) for name in reverse(copy(g:plugs_order))
let plug = g:plugs[name] let plug = g:plugs[name]
if !has_key(plug, 'on') && !has_key(plug, 'for') if !has_key(plug, 'on') && !has_key(plug, 'for')
call s:add_rtp(s:rtp(plug)) let rtp = s:rtp(plug)
call s:add_rtp(rtp)
if reload
call s:source(rtp, 'plugin/**/*.vim', 'after/plugin/**/*.vim')
endif
continue continue
endif endif
if has_key(plug, 'on') if has_key(plug, 'on')
let commands = s:to_a(plug.on) for cmd in s:to_a(plug.on)
for cmd in commands
if cmd =~ '^<Plug>.\+' if cmd =~ '^<Plug>.\+'
if empty(mapcheck(cmd)) && empty(mapcheck(cmd, 'i')) if empty(mapcheck(cmd)) && empty(mapcheck(cmd, 'i'))
for [mode, map_prefix, key_prefix] in for [mode, map_prefix, key_prefix] in
@@ -169,9 +181,7 @@ function! plug#end()
endif endif
if has_key(plug, 'for') if has_key(plug, 'for')
for vim in split(globpath(s:rtp(plug), 'ftdetect/**/*.vim'), '\n') call s:source(s:rtp(plug), 'ftdetect/**/*.vim', 'after/ftdetect/**/*.vim')
execute 'source '.vim
endfor
for key in s:to_a(plug.for) for key in s:to_a(plug.for)
if !has_key(lod, key) if !has_key(lod, key)
let lod[key] = [] let lod[key] = []
@@ -264,24 +274,23 @@ function! s:lod(plug, types)
let rtp = s:rtp(a:plug) let rtp = s:rtp(a:plug)
call s:add_rtp(rtp) call s:add_rtp(rtp)
for dir in a:types for dir in a:types
for vim in split(globpath(rtp, dir.'/**/*.vim'), '\n') call s:source(rtp, dir.'/**/*.vim')
execute 'source '.vim
endfor
endfor endfor
endfunction endfunction
function! s:lod_ft(pat, names) function! s:lod_ft(pat, names)
for name in a:names for name in a:names
call s:lod(g:plugs[name], ['plugin', 'after']) call s:lod(g:plugs[name], ['plugin', 'after/plugin'])
endfor endfor
call s:reorg_rtp() call s:reorg_rtp()
execute 'autocmd! PlugLOD FileType ' . a:pat execute 'autocmd! PlugLOD FileType ' . a:pat
silent! doautocmd filetypeplugin FileType silent! doautocmd filetypeplugin FileType
silent! doautocmd filetypeindent FileType
endfunction endfunction
function! s:lod_cmd(cmd, bang, l1, l2, args, name) function! s:lod_cmd(cmd, bang, l1, l2, args, name)
execute 'delc '.a:cmd 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() call s:reorg_rtp()
execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args) execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args)
endfunction endfunction
@@ -289,7 +298,7 @@ endfunction
function! s:lod_map(map, name, prefix) function! s:lod_map(map, name, prefix)
execute 'unmap '.a:map execute 'unmap '.a:map
execute 'iunmap '.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() call s:reorg_rtp()
let extra = '' let extra = ''
while 1 while 1
@@ -311,7 +320,7 @@ function! s:add(repo, ...)
let repo = s:trim(a:repo) let repo = s:trim(a:repo)
let name = fnamemodify(repo, ':t:s?\.git$??') let name = fnamemodify(repo, ':t:s?\.git$??')
let spec = extend(s:infer_properties(name, repo), let spec = extend(s:infer_properties(name, repo),
\ a:0 == 1 ? s:parse_options(a:1) : copy(s:base_spec)) \ a:0 == 1 ? s:parse_options(a:1) : s:base_spec)
let g:plugs[name] = spec let g:plugs[name] = spec
let g:plugs_order += [name] let g:plugs_order += [name]
catch catch
@@ -341,7 +350,7 @@ endfunction
function! s:infer_properties(name, repo) function! s:infer_properties(name, repo)
let repo = a:repo let repo = a:repo
if s:is_local_plug(repo) if s:is_local_plug(repo)
let properties = { 'dir': s:dirpath(expand(repo)), 'local': 1 } return { 'dir': s:dirpath(expand(repo)) }
else else
if repo =~ ':' if repo =~ ':'
let uri = repo let uri = repo
@@ -352,29 +361,25 @@ function! s:infer_properties(name, repo)
let uri = 'https://git:@github.com/' . repo . '.git' let uri = 'https://git:@github.com/' . repo . '.git'
endif endif
let dir = s:dirpath( fnamemodify(join([g:plug_home, a:name], '/'), ':p') ) let dir = s:dirpath( fnamemodify(join([g:plug_home, a:name], '/'), ':p') )
let properties = { 'dir': dir, 'uri': uri } return { 'dir': dir, 'uri': uri }
endif endif
return properties
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:apply() 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
runtime! plugin/*.vim
runtime! after/*.vim
silent! source $MYVIMRC
endfunction endfunction
function! s:syntax() function! s:syntax()
@@ -465,15 +470,16 @@ function! s:assign_name()
silent! execute 'f '.fnameescape(name) silent! execute 'f '.fnameescape(name)
endfunction endfunction
function! s:do(pull, todo) function! s:do(pull, force, todo)
for [name, spec] in items(a:todo) for [name, spec] in items(a:todo)
if !isdirectory(spec.dir) if !isdirectory(spec.dir)
continue continue
endif endif
execute 'cd '.s:esc(spec.dir) execute 'cd '.s:esc(spec.dir)
let installed = has_key(s:prev_update.new, name) let installed = has_key(s:prev_update.new, name)
if installed || (a:pull && let updated = installed ? 0 :
\ !empty(s:system_chomp('git log --pretty=format:"%h" "HEAD...HEAD@{1}"'))) \ (a:pull && !empty(s:system_chomp('git log --pretty=format:"%h" "HEAD...HEAD@{1}"')))
if a:force || installed || updated
call append(3, '- Post-update hook for '. name .' ... ') call append(3, '- Post-update hook for '. name .' ... ')
let type = type(spec.do) let type = type(spec.do)
if type == s:TYPE.string if type == s:TYPE.string
@@ -488,7 +494,8 @@ function! s:do(pull, todo)
endtry endtry
elseif type == s:TYPE.funcref elseif type == s:TYPE.funcref
try try
call spec.do({ 'name': name, 'status': (installed ? 'installed' : 'updated') }) let status = installed ? 'installed' : (updated ? 'updated' : 'unchanged')
call spec.do({ 'name': name, 'status': status, 'force': a:force })
let result = 'Done!' let result = 'Done!'
catch catch
let result = 'Error: ' . v:exception let result = 'Error: ' . v:exception
@@ -505,10 +512,11 @@ endfunction
function! s:finish(pull) function! s:finish(pull)
call append(3, '- Finishing ... ') call append(3, '- Finishing ... ')
redraw redraw
call s:apply() call s:helptags()
call s:syntax() call plug#end()
call setline(4, getline(4) . 'Done!') call setline(4, getline(4) . 'Done!')
normal! gg normal! gg
call s:syntax()
redraw redraw
let msgs = [] let msgs = []
if !empty(s:prev_update.errors) if !empty(s:prev_update.errors)
@@ -524,7 +532,7 @@ function! s:retry()
if empty(s:prev_update.errors) if empty(s:prev_update.errors)
return return
endif endif
call s:update_impl(s:prev_update.pull, call s:update_impl(s:prev_update.pull, s:prev_update.force,
\ extend(copy(s:prev_update.errors), [s:prev_update.threads])) \ extend(copy(s:prev_update.errors), [s:prev_update.threads]))
endfunction endfunction
@@ -536,7 +544,7 @@ function! s:names(...)
return filter(keys(g:plugs), 'stridx(v:val, a:1) == 0 && s:is_managed(v:val)') return filter(keys(g:plugs), 'stridx(v:val, a:1) == 0 && s:is_managed(v:val)')
endfunction endfunction
function! s:update_impl(pull, args) abort function! s:update_impl(pull, force, args) abort
let st = reltime() let st = reltime()
let args = copy(a:args) let args = copy(a:args)
let threads = (len(args) > 0 && args[-1] =~ '^[1-9][0-9]*$') ? let threads = (len(args) > 0 && args[-1] =~ '^[1-9][0-9]*$') ?
@@ -562,8 +570,7 @@ function! s:update_impl(pull, args) abort
if !isdirectory(g:plug_home) if !isdirectory(g:plug_home)
call mkdir(g:plug_home, 'p') call mkdir(g:plug_home, 'p')
endif endif
let len = len(g:plugs) let s:prev_update = { 'errors': [], 'pull': a:pull, 'force': a:force, 'new': {}, 'threads': threads }
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
@@ -593,10 +600,7 @@ function! s:update_impl(pull, args) abort
else else
call s:update_serial(a:pull, todo) call s:update_serial(a:pull, todo)
endif endif
call s:do(a:pull, filter(copy(todo), 'has_key(v:val, "do")')) call s:do(a:pull, a:force, filter(copy(todo), 'has_key(v:val, "do")'))
if len(g:plugs) > len
call plug#end()
endif
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
@@ -674,6 +678,20 @@ function! s:update_parallel(pull, todo, threads)
%["#{arg.gsub('"', '\"')}"] %["#{arg.gsub('"', '\"')}"]
end end
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 'thread'
require 'fileutils' require 'fileutils'
require 'timeout' require 'timeout'
@@ -681,7 +699,7 @@ function! s:update_parallel(pull, todo, threads)
iswin = VIM::evaluate('s:is_win').to_i == 1 iswin = VIM::evaluate('s:is_win').to_i == 1
pull = VIM::evaluate('a:pull').to_i == 1 pull = VIM::evaluate('a:pull').to_i == 1
base = VIM::evaluate('g:plug_home') 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)') limit = VIM::evaluate('get(g:, "plug_timeout", 60)')
tries = VIM::evaluate('get(g:, "plug_retries", 2)') + 1 tries = VIM::evaluate('get(g:, "plug_retries", 2)') + 1
nthr = VIM::evaluate('a:threads').to_i nthr = VIM::evaluate('a:threads').to_i
@@ -756,17 +774,7 @@ function! s:update_parallel(pull, todo, threads)
[$? == 0, data.chomp] [$? == 0, data.chomp]
rescue Timeout::Error, Interrupt => e rescue Timeout::Error, Interrupt => e
if fd && !fd.closed? if fd && !fd.closed?
pids = [fd.pid] killall 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 }
fd.close fd.close
end end
if e.is_a?(Timeout::Error) && tried < tries if e.is_a?(Timeout::Error) && tried < tries
@@ -1028,7 +1036,6 @@ endfunction
function! s:upgrade_specs() function! s:upgrade_specs()
for spec in values(g:plugs) for spec in values(g:plugs)
let spec.frozen = get(spec, 'frozen', 0) let spec.frozen = get(spec, 'frozen', 0)
let spec.local = get(spec, 'local', 0)
endfor endfor
endfunction endfunction

View File

@@ -14,8 +14,26 @@ if [ ! -d fzf-staged ]; then
git clone https://github.com/junegunn/fzf.git fzf-staged git clone https://github.com/junegunn/fzf.git fzf-staged
fi 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:xxx = get(g:, 'xxx', [])
call add(g:xxx, '${1:4}/$d')
EOF
done
cd - > /dev/null
}
make_dirs xxx/
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

View File

@@ -1,5 +1,5 @@
Execute (Initialize test environment): 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 first_rtp = split(&rtp, ',')[0]
let last_rtp = split(&rtp, ',')[-1] let last_rtp = split(&rtp, ',')[-1]
@@ -33,11 +33,6 @@ Execute (Initialize test environment):
endfunction endfunction
command! -nargs=+ -bang AssertExpect call AssertExpect('<bang>' == '!', <args>) 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 (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()
@@ -133,7 +128,6 @@ Execute (Yet, plugins are not available):
Execute (PlugInstall): Execute (PlugInstall):
PlugInstall PlugInstall
AssertEqual 1, g:vimrc_reloaded
q q
Execute (Plugin available after installation): Execute (Plugin available after installation):
@@ -167,7 +161,6 @@ Expect:
Execute (PlugUpdate to set the right branch): Execute (PlugUpdate to set the right branch):
PlugUpdate PlugUpdate
call PlugStatusSorted() call PlugStatusSorted()
AssertEqual 2, g:vimrc_reloaded
Expect: Expect:
- goyo.vim: OK - goyo.vim: OK
@@ -254,7 +247,6 @@ Execute (PlugClean! to remove vim-emoji):
Execute (PlugUpdate to install both again): Execute (PlugUpdate to install both again):
PlugUpdate PlugUpdate
AssertExpect '^- [^:]*:', 2 AssertExpect '^- [^:]*:', 2
AssertEqual 3, g:vimrc_reloaded
Assert !empty(globpath(&rtp, 'colors/seoul256.vim')), 'seoul256.vim should be found' Assert !empty(globpath(&rtp, 'colors/seoul256.vim')), 'seoul256.vim should be found'
Assert !empty(globpath(&rtp, 'autoload/emoji.vim')), 'vim-emoji should be found' Assert !empty(globpath(&rtp, 'autoload/emoji.vim')), 'vim-emoji should be found'
q q
@@ -262,7 +254,6 @@ Execute (PlugUpdate to install both again):
Execute (PlugUpdate only to find out plugins are up-to-date, D key to check): Execute (PlugUpdate only to find out plugins are up-to-date, D key to check):
PlugUpdate PlugUpdate
AssertExpect 'Already up-to-date', 2 AssertExpect 'Already up-to-date', 2
AssertEqual 4, g:vimrc_reloaded
normal D normal D
AssertEqual 'No updates.', getline(1) AssertEqual 'No updates.', getline(1)
q q
@@ -384,9 +375,14 @@ Given (Unaligned code):
aa=2 aa=2
Execute (Check installed plugins): 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(':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(':RedisExecute'), 'RedisExecute command still should not be found'
Assert exists(':EasyAlign'), 'EasyAlign command should be found'
%EasyAlign= %EasyAlign=
Expect (Aligned code): Expect (Aligned code):
@@ -625,6 +621,14 @@ Execute (When already installed):
Assert !filereadable(g:plugs['vim-easy-align'].dir.'/installed2'), Assert !filereadable(g:plugs['vim-easy-align'].dir.'/installed2'),
\ 'vim-easy-align/installed2 should not exist' \ 'vim-easy-align/installed2 should not exist'
Assert !filereadable(g:plugs['vim-pseudocl'].dir.'/installed2'), Assert !filereadable(g:plugs['vim-pseudocl'].dir.'/installed2'),
\ 'vim-pseudocl/installed2 should not exist'
Execute (PlugInstall!):
PlugInstall!
q
Assert filereadable(g:plugs['vim-easy-align'].dir.'/installed2'),
\ 'vim-easy-align/installed2 should exist'
Assert filereadable(g:plugs['vim-pseudocl'].dir.'/installed2'),
\ 'vim-pseudocl/installed2 should exist' \ 'vim-pseudocl/installed2 should exist'
Execute (When already updated): Execute (When already updated):
@@ -638,11 +642,19 @@ Execute (When already updated):
Assert !filereadable(g:plugs['vim-easy-align'].dir.'/updated2'), Assert !filereadable(g:plugs['vim-easy-align'].dir.'/updated2'),
\ 'vim-easy-align/updated2 should not exist' \ 'vim-easy-align/updated2 should not exist'
Assert !filereadable(g:plugs['vim-pseudocl'].dir.'/updated2'), Assert !filereadable(g:plugs['vim-pseudocl'].dir.'/updated2'),
\ 'vim-pseudocl/updated2 should not exist'
Execute (PlugUpdate!):
PlugUpdate!
q
Assert filereadable(g:plugs['vim-easy-align'].dir.'/updated2'),
\ 'vim-easy-align/updated2 should exist'
Assert filereadable(g:plugs['vim-pseudocl'].dir.'/updated2'),
\ 'vim-pseudocl/updated2 should exist' \ 'vim-pseudocl/updated2 should exist'
Execute (Using Funcref): Execute (Using Funcref):
function! PlugUpdated(info) function! PlugUpdated(info)
call system('touch '. a:info.name . a:info.status . len(a:info)) call system('touch '. a:info.name . a:info.status . a:info.force . len(a:info))
endfunction endfunction
call plug#begin() call plug#begin()
@@ -656,11 +668,26 @@ Execute (Using Funcref):
PlugUpdate PlugUpdate
Log getline(1, '$') Log getline(1, '$')
q q
Assert filereadable(g:plugs['vim-easy-align'].dir.'/vim-easy-alignupdated2'), Assert filereadable(g:plugs['vim-easy-align'].dir.'/vim-easy-alignupdated03'),
\ 'vim-easy-align/vim-easy-alignupdated2 should exist' \ 'vim-easy-align/vim-easy-alignupdated03 should exist'
Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclinstalled2'), Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclinstalled03'),
\ 'vim-pseudocl/vim-pseudoclinstalled2 should exist' \ 'vim-pseudocl/vim-pseudoclinstalled03 should exist'
call system('rm -rf '.g:plugs['vim-pseudocl'].dir)
PlugInstall!
q
Assert filereadable(g:plugs['vim-easy-align'].dir.'/vim-easy-alignunchanged13'),
\ 'vim-easy-align/vim-easy-alignunchanged13 should exist'
Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclinstalled13'),
\ 'vim-pseudocl/vim-pseudoclinstalled13 should exist'
call system('cd '.g:plugs['vim-easy-align'].dir.' && git reset --hard HEAD^')
PlugUpdate!
q
Assert filereadable(g:plugs['vim-easy-align'].dir.'/vim-easy-alignupdated13'),
\ 'vim-easy-align/vim-easy-alignupdated13 should exist'
Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclunchanged13'),
\ 'vim-pseudocl/vim-pseudoclunchanged13 should exist'
********************************************************************** **********************************************************************
~ Overriding `dir` ~ Overriding `dir`
@@ -683,19 +710,64 @@ Execute (Using custom dir):
q q
Assert isdirectory(g:plugs['vim-easy-align'].dir) Assert isdirectory(g:plugs['vim-easy-align'].dir)
Execute (Cleanup): **********************************************************************
call system('rm -rf '.temp_plugged) ~ On-demand loading load order
call rename('fzf', 'fzf-staged') **********************************************************************
Before (Clear global vars):
let g:xxx = []
set rtp-=$PWD/xxx/
set rtp-=$PWD/xxx/after
unlet g:plugs Execute (Immediate loading):
unlet g:plug_home call plug#begin()
unlet g:vimrc_reloaded Plug '$PWD/xxx'
unlet temp_plugged vader plug basertp save_rtp repo lnum fzf out call plug#end()
delf PlugStatusSorted
delf AssertExpect " FIXME:
delf PlugUpdated " Different result when Vader is run from commandline with `-c` option
delc AssertExpect Log g:xxx
unmap / if has('vim_starting')
unmap ? 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:
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 Restore