56 Commits
0.7.0 ... 0.7.2

Author SHA1 Message Date
Junegunn Choi
240dc9cbb6 Fix Travis CI build 2015-05-29 01:07:31 +09:00
Junegunn Choi
f85d4d774b Test refactoring 2015-05-28 19:03:49 +09:00
Junegunn Choi
50cd5e5819 Remove unused test code 2015-05-28 14:52:07 +09:00
Junegunn Choi
099057da65 Merge branch 'hori-ryota-feature/fixed-bug-of-on-demand-loading'
Close #236
2015-05-28 14:45:59 +09:00
Junegunn Choi
8e0fcf88c0 Merge branch 'feature/fixed-bug-of-on-demand-loading' 2015-05-28 14:45:30 +09:00
Junegunn Choi
025f314144 Add failing test case for #236 2015-05-28 14:45:14 +09:00
Hori Ryota
48fba1454b Bugfix of on-demand loading 2015-05-28 14:18:35 +09:00
Junegunn Choi
2ed1f27aa2 Explicitly reset s:-variables during test 2015-05-28 12:34:43 +09:00
Junegunn Choi
7760f1c22b Merge pull request #235 from starcraftman/simple_depends
Update examples: inline declaration
2015-05-24 11:41:22 +09:00
Jeremy Pallats/starcraft.man
0bd23f5b47 Inline dependency example. 2015-05-23 19:50:38 -04:00
Junegunn Choi
0227c78910 Merge pull request #233 from itspriddle/fix-diff-display
Specify a format when `git show` displays a commit
2015-05-20 09:48:12 +09:00
Joshua Priddle
8a72305371 Specify a format when git show displays a commit 2015-05-19 14:00:31 -04:00
Junegunn Choi
018b48e071 Merge pull request #232 from junegunn/user-autocmd
Trigger User autocmd when plugin is loaded on demand (#231)
2015-05-20 02:10:01 +09:00
Junegunn Choi
7ace0c42db Trigger User autocmd when plugin is loaded on demand (#231) 2015-05-20 01:38:05 +09:00
Junegunn Choi
179fa7bb82 Check if autocmd defined before doautocmd
This removes `No matching autocommands` message
2015-05-20 00:33:02 +09:00
Junegunn Choi
76bce26ab8 Temporarily change shellredir (#159) 2015-05-15 22:18:07 +09:00
Junegunn Choi
36e4364b81 silent! redraw is simpler 2015-05-11 12:36:55 +09:00
Junegunn Choi
76ec644114 Force evaluation of &statusline before running installer
Close #228
2015-05-11 12:35:48 +09:00
Junegunn Choi
9e0a082a3d Merge pull request #227 from starcraftman/starting
Use Python installer on Neovim during `vim_starting` (#104)
2015-05-07 01:33:14 +09:00
Jeremy Pallats/starcraft.man
9bee42ca0a Neovim Python Support
* Buffer updates now managed by __main__ loop with buf_q.
* Synchronous neovim install temporarily provided by python installer.
* Known issues:
*   No ctrl-c/interrupt support on nvim.
*   Graphical bug: https://github.com/neovim/python-client/issues/103
2015-05-06 12:00:26 -04:00
Junegunn Choi
18313fa43e Update README 2015-05-03 22:10:32 +09:00
Junegunn Choi
32eb4f5cbe Update README 2015-05-02 23:55:55 +09:00
Junegunn Choi
96824ccd14 Merge pull request #219 from starcraftman/py3
Support Python 2.6+ & 3.0+
2015-05-02 23:47:36 +09:00
Jeremy Pallats/starcraft.man
ef4549d2d1 Support Python 2.6+ & 3.0+
* Seamless support of both version with same code.
* Added test version for py3 on RVM = 2.1.0.
2015-05-02 10:21:02 -04:00
Junegunn Choi
d738da2ddb Merge pull request #221 from junegunn/shallow-clone
Shallow clone by default (#122 #217)
2015-04-30 14:01:30 +09:00
Junegunn Choi
d17d10dccb Add test case where shallow-clone is disabled by tag 2015-04-30 13:51:52 +09:00
Junegunn Choi
6677e8bffd Add test case for g:plug_shallow 2015-04-29 13:27:37 +09:00
Junegunn Choi
80ca4ebf54 Shallow clone by default (#122 #217) 2015-04-28 22:54:35 +09:00
Junegunn Choi
8f1df15cc3 Revert "Shallow clone by default (#122 #217)"
This reverts commit c632c1fd6a.
2015-04-28 13:47:14 +09:00
Junegunn Choi
2218b8fe20 Merge pull request #218 from junegunn/shallow-clone
Shallow clone by default #122 #217
2015-04-28 13:42:25 +09:00
Junegunn Choi
c632c1fd6a Shallow clone by default (#122 #217) 2015-04-27 10:50:55 +09:00
Junegunn Choi
42300e0c4d Merge pull request #211 from mhinz/accept-lowercase-plug
Ignore case for "<Plug>"
2015-04-12 21:08:19 +09:00
Marco Hinz
13de76383d Ignore case for "<Plug>" 2015-04-12 13:45:27 +02:00
Junegunn Choi
481a400ba4 Merge pull request #208 from starcraftman/travis_changes
Download Vim source from GitHub
2015-04-08 20:56:44 +09:00
Jeremy Pallats/starcraft.man
02710070a1 Testing changes. 2015-04-08 07:22:46 -04:00
Junegunn Choi
e04f93b162 Improve check of Neovim Job API
Checking for the existence of `jobwait()` function seems like a more
robust way to check if the current Neovim process meets the requirement
of the parallel installer. This condition precludes a very old version
of Neovim built even before the initial Job API was implemented.
2015-04-07 22:28:13 +09:00
Junegunn Choi
923f3fb3d5 Print warning message on old Neovim (#206)
Suggested by @starcraftman.
2015-04-07 22:20:34 +09:00
Junegunn Choi
6a7efea26b Fix local plugin judgement on Windows (#205) 2015-04-07 04:06:59 +09:00
Junegunn Choi
0e3e1cab75 Merge pull request #201 from junegunn/git-upgrade
PlugUpgrade using git (close #200)
2015-04-03 01:26:24 +09:00
Junegunn Choi
27354c826e PlugUpgrade using git 2015-04-03 00:47:18 +09:00
Junegunn Choi
650927980d Merge pull request #198 from starcraftman/new_job_api
New Neovim Job API
2015-03-30 11:40:21 +09:00
Jeremy Pallats/starcraft.man
047fbba4cd New dict format. 2015-03-27 13:03:46 -04:00
Jeremy Pallats/starcraft.man
fa5ece81f7 New neovim jobs API. 2015-03-26 10:41:43 -04:00
Junegunn Choi
e1b7f1ae85 Update usage and license in plug.vim 2015-03-24 00:00:35 +09:00
Junegunn Choi
cf1f644aa8 Merge pull request #194 from starcraftman/master
Fix for #193 Missing status when PlugUpdate
2015-03-23 09:15:59 +09:00
Jeremy Pallats/starcraft.man
8da3942484 Fix for #193 Missing status when PlugUpdate 2015-03-22 15:49:53 -04:00
Junegunn Choi
cbaf4f3088 Allow using Ruby/Python for PlugUpgrade on Windows (#192) 2015-03-15 13:04:47 +09:00
Junegunn Choi
a06687b4ed Slim 2015-03-15 03:13:24 +09:00
Junegunn Choi
9abd50facd Change the default number of threads on Windows to 1 (#191) 2015-03-14 14:32:24 +09:00
Junegunn Choi
b3226fbbf6 Merge pull request #189 from starcraftman/master
Disable Python on Cygwin
2015-03-12 23:06:56 +09:00
Jeremy Pallats/starcraft.man
d0120cfb45 Disable on cygwin for now. 2015-03-12 09:57:12 -04:00
Junegunn Choi
d9b70554e3 Merge pull request #187 from junegunn/python-2.6
Python 2.6 compatibility
2015-03-08 02:40:28 +09:00
Junegunn Choi
3c6ac68947 Python 2.6 compatibility
Tested on
- Vim 7.2.330
- Python 2.6.5
- Ubuntu 10.04
- https://gist.github.com/junegunn/863dcbd78eadece788cd
2015-03-08 02:00:06 +09:00
Junegunn Choi
51dc024b2e Update README (markdown table) 2015-02-27 18:56:30 +09:00
Junegunn Choi
30a2c5cc14 Remove uniq() function from test code 2015-02-25 22:44:18 +09:00
Junegunn Choi
a34b745a21 Fix #184 - Avoid duplicate entries in g:plugs_order 2015-02-25 22:31:39 +09:00
10 changed files with 492 additions and 309 deletions

View File

@@ -4,19 +4,22 @@ rvm:
- 1.9.2 # Test with vim-nox package on ubuntu
- 1.9.3 # Test against python installer
- 2.0.0
- 2.1.0 # Test against python3 installer
before_script: |
sudo apt-get update -y
if [ $(ruby -e 'puts RUBY_VERSION') = 1.9.2 ]; then
sudo apt-get update -y
sudo apt-get install -y vim-nox
sudo ln -s /usr/bin/vim /usr/local/bin/vim
else
hg clone https://code.google.com/p/vim/
git clone --depth 1 https://github.com/vim/vim
cd vim
if [ $(ruby -e 'puts RUBY_VERSION') = 1.9.3 ]; then
sudo apt-get update -y
sudo apt-get install -y python2.7-dev
./configure --with-features=huge --enable-pythoninterp
elif [ $(ruby -e 'puts RUBY_VERSION') = 2.1.0 ]; then
sudo apt-get install -y python3-dev
./configure --with-features=huge --enable-python3interp
else
./configure --with-features=huge --enable-rubyinterp
fi

View File

@@ -1,5 +1,5 @@
<img src="https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.png" height="56" alt="vim-plug">
[![travis-ci](https://travis-ci.org/junegunn/vim-plug.svg?branch=master)](https://travis-ci.org/junegunn/vim-plug)
<img src="https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.png" height="75" alt="vim-plug">[![travis-ci](https://travis-ci.org/junegunn/vim-plug.svg?branch=master)](https://travis-ci.org/junegunn/vim-plug)
===
A minimalist Vim plugin manager.
@@ -10,7 +10,8 @@ A minimalist Vim plugin manager.
- Easier to setup: Single file. No boilerplate code required.
- Easier to use: Concise, intuitive syntax
- [Super-fast][40/4] parallel installation/update
(with [+python][py] or [+ruby][rb] or [Neovim][nv])
(with any of `+python`, `+python3`, `+ruby`, or [Neovim][nv])
- Creates shallow clones to minimize disk space usage and download time
- On-demand loading for [faster startup time][startup-time]
- Can review and rollback updates
- Branch/tag support
@@ -18,8 +19,6 @@ A minimalist Vim plugin manager.
- Support for externally managed plugins
[40/4]: https://raw.githubusercontent.com/junegunn/i/master/vim-plug/40-in-4.gif
[py]: https://github.com/junegunn/vim-plug/wiki/python
[rb]: https://github.com/junegunn/vim-plug/wiki/ruby
[nv]: http://neovim.org/
[startup-time]: http://junegunn.kr/images/vim-startup-time.png
@@ -42,6 +41,9 @@ call plug#begin('~/.vim/plugged')
Plug 'junegunn/seoul256.vim'
Plug 'junegunn/vim-easy-align'
" Group dependencies, vim-snippets depends on ultisnips
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
" On-demand loading
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
@@ -50,7 +52,7 @@ Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
Plug 'https://github.com/junegunn/vim-github-dashboard.git'
" Plugin options
Plug 'nsf/gocode', { 'tag': 'go.weekly.2012-03-13', 'rtp': 'vim' }
Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }
" Plugin outside ~/.vim/plugged with post-update hook
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': 'yes \| ./install' }
@@ -89,13 +91,14 @@ Reload .vimrc and `:PlugInstall` to install plugins.
### Global options
| Flag | Default | Description |
| ------------------- | --------------------------------- | -----------------------------------------------------------|
| `g:plug_threads` | 16 | Default number of threads to use |
| Flag | Default | Description |
| ------------------- | --------------------------------- | ------------------------------------------------------ |
| `g:plug_threads` | 16 | Default number of threads to use |
| `g:plug_timeout` | 60 | Time limit of each task in seconds (*Ruby & Python*) |
| `g:plug_retries` | 2 | Number of retries in case of timeout (*Ruby & Python*) |
| `g:plug_window` | `vertical topleft new` | Command to open plug window |
| `g:plug_url_format` | `https://git::@github.com/%s.git` | `printf` format to build repo URL |
| `g:plug_shallow` | 1 | Use shallow clone |
| `g:plug_window` | `vertical topleft new` | Command to open plug window |
| `g:plug_url_format` | `https://git::@github.com/%s.git` | `printf` format to build repo URL |
### Keybindings
@@ -134,6 +137,10 @@ Plug 'kovisoft/paredit', { 'for': ['clojure', 'scheme'] }
" On-demand loading on both conditions
Plug 'junegunn/vader.vim', { 'on': 'Vader', 'for': 'vader' }
" Code to execute when the plugin is loaded on demand
Plug 'Valloric/YouCompleteMe', { 'for': 'cpp' }
autocmd! User YouCompleteMe call youcompleteme#Enable()
```
`for` option is generally not needed as most plugins for specific file types

BIN
plug.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 23 KiB

387
plug.vim
View File

@@ -3,8 +3,7 @@
"
" Download plug.vim and put it in ~/.vim/autoload
"
" mkdir -p ~/.vim/autoload
" curl -fLo ~/.vim/autoload/plug.vim \
" curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
" https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
"
" Edit your .vimrc
@@ -15,6 +14,9 @@
" Plug 'junegunn/seoul256.vim'
" Plug 'junegunn/vim-easy-align'
"
" " Group dependencies, vim-snippets depends on ultisnips
" Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
"
" " On-demand loading
" Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
" Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
@@ -23,7 +25,7 @@
" Plug 'https://github.com/junegunn/vim-github-dashboard.git'
"
" " Plugin options
" Plug 'nsf/gocode', { 'tag': 'go.weekly.2012-03-13', 'rtp': 'vim' }
" Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }
"
" " Plugin outside ~/.vim/plugged with post-update hook
" Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': 'yes \| ./install' }
@@ -37,7 +39,7 @@
" Visit https://github.com/junegunn/vim-plug for more information.
"
"
" Copyright (c) 2014 Junegunn Choi
" Copyright (c) 2015 Junegunn Choi
"
" MIT License
"
@@ -68,14 +70,12 @@ let g:loaded_plug = 1
let s:cpo_save = &cpo
set cpo&vim
let s:plug_src = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
let s:plug_src = 'https://github.com/junegunn/vim-plug.git'
let s:plug_tab = get(s:, 'plug_tab', -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:py2 = has('python') && !s:is_win
let s:ruby = has('ruby') && (v:version >= 703 || v:version == 702 && has('patch374'))
let s:nvim = has('nvim') && !s:is_win
let s:nvim = has('nvim') && exists('*jobwait') && !s:is_win
let s:me = resolve(expand('<sfile>:p'))
let s:base_spec = { 'branch': 'master', 'frozen': 0 }
let s:TYPE = {
@@ -166,7 +166,7 @@ function! plug#end()
if has_key(plug, 'on')
let s:triggers[name] = { 'map': [], 'cmd': [] }
for cmd in s:to_a(plug.on)
if cmd =~ '^<Plug>.\+'
if cmd =~? '^<Plug>.\+'
if empty(mapcheck(cmd)) && empty(mapcheck(cmd, 'i'))
call s:assoc(lod.map, cmd, name)
endif
@@ -271,7 +271,7 @@ if s:is_win
endfunction
function! s:is_local_plug(repo)
return a:repo =~? '^[a-z]:'
return a:repo =~? '^[a-z]:\|^[%~]'
endfunction
else
function! s:rtp(spec)
@@ -359,7 +359,9 @@ function! plug#load(...)
for name in a:000
call s:lod([name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
endfor
doautocmd BufRead
if exists('#BufRead')
doautocmd BufRead
endif
return 1
endfunction
@@ -389,14 +391,21 @@ function! s:lod(names, types)
for dir in a:types
call s:source(rtp, dir.'/**/*.vim')
endfor
if exists('#User#'.name)
execute 'doautocmd User' name
endif
endfor
endfunction
function! s:lod_ft(pat, names)
call s:lod(a:names, ['plugin', 'after/plugin'])
execute 'autocmd! PlugLOD FileType' a:pat
doautocmd filetypeplugin FileType
doautocmd filetypeindent FileType
if exists('#filetypeplugin#FileType')
doautocmd filetypeplugin FileType
endif
if exists('#filetypeindent#FileType')
doautocmd filetypeindent FileType
endif
endfunction
function! s:lod_cmd(cmd, bang, l1, l2, args, names)
@@ -427,9 +436,11 @@ function! s:add(repo, ...)
let name = fnamemodify(repo, ':t:s?\.git$??')
let spec = extend(s:infer_properties(name, repo),
\ a:0 == 1 ? s:parse_options(a:1) : s:base_spec)
if !has_key(g:plugs, name)
call add(g:plugs_order, name)
endif
let g:plugs[name] = spec
let g:plugs_order += [name]
let s:loaded[name] = 0
let s:loaded[name] = get(s:loaded, name, 0)
catch
return s:err(v:exception)
endtry
@@ -708,7 +719,7 @@ endfunction
function! s:update_impl(pull, force, args) abort
let args = copy(a:args)
let threads = (len(args) > 0 && args[-1] =~ '^[1-9][0-9]*$') ?
\ remove(args, -1) : get(g:, 'plug_threads', 16)
\ remove(args, -1) : get(g:, 'plug_threads', s:is_win ? 1 : 16)
let managed = filter(copy(g:plugs), 's:is_managed(v:key)')
let todo = empty(args) ? filter(managed, '!v:val.frozen || !isdirectory(v:val.dir)') :
@@ -739,6 +750,16 @@ function! s:update_impl(pull, force, args) abort
endtry
endif
if has('nvim') && !exists('*jobwait') && threads > 1
echohl WarningMsg
echomsg 'vim-plug: update Neovim for parallel installer'
echohl None
endif
let python = (has('python') || has('python3')) && !s:is_win && !has('win32unix')
\ && (!s:nvim || has('vim_starting'))
let ruby = has('ruby') && !s:nvim && (v:version >= 703 || v:version == 702 && has('patch374'))
let s:update = {
\ 'start': reltime(),
\ 'all': todo,
@@ -747,7 +768,7 @@ function! s:update_impl(pull, force, args) abort
\ 'pull': a:pull,
\ 'force': a:force,
\ 'new': {},
\ 'threads': (s:py2 || s:ruby || s:nvim) ? min([len(todo), threads]) : 1,
\ 'threads': (python || ruby || s:nvim) ? min([len(todo), threads]) : 1,
\ 'bar': '',
\ 'fin': 0
\ }
@@ -755,22 +776,27 @@ function! s:update_impl(pull, force, args) abort
call s:prepare()
call append(0, ['', ''])
normal! 2G
silent! redraw
let s:clone_opt = get(g:, 'plug_shallow', 1) ?
\ '--depth 1' . (s:git_version_requirement(1, 7, 10) ? ' --no-single-branch' : '') : ''
" Python version requirement (>= 2.7)
if s:py2 && !s:ruby && !s:nvim && s:update.threads > 1
if python && !has('python3') && !ruby && !s:nvim && s:update.threads > 1
redir => pyv
silent python import platform; print(platform.python_version())
redir END
let s:py2 = s:version_requirement(
\ map(split(split(pyv)[0], '\.'), 'str2nr(v:val)'), [2, 7])
let python = s:version_requirement(
\ map(split(split(pyv)[0], '\.'), 'str2nr(v:val)'), [2, 6])
endif
if (s:py2 || s:ruby) && !s:nvim && s:update.threads > 1
if (python || ruby) && s:update.threads > 1
try
let imd = &imd
if s:mac_gui
set noimd
endif
if s:ruby
if ruby
call s:update_ruby()
else
call s:update_python()
@@ -816,9 +842,7 @@ function! s:job_abort()
if !s:nvim || !exists('s:jobs')
return
endif
augroup PlugJobControl
autocmd!
augroup END
for [name, j] in items(s:jobs)
silent! call jobstop(j.jobid)
if j.new
@@ -828,52 +852,48 @@ function! s:job_abort()
let s:jobs = {}
endfunction
function! s:job_handler(name) abort
" When a:event == 'stdout', data = list of strings
" When a:event == 'exit', data = returncode
function! s:job_handler(job_id, data, event) abort
if !s:plug_window_exists() " plug window closed
return s:job_abort()
endif
if !has_key(s:jobs, a:name)
return
endif
let job = s:jobs[a:name]
if v:job_data[1] == 'exit'
let job.running = 0
if s:lastline(job.result) ==# 'Error'
let job.error = 1
let job.result = substitute(job.result, "Error[\r\n]$", '', '')
endif
call s:reap(a:name)
call s:tick()
else
let job.result .= s:to_s(v:job_data[2])
if a:event == 'stdout'
let self.result .= substitute(s:to_s(a:data), '[\r\n]', '', 'g') . "\n"
" To reduce the number of buffer updates
let job.tick = get(job, 'tick', -1) + 1
if job.tick % len(s:jobs) == 0
call s:log(job.new ? '+' : '*', a:name, job.result)
let self.tick = get(self, 'tick', -1) + 1
if self.tick % len(s:jobs) == 0
call s:log(self.new ? '+' : '*', self.name, self.result)
endif
elseif a:event == 'exit'
let self.running = 0
if a:data != 0
let self.error = 1
endif
call s:reap(self.name)
call s:tick()
endif
endfunction
function! s:spawn(name, cmd, opts)
let job = { 'running': 1, 'new': get(a:opts, 'new', 0),
\ 'error': 0, 'result': '' }
let job = { 'name': a:name, 'running': 1, 'error': 0, 'result': '',
\ 'new': get(a:opts, 'new', 0),
\ 'on_stdout': function('s:job_handler'),
\ 'on_exit' : function('s:job_handler'),
\ }
let s:jobs[a:name] = job
if s:nvim
let x = jobstart(a:name, 'sh', ['-c',
\ (has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd)
\ . ' || echo Error'])
if x > 0
let job.jobid = x
augroup PlugJobControl
execute 'autocmd JobActivity' a:name printf('call s:job_handler(%s)', string(a:name))
augroup END
let argv = [ 'sh', '-c',
\ (has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd) ]
let jid = jobstart(argv, job)
if jid > 0
let job.jobid = jid
else
let job.running = 0
let job.error = 1
let job.result = x < 0 ? 'sh is not executable' :
let job.result = jid < 0 ? 'sh is not executable' :
\ 'Invalid arguments (or job table is full)'
endif
else
@@ -885,10 +905,6 @@ function! s:spawn(name, cmd, opts)
endfunction
function! s:reap(name)
if s:nvim
silent! execute 'autocmd! PlugJobControl JobActivity' a:name
endif
let job = s:jobs[a:name]
if job.error
call add(s:update.errors, a:name)
@@ -964,16 +980,18 @@ while 1 " Without TCO, Vim stack is bound to explode
call s:log(new ? '+' : '*', name, pull ? 'Updating ...' : 'Installing ...')
redraw
let checkout = s:shellesc(has_key(spec, 'tag') ? spec.tag : spec.branch)
let merge = s:shellesc(has_key(spec, 'tag') ? spec.tag : 'origin/'.spec.branch)
let has_tag = has_key(spec, 'tag')
let checkout = s:shellesc(has_tag ? spec.tag : spec.branch)
let merge = s:shellesc(has_tag ? spec.tag : 'origin/'.spec.branch)
if !new
let [valid, msg] = s:git_valid(spec, 0)
if valid
if pull
let fetch_opt = (has_tag && !empty(globpath(spec.dir, '.git/shallow'))) ? '--depth 99999999' : ''
call s:spawn(name,
\ printf('(git fetch %s 2>&1 && git checkout -q %s 2>&1 && git merge --ff-only %s 2>&1 && git submodule update --init --recursive 2>&1)',
\ prog, checkout, merge), { 'dir': spec.dir })
\ printf('(git fetch %s %s 2>&1 && git checkout -q %s 2>&1 && git merge --ff-only %s 2>&1 && git submodule update --init --recursive 2>&1)',
\ fetch_opt, prog, checkout, merge), { 'dir': spec.dir })
else
let s:jobs[name] = { 'running': 0, 'result': 'Already installed', 'error': 0 }
endif
@@ -982,7 +1000,8 @@ while 1 " Without TCO, Vim stack is bound to explode
endif
else
call s:spawn(name,
\ printf('git clone %s --recursive %s -b %s %s 2>&1',
\ printf('git clone %s %s --recursive %s -b %s %s 2>&1',
\ has_tag ? '' : s:clone_opt,
\ prog,
\ s:shellesc(spec.uri),
\ checkout,
@@ -999,12 +1018,16 @@ endwhile
endfunction
function! s:update_python()
python << EOF
let py_exe = has('python3') ? 'python3' : 'python'
execute py_exe "<< EOF"
""" Due to use of signals this function is POSIX only. """
import datetime
import functools
import os
import Queue
try:
import queue
except ImportError:
import Queue as queue
import random
import re
import shutil
@@ -1016,18 +1039,27 @@ import time
import traceback
import vim
G_NVIM = vim.eval("has('nvim')") == '1'
G_PULL = vim.eval('s:update.pull') == '1'
G_RETRIES = int(vim.eval('get(g:, "plug_retries", 2)')) + 1
G_TIMEOUT = int(vim.eval('get(g:, "plug_timeout", 60)'))
G_CLONE_OPT = vim.eval('s:clone_opt')
G_PROGRESS = vim.eval('s:progress_opt(1)')
G_LOG_PROB = 1.0 / int(vim.eval('s:update.threads'))
G_STOP = thr.Event()
G_THREADS = {}
class CmdTimedOut(Exception):
class BaseExc(Exception):
def __init__(self, msg):
self._msg = msg
@property
def msg(self):
return self._msg
class CmdTimedOut(BaseExc):
pass
class CmdFailed(Exception):
class CmdFailed(BaseExc):
pass
class InvalidURI(Exception):
class InvalidURI(BaseExc):
pass
class Action(object):
INSTALL, UPDATE, ERROR, DONE = ['+', '*', 'x', '-']
@@ -1050,14 +1082,14 @@ class GLog(object):
fname = cls.LOGDIR + os.path.sep + name
with open(fname, 'ab') as flog:
ltime = datetime.datetime.now().strftime("%H:%M:%S.%f")
msg = '[{},{}] {}{}'.format(name, ltime, msg, '\n')
flog.write(msg)
msg = '[{0},{1}] {2}{3}'.format(name, ltime, msg, '\n')
flog.write(msg.encode())
class Buffer(object):
def __init__(self, lock, num_plugs):
def __init__(self, lock, num_plugs, is_pull, is_win):
self.bar = ''
self.event = 'Updating' if vim.eval('s:update.pull') == '1' else 'Installing'
self.is_win = vim.eval('s:is_win') == '1'
self.event = 'Updating' if is_pull else 'Installing'
self.is_win = is_win
self.lock = lock
self.maxy = int(vim.eval('winheight(".")'))
self.num_plugs = num_plugs
@@ -1065,7 +1097,7 @@ class Buffer(object):
def _where(self, name):
""" Find first line with name in current buffer. Return line num. """
found, lnum = False, 0
matcher = re.compile('^[-+x*] {}:'.format(name))
matcher = re.compile('^[-+x*] {0}:'.format(name))
for line in vim.current.buffer:
if matcher.search(line) is not None:
found = True
@@ -1078,29 +1110,26 @@ class Buffer(object):
def header(self):
curbuf = vim.current.buffer
curbuf[0] = self.event + ' plugins ({}/{})'.format(len(self.bar), self.num_plugs)
curbuf[0] = self.event + ' plugins ({0}/{1})'.format(len(self.bar), self.num_plugs)
num_spaces = self.num_plugs - len(self.bar)
curbuf[1] = '[{}{}]'.format(self.bar, num_spaces * ' ')
curbuf[1] = '[{0}{1}]'.format(self.bar, num_spaces * ' ')
vim.command('normal! 2G')
if not self.is_win:
vim.command('redraw')
def write(self, *args, **kwargs):
with self.lock:
self._write(*args, **kwargs)
vim.command('normal! 2G')
if not self.is_win:
vim.command('redraw')
def _write(self, action, name, lines):
def write(self, action, name, lines):
first, rest = lines[0], lines[1:]
msg = ['{} {}{}{}'.format(action, name, ': ' if first else '', first)]
msg = ['{0} {1}{2}{3}'.format(action, name, ': ' if first else '', first)]
padded_rest = [' ' + line for line in rest]
msg.extend(padded_rest)
try:
if action == Action.ERROR:
self.bar += 'x'
vim.command("call add(s:update.errors, '{}')".format(name))
vim.command("call add(s:update.errors, '{0}')".format(name))
elif action == Action.DONE:
self.bar += '='
@@ -1108,7 +1137,7 @@ class Buffer(object):
lnum = self._where(name)
if lnum != -1: # Found matching line num
del curbuf[lnum]
if lnum > self.maxy and action in {Action.INSTALL, Action.UPDATE}:
if lnum > self.maxy and action in set([Action.INSTALL, Action.UPDATE]):
lnum = 3
else:
lnum = 3
@@ -1143,7 +1172,7 @@ class Command(object):
for count in range(3, 0, -1):
if G_STOP.is_set():
raise KeyboardInterrupt
msg = 'Timeout. Will retry in {} second{} ...'.format(
msg = 'Timeout. Will retry in {0} second{1} ...'.format(
count, 's' if count != 1 else '')
self.callback([msg])
time.sleep(1)
@@ -1162,7 +1191,7 @@ class Command(object):
proc = None
first_line = True
try:
tfile = tempfile.NamedTemporaryFile()
tfile = tempfile.NamedTemporaryFile(mode='w+b', delete=False)
proc = subprocess.Popen(self.cmd, cwd=self.cmd_dir, stdout=tfile,
stderr=subprocess.STDOUT, shell=True, preexec_fn=os.setsid)
while proc.poll() is None:
@@ -1183,7 +1212,7 @@ class Command(object):
raise CmdTimedOut(['Timeout!'])
tfile.seek(0)
result = [line.rstrip() for line in tfile]
result = [line.decode().rstrip() for line in tfile]
if proc.returncode != 0:
msg = ['']
@@ -1195,18 +1224,21 @@ class Command(object):
if self.clean:
self.clean()
raise
finally:
os.remove(tfile.name)
return result
class Plugin(object):
def __init__(self, name, args, buf, lock):
def __init__(self, name, args, buf_q, lock):
self.name = name
self.args = args
self.buf = buf
self.buf_q = buf_q
self.lock = lock
tag = args.get('tag', 0)
self.checkout = esc(tag if tag else args['branch'])
self.merge = esc(tag if tag else 'origin/' + args['branch'])
self.tag = tag
def manage(self):
try:
@@ -1215,15 +1247,15 @@ class Plugin(object):
else:
self.install()
with self.lock:
vim.command("let s:update.new['{}'] = 1".format(self.name))
thread_vim_command("let s:update.new['{0}'] = 1".format(self.name))
except (CmdTimedOut, CmdFailed, InvalidURI) as exc:
self.write(Action.ERROR, self.name, exc.message)
self.write(Action.ERROR, self.name, exc.msg)
except KeyboardInterrupt:
G_STOP.set()
self.write(Action.ERROR, self.name, ['Interrupted!'])
except:
# Any exception except those above print stack trace
msg = 'Trace:\n{}'.format(traceback.format_exc().rstrip())
msg = 'Trace:\n{0}'.format(traceback.format_exc().rstrip())
self.write(Action.ERROR, self.name, msg.split('\n'))
raise
@@ -1239,9 +1271,9 @@ class Plugin(object):
return _clean
self.write(Action.INSTALL, self.name, ['Installing ...'])
callback = functools.partial(self.buf.write, Action.INSTALL, self.name)
cmd = 'git clone {} --recursive {} -b {} {} 2>&1'.format(
G_PROGRESS, self.args['uri'], self.checkout, esc(target))
callback = functools.partial(self.write, Action.INSTALL, self.name)
cmd = 'git clone {0} {1} --recursive {2} -b {3} {4} 2>&1'.format(
'' if self.tag else G_CLONE_OPT, G_PROGRESS, self.args['uri'], self.checkout, esc(target))
com = Command(cmd, None, G_TIMEOUT, G_RETRIES, callback, clean(target))
result = com.attempt_cmd()
self.write(Action.DONE, self.name, result[-1:])
@@ -1252,17 +1284,18 @@ class Plugin(object):
expect_uri = re.sub(match, '', self.args['uri'])
if actual_uri != expect_uri:
msg = ['',
'Invalid URI: {}'.format(actual_uri),
'Expected {}'.format(expect_uri),
'Invalid URI: {0}'.format(actual_uri),
'Expected {0}'.format(expect_uri),
'PlugClean required.']
raise InvalidURI(msg)
if G_PULL:
self.write(Action.UPDATE, self.name, ['Updating ...'])
callback = functools.partial(self.buf.write, Action.UPDATE, self.name)
cmds = ['git fetch {}'.format(G_PROGRESS),
'git checkout -q {}'.format(self.checkout),
'git merge --ff-only {}'.format(self.merge),
callback = functools.partial(self.write, Action.UPDATE, self.name)
fetch_opt = '--depth 99999999' if self.tag and os.path.isfile(os.path.join(self.args['dir'], '.git/shallow')) else ''
cmds = ['git fetch {0} {1}'.format(fetch_opt, G_PROGRESS),
'git checkout -q {0}'.format(self.checkout),
'git merge --ff-only {0}'.format(self.merge),
'git submodule update --init --recursive']
cmd = ' 2>&1 && '.join(cmds)
GLog.write(cmd)
@@ -1280,8 +1313,8 @@ class Plugin(object):
return result[-1]
def write(self, action, name, msg):
GLog.write('{} {}: {}'.format(action, name, '\n'.join(msg)))
self.buf.write(action, name, msg)
GLog.write('{0} {1}: {2}'.format(action, name, '\n'.join(msg)))
self.buf_q.put((action, name, msg))
class PlugThread(thr.Thread):
def __init__(self, tname, args):
@@ -1291,17 +1324,21 @@ class PlugThread(thr.Thread):
def run(self):
thr.current_thread().name = self.tname
work_q, lock, buf = self.args
buf_q, work_q, lock = self.args
try:
while not G_STOP.is_set():
name, args = work_q.get_nowait()
GLog.write('{}: Dir {}'.format(name, args['dir']))
plug = Plugin(name, args, buf, lock)
GLog.write('{0}: Dir {1}'.format(name, args['dir']))
plug = Plugin(name, args, buf_q, lock)
plug.manage()
work_q.task_done()
except Queue.Empty:
except queue.Empty:
GLog.write('Queue now empty.')
finally:
global G_THREADS
with lock:
del G_THREADS[thr.current_thread().name]
class RefreshThread(thr.Thread):
def __init__(self, lock):
@@ -1312,19 +1349,26 @@ class RefreshThread(thr.Thread):
def run(self):
while self.running:
with self.lock:
vim.command('noautocmd normal! a')
thread_vim_command('noautocmd normal! a')
time.sleep(0.2)
def stop(self):
self.running = False
if G_NVIM:
def thread_vim_command(cmd):
vim.session.threadsafe_call(lambda: vim.command(cmd))
else:
def thread_vim_command(cmd):
vim.command(cmd)
def esc(name):
return '"' + name.replace('"', '\"') + '"'
def nonblock_read(fname):
""" Read a file with nonblock flag. Return the last line. """
fread = os.open(fname, os.O_RDONLY | os.O_NONBLOCK)
buf = os.read(fread, 100000)
buf = os.read(fread, 100000).decode()
os.close(fread)
line = buf.rstrip('\r\n')
@@ -1341,34 +1385,42 @@ def main():
if GLog.ON and os.path.exists(GLog.LOGDIR):
shutil.rmtree(GLog.LOGDIR)
threads = []
nthreads = int(vim.eval('s:update.threads'))
plugs = vim.eval('s:update.todo')
mac_gui = vim.eval('s:mac_gui') == '1'
is_win = vim.eval('s:is_win') == '1'
GLog.write('Plugs: {}'.format(plugs))
GLog.write('PULL: {}, WIN: {}, MAC: {}'.format(G_PULL, is_win, mac_gui))
GLog.write('Num Threads: {}'.format(nthreads))
GLog.write('Plugs: {0}'.format(plugs))
GLog.write('PULL: {0}, WIN: {1}, MAC: {2}'.format(G_PULL, is_win, mac_gui))
GLog.write('Num Threads: {0}'.format(nthreads))
lock = thr.Lock()
buf = Buffer(lock, len(plugs))
work_q = Queue.Queue()
buf = Buffer(lock, len(plugs), G_PULL, is_win)
buf_q, work_q = queue.Queue(), queue.Queue()
for work in plugs.items():
work_q.put(work)
GLog.write('Starting Threads')
global G_THREADS
for num in range(nthreads):
tname = 'PlugT-{0:02}'.format(num)
thread = PlugThread(tname, (work_q, lock, buf))
thread = PlugThread(tname, (buf_q, work_q, lock))
thread.start()
threads.append(thread)
G_THREADS[tname] = thread
if mac_gui:
rthread = RefreshThread(lock)
rthread.start()
GLog.write('Joining Live Threads')
for thread in threads:
thread.join()
GLog.write('Buffer Writing Loop')
while not buf_q.empty() or len(G_THREADS) != 0:
try:
action, name, msg = buf_q.get(True, 0.25)
buf.write(action, name, msg)
buf_q.task_done()
except queue.Empty:
pass
except KeyboardInterrupt:
G_STOP.set()
if mac_gui:
rthread.stop()
rthread.join()
@@ -1536,6 +1588,7 @@ function! s:update_ruby()
end
} if VIM::evaluate('s:mac_gui') == 1
clone_opt = VIM::evaluate('s:clone_opt')
progress = VIM::evaluate('s:progress_opt(1)')
nthr.times do
mtx.synchronize do
@@ -1565,7 +1618,8 @@ function! s:update_ruby()
else
if pull
log.call name, 'Updating ...', :update
bt.call "#{cd} #{dir} && git fetch #{progress} 2>&1 && git checkout -q #{checkout} 2>&1 && git merge --ff-only #{merge} 2>&1 && #{subm}", name, :update, nil
fetch_opt = (tag && File.exist?(File.join(dir, '.git/shallow'))) ? '--depth 99999999' : ''
bt.call "#{cd} #{dir} && git fetch #{fetch_opt} #{progress} 2>&1 && git checkout -q #{checkout} 2>&1 && git merge --ff-only #{merge} 2>&1 && #{subm}", name, :update, nil
else
[true, skip]
end
@@ -1573,7 +1627,7 @@ function! s:update_ruby()
else
d = esc dir.sub(%r{[\\/]+$}, '')
log.call name, 'Installing ...', :install
bt.call "git clone #{progress} --recursive #{uri} -b #{checkout} #{d} 2>&1", name, :install, proc {
bt.call "git clone #{clone_opt unless tag} #{progress} --recursive #{uri} -b #{checkout} #{d} 2>&1", name, :install, proc {
FileUtils.rm_rf dir
}
end
@@ -1623,14 +1677,14 @@ endfunction
function! s:system(cmd, ...)
try
let sh = &shell
let [sh, shrd] = [&shell, &shellredir]
if !s:is_win
set shell=sh
set shell=sh shellredir=>%s\ 2>&1
endif
let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd
return system(s:is_win ? '('.cmd.')' : cmd)
finally
let &shell = sh
let [&shell, &shellredir] = [sh, shrd]
endtry
endfunction
@@ -1677,6 +1731,12 @@ function! s:git_valid(spec, check_branch)
return [ret, msg]
endfunction
function! s:rm_rf(dir)
if isdirectory(a:dir)
call s:system((s:is_win ? 'rmdir /S /Q ' : 'rm -rf ') . s:shellesc(a:dir))
endif
endfunction
function! s:clean(force)
call s:prepare()
call append(0, 'Searching for unused plugins in '.g:plug_home)
@@ -1725,9 +1785,7 @@ function! s:clean(force)
call inputrestore()
if yes
for dir in todo
if isdirectory(dir)
call s:system((s:is_win ? 'rmdir /S /Q ' : 'rm -rf ') . s:shellesc(dir))
endif
call s:rm_rf(dir)
endfor
call append(line('$'), 'Removed.')
else
@@ -1738,55 +1796,30 @@ function! s:clean(force)
endfunction
function! s:upgrade()
let new = s:me . '.new'
echo 'Downloading '. s:plug_src
echo 'Downloading the latest version of vim-plug'
redraw
let tmp = tempname()
let new = tmp . '/plug.vim'
try
if executable('curl')
let output = s:system(printf('curl -fLo %s %s', s:shellesc(new), s:plug_src))
if v:shell_error
throw get(s:lines(output), -1, v:shell_error)
endif
elseif s:ruby
call s:upgrade_using_ruby(new)
elseif s:py2
call s:upgrade_using_python(new)
else
return s:err('Missing: curl executable, ruby support or python support')
let out = s:system(printf('git clone --depth 1 %s %s', s:plug_src, tmp))
if v:shell_error
return s:err('Error upgrading vim-plug: '. out)
endif
catch
return s:err('Error upgrading vim-plug: '. v:exception)
if readfile(s:me) ==# readfile(new)
echo 'vim-plug is already up-to-date'
return 0
else
call rename(s:me, s:me . '.old')
call rename(new, s:me)
unlet g:loaded_plug
echo 'vim-plug has been upgraded'
return 1
endif
finally
silent! call s:rm_rf(tmp)
endtry
if readfile(s:me) ==# readfile(new)
echo 'vim-plug is already up-to-date'
silent! call delete(new)
return 0
else
call rename(s:me, s:me . '.old')
call rename(new, s:me)
unlet g:loaded_plug
echo 'vim-plug has been upgraded'
return 1
endif
endfunction
function! s:upgrade_using_ruby(new)
ruby << EOF
require 'open-uri'
File.open(VIM::evaluate('a:new'), 'w') do |f|
f << open(VIM::evaluate('s:plug_src')).read
end
EOF
endfunction
function! s:upgrade_using_python(new)
python << EOF
import urllib
import vim
psrc, dest = vim.eval('s:plug_src'), vim.eval('a:new')
urllib.urlretrieve(psrc, dest)
EOF
endfunction
function! s:upgrade_specs()
@@ -1904,7 +1937,7 @@ function! s:preview_commit()
execute 'pedit' sha
wincmd P
setlocal filetype=git buftype=nofile nobuflisted
execute 'silent read !cd' s:shellesc(g:plugs[name].dir) '&& git show' sha
execute 'silent read !cd' s:shellesc(g:plugs[name].dir) '&& git show --pretty=medium' sha
normal! gg"_dd
wincmd p
endfunction

View File

@@ -1,5 +0,0 @@
fzf*
xxx
yyy
z1
z2

View File

@@ -1 +0,0 @@
echomsg 'ftplugin'

View File

@@ -19,7 +19,7 @@ Execute (#112 On-demand loading should not suppress messages from ftplugin):
**********************************************************************
Execute (#114 Should not contain empty path in &rtp):
call plug#begin('$TMPDIR/plugged')
call plug#begin('/tmp/plugged')
call plug#end()
Log &rtp
@@ -34,7 +34,8 @@ Execute (#130 Proper cleanup of on-demand loading triggers):
augroup END
" Cleared on command
call plug#begin('$TMPDIR/plugged')
call ReloadPlug()
call plug#begin('/tmp/plugged')
Plug 'junegunn/vim-emoji', { 'on': ['EmojiCommand', 'EmojiCommand2', '<Plug>(EmojiMapping)'] }
call plug#end()
PlugInstall | q
@@ -50,7 +51,8 @@ Execute (#130 Proper cleanup of on-demand loading triggers):
Assert empty(mapcheck('<Plug>(EmojiMapping)')), '<Plug>(EmojiMapping) defined'
" Cleared on FileType
call plug#begin('$TMPDIR/plugged')
call ReloadPlug()
call plug#begin('/tmp/plugged')
Plug 'junegunn/vim-emoji', { 'on': ['EmojiCommandExtra', '<Plug>(EmojiMappingExtra)'], 'for': ['emoji'] }
call plug#end()
@@ -64,25 +66,25 @@ Execute (#130 Proper cleanup of on-demand loading triggers):
**********************************************************************
Execute (#131 Syntax error):
call plug#begin('/no-permission')
call plug#begin('/proc/no-permission')
Plug 'junegunn/vim-emoji'
call plug#end()
redir => out
silent PlugInstall
redir END
Assert out =~ 'Invalid plug directory: /no-permission'
Assert out =~ 'Invalid plug directory: /proc/no-permission', out
**********************************************************************
Execute (#139-1 Using new remote branch):
" Make sure to remove the clone
call plug#begin('$TMPDIR/plugged')
call plug#begin('/tmp/plugged')
call plug#end()
PlugClean!
" Install master branch
call plug#begin('$TMPDIR/plugged')
Plug expand('file:///$TMPDIR/new-branch')
call plug#begin('/tmp/plugged')
Plug expand('file:////tmp/new-branch')
call plug#end()
PlugUpdate
@@ -93,14 +95,14 @@ Execute (#139-1 Using new remote branch):
Assert !exists('g:baz'), 'g:baz should not be found'
" Create a new branch on origin
call system('cd $TMPDIR/new-branch && git checkout -b new &&'
call system('cd /tmp/new-branch && git checkout -b new &&'
\. 'echo "let g:bar = 1" > plugin/bar.vim && git add plugin/bar.vim &&'
\. 'git commit -m second')
" We're setting up two plugins so that parallel installer is used
call plug#begin('$TMPDIR/plugged')
call plug#begin('/tmp/plugged')
Plug 'junegunn/seoul256.vim'
Plug expand('file:///$TMPDIR/new-branch'), { 'branch': 'new' }
Plug expand('file:////tmp/new-branch'), { 'branch': 'new' }
call plug#end()
PlugUpdate
silent %y
@@ -123,14 +125,14 @@ Expect:
Execute (#139-2 Using yet another new remote branch):
" Create another branch on origin
call system('cd $TMPDIR/new-branch && git checkout master &&'
call system('cd /tmp/new-branch && git checkout master &&'
\. 'git checkout -b brand-new &&'
\. 'echo "let g:baz = 1" > plugin/baz.vim && git add plugin/baz.vim &&'
\. 'git commit -m third')
" Test Vim installer here
call plug#begin('$TMPDIR/plugged')
Plug expand('file:///$TMPDIR/new-branch'), { 'branch': 'brand-new' }
call plug#begin('/tmp/plugged')
Plug expand('file:////tmp/new-branch'), { 'branch': 'brand-new' }
call plug#end()
PlugUpdate
silent %y
@@ -152,24 +154,25 @@ Expect:
Execute (#139-3 Should fail when not possible to fast-forward):
" Commit on cloned repo
call system('cd $TMPDIR/plugged/new-branch && git checkout master &&'
call system('cd /tmp/plugged/new-branch && git checkout master &&'
\. 'touch foobar && git add foobar && git commit -m foobar')
" Different commit on remote
call system('cd $TMPDIR/new-branch && git checkout master &&'
call system('cd /tmp/new-branch && git checkout master &&'
\. 'touch foobaz && git add foobaz && git commit -m foobaz')
for multi in [0, 1]
call plug#begin('$TMPDIR/plugged')
call plug#begin('/tmp/plugged')
if multi
Plug 'junegunn/seoul256.vim'
endif
Plug expand('file:///$TMPDIR/new-branch')
Plug expand('file:////tmp/new-branch')
call plug#end()
PlugUpdate
silent %y
Assert @" =~ 'Not possible to fast-forward', @"
endfor
q
**********************************************************************
Execute (#145: Merging on-demand loading triggers - cmd):
@@ -188,6 +191,7 @@ Execute (#145: Merging on-demand loading triggers - cmd):
Execute (#145: Merging on-demand loading triggers - map):
unlet! g:xxx g:yyy
call ReloadPlug()
call plug#begin()
Plug '$PLUG_FIXTURES/xxx', { 'on': '<Plug>(xxx)' }
Plug '$PLUG_FIXTURES/yyy', { 'on': ['<Plug>(xxx)' ,'<Plug>(yyy)' ] }
@@ -206,7 +210,7 @@ Execute (#159: shell=/bin/tcsh):
let org = &shell
try
set shell=/bin/tcsh
call plug#begin('$TMPDIR/plugged')
call plug#begin('/tmp/plugged')
Plug 'junegunn/seoul256.vim'
call plug#end()
@@ -220,9 +224,42 @@ Execute (#159: shell=/bin/tcsh):
**********************************************************************
Execute (#154: Spaces in &rtp should not be escaped):
call plug#begin('$TMPDIR/plug it')
call plug#begin('/tmp/plug it')
Plug 'seoul256 vim'
call plug#end()
Log &rtp
Assert stridx(&rtp, 'plug it/seoul256 vim') >= 0
**********************************************************************
Execute (#184: Duplicate entries in &rtp):
call plug#begin('/tmp/plugged')
Plug 'plugin1'
\| Plug 'plugin0'
Plug 'plugin2'
\| Plug 'plugin0'
\| Plug 'plugin1'
call plug#end()
Log &rtp
AssertEqual 3, len(filter(split(&rtp, ','), 'stridx(v:val, "plugged") >= 0'))
**********************************************************************
Execute (#236: Plugin removed from &rtp when .vimrc is reloaded):
unlet! g:loaded_easy_align_plugin
silent! delc EasyAlign
call ReloadPlug()
call plug#begin('/tmp/plugged')
Plug 'junegunn/vim-easy-align', { 'on': 'EasyAlign' }
call plug#end()
PlugInstall | q
Assert &rtp !~ '/vim-easy-align', 'Plugin should not be in &rtp'
%EasyAlign=
Assert &rtp =~ '/vim-easy-align', 'Plugin should be in &rtp'
call plug#begin('/tmp/plugged')
Plug 'junegunn/vim-easy-align', { 'on': 'EasyAlign' }
call plug#end()
Assert &rtp =~ '/vim-easy-align', 'Plugin should still be in &rtp'

View File

@@ -1,11 +1,16 @@
#!/bin/bash
cd $(dirname $BASH_SOURCE)
cd ..
PLUG_SRC=$(pwd)/plug.vim
cd - > /dev/null
cd $(dirname "${BASH_SOURCE[0]}")
export PLUG_FIXTURES=$(pwd)/fixtures
export BASE="$PWD"
export PLUG_SRC="$PWD/../plug.vim"
export PLUG_FIXTURES="$PWD/fixtures"
mkdir -p "$PLUG_FIXTURES"
cat > /tmp/mini-vimrc << VIMRC
set rtp+=/tmp/junegunn/vader.vim
set shell=/bin/bash
VIMRC
clone() {
if [ ! -d $2 ]; then
@@ -13,25 +18,25 @@ clone() {
fi
}
# Clone
cd /tmp
mkdir -p junegunn vim-scripts jg
for repo in vader.vim goyo.vim rust.vim seoul256.vim vim-easy-align vim-fnr \
vim-oblique vim-pseudocl vim-redis vim-emoji; do
clone https://github.com/junegunn/${repo}.git junegunn/$repo &
done
clone https://github.com/vim-scripts/beauty256.git vim-scripts/beauty256 &
clone_repos() {
cd /tmp
mkdir -p junegunn vim-scripts jg
for repo in vader.vim goyo.vim rust.vim seoul256.vim vim-easy-align vim-fnr \
vim-oblique vim-pseudocl vim-redis vim-emoji; do
clone https://github.com/junegunn/${repo}.git junegunn/$repo &
done
clone https://github.com/vim-scripts/beauty256.git vim-scripts/beauty256 &
clone https://github.com/junegunn/fzf.git fzf &
wait
rm -rf $PLUG_FIXTURES/fzf
clone https://github.com/junegunn/fzf.git $PLUG_FIXTURES/fzf-staged &
wait
clone junegunn/vim-emoji jg/vim-emoji
cd junegunn/seoul256.vim && git checkout no-t_co && git checkout master
(cd junegunn/seoul256.vim &&
git checkout no-t_co && git checkout master) > /dev/null 2>&1
clone junegunn/vim-emoji jg/vim-emoji
cd - > /dev/null
cd "$BASE"
}
make_dirs() {
rm -rf "$PLUG_FIXTURES/$1"
mkdir -p "$PLUG_FIXTURES/$1"
cd "$PLUG_FIXTURES/$1"
mkdir -p autoload colors ftdetect ftplugin indent plugin syntax
@@ -46,17 +51,15 @@ make_dirs() {
call add(g:total_order, s:name)
EOF
done
cd - > /dev/null
cd "$BASE"
}
init() {
rm -rf $PLUG_FIXTURES/{xxx,yyy,z1,z2}
rm -rf $TMPDIR/new-branch
prepare() {
make_dirs xxx/ xxx
make_dirs xxx/after xxx
mkdir -p $PLUG_FIXTURES/xxx/doc
cat > $PLUG_FIXTURES/xxx/doc/xxx.txt << DOC
mkdir -p "$PLUG_FIXTURES/xxx/doc"
cat > "$PLUG_FIXTURES/xxx/doc/xxx.txt" << DOC
hello *xxx*
DOC
@@ -66,28 +69,27 @@ DOC
make_dirs z1/ z1
make_dirs z2/ z2
(
cd $TMPDIR
git init new-branch
cd new-branch
mkdir plugin
echo 'let g:foo = 1' > plugin/foo.vim
git add plugin/foo.vim
git commit -m initial
)
rm -rf "$PLUG_FIXTURES/ftplugin-msg"
mkdir -p "$PLUG_FIXTURES/ftplugin-msg/ftplugin"
echo "echomsg 'ftplugin'" > "$PLUG_FIXTURES/ftplugin-msg/ftplugin/c.vim"
rm -rf /tmp/new-branch
cd /tmp
git init new-branch
cd new-branch
mkdir plugin
echo 'let g:foo = 1' > plugin/foo.vim
git add plugin/foo.vim
git commit -m initial
cd "$BASE"
}
cat > /tmp/mini-vimrc << VIMRC
set rtp+=/tmp/junegunn/vader.vim
set shell=/bin/bash
source $PLUG_SRC
VIMRC
[ -z "$TMPDIR" ] && export TMPDIR=/tmp/
init
clone_repos
prepare
if [ "$1" = '!' ]; then
/usr/local/bin/vim -Nu /tmp/mini-vimrc -c 'Vader! test.vader' > /dev/null &&
init &&
prepare &&
/usr/local/bin/vim -Nu /tmp/mini-vimrc -c 'let g:plug_threads = 1 | Vader! test.vader' > /dev/null
else
/usr/local/bin/vim -Nu /tmp/mini-vimrc -c 'Vader test.vader'

View File

@@ -1,18 +1,20 @@
Execute (Initialize test environment):
Save &rtp, g:plugs, g:plug_home, g:plug_window
let first_rtp = split(&rtp, ',')[0]
let last_rtp = split(&rtp, ',')[-1]
let vader = fnamemodify(globpath(&rtp, 'autoload/vader.vim'), ':h:h')
let plug = fnamemodify(globpath(&rtp, 'autoload/plug.vim'), ':h:h')
set rtp=$HOME/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/.vim/after
execute 'set rtp^='.vader
execute 'set rtp^='.plug
let basertp = &rtp
unlet! g:plugs g:plug_home g:plug_window
let g:plug_url_format = 'file:///tmp/%s'
let g:base_rtp = &rtp
let g:first_rtp = split(&rtp, ',')[0]
let g:last_rtp = split(&rtp, ',')[-1]
let g:temp_plugged = tempname()
if !exists('$PLUG_SRC')
let $PLUG_SRC = globpath(&rtp, 'autoload/plug.vim')
endif
" Temporarily patch plug.vim
call system('cp $PLUG_SRC $PLUG_SRC.org')
call writefile(extend(readfile($PLUG_SRC),
\ ['function! ResetPlug()', 'let s:loaded = {}', 'endfunction']), $PLUG_SRC)
set t_Co=256
colo default
@@ -39,12 +41,26 @@ Execute (Initialize test environment):
endif
endfunction
function! RmRf(file)
call system(printf('rm -rf "%s"', a:file))
endfunction
function! ReloadPlug()
call ResetPlug()
source $PLUG_SRC
let &rtp = g:base_rtp
endfunction
source $PLUG_SRC
Execute (Print Interpreter Version):
redir => out
if has('ruby')
silent ruby puts 'Ruby: ' + RUBY_VERSION
elseif has('python')
silent python import sys; svi = sys.version_info; print 'Python: {}.{}.{}'.format(svi[0], svi[1], svi[2])
elseif has('python3')
silent python3 import sys; svi = sys.version_info; print('Python: {}.{}.{}'.format(svi[0], svi[1], svi[2]))
endif
redir END
Log substitute(out, '\n', '', 'g')
@@ -53,20 +69,18 @@ Include: workflow.vader
Include: regressions.vader
Execute (Cleanup):
silent! call system('rm -rf '.temp_plugged)
silent! call system('rm -rf '.temp_plugged)
silent! call rename(fzf, expand('$PLUG_FIXTURES/fzf-staged'))
silent! unlet g:plugs
silent! unlet g:plug_home
silent! unlet g:plug_url_format
silent! unlet temp_plugged vader plug basertp save_rtp repo lnum fzf out tabnr found len
silent! call RmRf(g:temp_plugged)
silent! unlet g:plugs g:plug_home g:plug_url_format
silent! unlet g:temp_plugged g:first_rtp g:last_rtp g:base_rtp out
silent! delf PlugStatusSorted
silent! delf AssertExpect
silent! delf PlugUpdated
silent! delf EnsureLoaded
silent! delf ReloadPlug
silent! delc AssertExpect
silent! unmap /
silent! unmap ?
call system('mv $PLUG_SRC.org $PLUG_SRC')
Restore

View File

@@ -17,25 +17,25 @@ Execute (plug#begin() without path argument with empty &rtp):
redir END
Assert stridx(out, 'Unable to determine plug home') >= 0
let &rtp = save_rtp
unlet save_rtp
Execute (plug#begin(path)):
let temp_plugged = tempname()
call plug#begin(temp_plugged.'/')
call plug#begin(g:temp_plugged.'/')
Assert g:plug_home !~ '[/\\]$', 'Trailing / should be stripped from g:plug_home'
AssertEqual 0, len(g:plugs)
AssertEqual temp_plugged, g:plug_home
AssertEqual basertp, &rtp
AssertEqual g:temp_plugged, g:plug_home
AssertEqual g:base_rtp, &rtp
Execute (Subsequent plug#begin() calls will reuse g:plug_home):
call plug#begin()
AssertEqual temp_plugged, g:plug_home
AssertEqual g:temp_plugged, g:plug_home
Execute (Test Plug command):
^ Git repo with branch (DEPRECATED. USE BRANCH OPTION)
Plug 'junegunn/seoul256.vim', { 'branch': 'yes-t_co' }
AssertEqual 'file:///tmp/junegunn/seoul256.vim', g:plugs['seoul256.vim'].uri
AssertEqual join([temp_plugged, 'seoul256.vim/'], '/'), g:plugs['seoul256.vim'].dir
AssertEqual join([g:temp_plugged, 'seoul256.vim/'], '/'), g:plugs['seoul256.vim'].dir
AssertEqual 'yes-t_co', g:plugs['seoul256.vim'].branch
Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co' } " Using branch option
@@ -44,7 +44,7 @@ Execute (Test Plug command):
^ Git repo with tag (DEPRECATED. USE TAG OPTION)
Plug 'junegunn/goyo.vim', '1.5.2'
AssertEqual 'file:///tmp/junegunn/goyo.vim', g:plugs['goyo.vim'].uri
AssertEqual join([temp_plugged, 'goyo.vim/'], '/'), g:plugs['goyo.vim'].dir
AssertEqual join([g:temp_plugged, 'goyo.vim/'], '/'), g:plugs['goyo.vim'].dir
AssertEqual '1.5.2', g:plugs['goyo.vim'].tag
Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' } " Using tag option
@@ -54,7 +54,7 @@ Execute (Test Plug command):
Plug 'file:///tmp/jg/vim-emoji'
AssertEqual 'file:///tmp/jg/vim-emoji', g:plugs['vim-emoji'].uri
AssertEqual 'master', g:plugs['vim-emoji'].branch
AssertEqual join([temp_plugged, 'vim-emoji/'], '/'), g:plugs['vim-emoji'].dir
AssertEqual join([g:temp_plugged, 'vim-emoji/'], '/'), g:plugs['vim-emoji'].dir
" vim-scripts/
Plug 'beauty256'
@@ -66,7 +66,7 @@ Execute (Test Plug command):
Execute (Plug command with dictionary option):
Log string(g:plugs)
Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co', 'rtp': '././' }
AssertEqual join([temp_plugged, 'seoul256.vim/'], '/'), g:plugs['seoul256.vim'].dir
AssertEqual join([g:temp_plugged, 'seoul256.vim/'], '/'), g:plugs['seoul256.vim'].dir
AssertEqual '././', g:plugs['seoul256.vim'].rtp
Log string(g:plugs)
@@ -84,9 +84,9 @@ Execute (PlugClean before installation):
Execute (plug#end() updates &rtp):
call plug#end()
Assert len(&rtp) > len(basertp)
AssertEqual first_rtp, split(&rtp, ',')[0]
AssertEqual last_rtp, split(&rtp, ',')[-1]
Assert len(&rtp) > len(g:base_rtp)
AssertEqual g:first_rtp, split(&rtp, ',')[0]
AssertEqual g:last_rtp, split(&rtp, ',')[-1]
Execute (Yet, plugins are not available):
Assert empty(globpath(&rtp, 'autoload/emoji.vim'))
@@ -270,10 +270,13 @@ Execute (PlugDiff - 'No updates.'):
AssertEqual 'No updates.', getline(1)
q
Execute (Rollback recent updates, PlugUpdate, then PlugDiff):
Execute (New commits on remote, PlugUpdate, then PlugDiff):
for repo in ['seoul256.vim', 'vim-emoji']
call system(printf('cd %s/%s && git reset HEAD^^ --hard', g:plug_home, repo))
for _ in range(2)
call system(printf('cd /tmp/junegunn/%s && git commit --allow-empty -m "update"', repo))
endfor
endfor
unlet repo
PlugUpdate
" Now we have updates
@@ -307,6 +310,7 @@ Execute (Rollback recent updates, PlugUpdate, then PlugDiff):
" [[ motion
execute 'normal 0[['
AssertEqual lnum, line('.')
unlet lnum
AssertEqual 3, col('.')
" X key to revert the update
@@ -346,12 +350,14 @@ Execute (Reuse Plug window in another tab):
AssertEqual tabnr, tabpagenr()
normal! gt
q
unlet tabnr
**********************************************************************
~ On-demand loading / Partial installation/update ~
**********************************************************************
Execute (Trying to execute on-demand commands when plugin is not installed):
call ReloadPlug()
call plug#begin()
Plug 'junegunn/vim-easy-align', { 'on': ['EasyAlign', 'LiveEasyAlign'] }
call plug#end()
@@ -364,16 +370,22 @@ Execute (Trying to execute on-demand commands when plugin is not installed):
Assert !exists(':LiveEasyAlign')
Execute (New set of plugins):
call ReloadPlug()
call plug#begin()
Plug 'junegunn/vim-fnr'
Plug 'junegunn/vim-pseudocl'
Plug 'junegunn/vim-easy-align', { 'on': 'EasyAlign' }
Plug 'junegunn/vim-redis', { 'for': 'redis' }
let user_autocmd = {}
autocmd! User vim-fnr let user_autocmd.fnr = 1
autocmd! User vim-easy-align let user_autocmd.easy_align = 1
autocmd! User vim-redis let user_autocmd.redis = 1
call plug#end()
Execute (Check commands):
Assert !exists(':FNR'), 'FNR command should not be found'
Assert !exists(':RedisExecute'), 'RedisExecute command should not be found'
Assert empty(user_autocmd)
Execute (Partial PlugInstall):
PlugInstall vim-fnr vim-easy-align
@@ -383,8 +395,8 @@ Execute (Partial PlugInstall):
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]
AssertEqual g:first_rtp, split(&rtp, ',')[0]
AssertEqual g:last_rtp, split(&rtp, ',')[-1]
q
Given (Unaligned code):
@@ -403,6 +415,10 @@ Expect (Aligned code):
a = 1
aa = 2
Then (autocmd executed):
Assert user_autocmd.easy_align
AssertEqual 1, len(user_autocmd)
Given:
Execute (Partial PlugUpdate):
PlugUpdate vim-redis
@@ -412,6 +428,11 @@ Execute (On-demand loading based on filetypes):
Assert !exists(':RedisExecute'), 'RedisExecute command still should not be found'
set ft=redis
Assert exists(':RedisExecute'), 'RedisExecute command is now found'
Assert user_autocmd.redis
AssertEqual 2, len(user_autocmd)
autocmd! User
unlet user_autocmd
**********************************************************************
~ Local (unmanaged) plugins
@@ -419,6 +440,7 @@ Execute (On-demand loading based on filetypes):
Execute (Add unmanaged plugin):
let fzf = expand('$PLUG_FIXTURES/fzf')
call RmRf(fzf)
Log fzf
call plug#begin()
@@ -477,7 +499,8 @@ Execute (PlugStatus should point out that the plugin is missing):
Execute (Deploy unmanaged plugin):
Assert !exists(':FZF'), ':FZF command should not exist'
call rename(expand('$PLUG_FIXTURES/fzf-staged'), fzf)
call RmRf(fzf)
Log system(printf('cp -r "/tmp/fzf" "%s"', fzf))
Execute (PlugUpdate still should not care):
PlugUpdate
@@ -497,8 +520,8 @@ Execute (Check &rtp after SomeCommand):
Assert &rtp !~ 'fzf'
silent! SomeCommand
Assert &rtp =~ 'fzf'
AssertEqual first_rtp, split(&rtp, ',')[0]
AssertEqual last_rtp, split(&rtp, ',')[-1]
AssertEqual g:first_rtp, split(&rtp, ',')[0]
AssertEqual g:last_rtp, split(&rtp, ',')[-1]
Execute (Common parent):
call plug#begin()
@@ -512,6 +535,8 @@ Execute (Common parent):
AssertExpect! '[===]', 1
q
unlet fzf
**********************************************************************
~ Frozen plugins
**********************************************************************
@@ -639,8 +664,8 @@ Execute (On update):
Plug 'junegunn/vim-pseudocl', { 'do': 'touch updated' }
call plug#end()
" Reset for updates
call system('cd '.g:plugs['vim-pseudocl'].dir.' && git reset --hard HEAD^')
" New commits on remote
call system('cd /tmp/junegunn/vim-pseudocl && git commit --allow-empty -m "update"')
silent PlugUpdate
Log getline(1, '$')
@@ -703,8 +728,9 @@ Execute (Using Funcref):
Plug 'junegunn/vim-pseudocl', { 'do': function('PlugUpdated') }
call plug#end()
call system('cd /tmp/junegunn/vim-easy-align && git commit --allow-empty -m "update"')
call system('cd '.g:plugs['vim-easy-align'].dir.' && git reset --hard HEAD^')
call system('rm -rf '.g:plugs['vim-pseudocl'].dir)
call RmRf(g:plugs['vim-pseudocl'].dir)
PlugUpdate
Log getline(1, '$')
@@ -714,7 +740,7 @@ Execute (Using Funcref):
Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclinstalled03'),
\ 'vim-pseudocl/vim-pseudoclinstalled03 should exist'
call system('rm -rf '.g:plugs['vim-pseudocl'].dir)
call RmRf(g:plugs['vim-pseudocl'].dir)
PlugInstall!
q
Assert filereadable(g:plugs['vim-easy-align'].dir.'/vim-easy-alignunchanged13'),
@@ -737,11 +763,11 @@ Execute (Using Funcref):
Execute (Using custom dir):
Assert isdirectory(g:plugs['vim-easy-align'].dir)
call system('rm -rf '.$TMPDIR.'easy-align')
call RmRf('/tmp/easy-align')
call plug#begin()
Plug 'junegunn/vim-easy-align', { 'dir': $TMPDIR.'easy-align' }
Plug 'junegunn/vim-easy-align', { 'dir': '/tmp/easy-align' }
call plug#end()
AssertEqual $TMPDIR.'easy-align/', g:plugs['vim-easy-align'].dir
AssertEqual '/tmp/easy-align/', g:plugs['vim-easy-align'].dir
PlugClean!
Assert !isdirectory(g:plugs['vim-easy-align'].dir)
@@ -760,6 +786,7 @@ Before (Clear global vars):
set rtp-=$PLUG_FIXTURES/xxx/after
Execute (Immediate loading):
call ReloadPlug()
call plug#begin()
Plug '$PLUG_FIXTURES/xxx'
call plug#end()
@@ -774,6 +801,7 @@ Execute (Immediate loading):
endif
Execute (Command-based on-demand loading):
call ReloadPlug()
call plug#begin()
Plug '$PLUG_FIXTURES/xxx', { 'on': 'XXX' }
call plug#end()
@@ -787,6 +815,7 @@ Execute (Command-based on-demand loading):
AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect', 'xxx/plugin', 'xxx/after/plugin', 'xxx/ftplugin', 'xxx/after/ftplugin', 'xxx/indent', 'xxx/after/indent', 'xxx/syntax', 'xxx/after/syntax'], g:xxx
Execute (Filetype-based on-demand loading):
call ReloadPlug()
call plug#begin()
Plug '$PLUG_FIXTURES/xxx', { 'for': 'xxx' }
call plug#end()
@@ -901,7 +930,7 @@ Execute (Open plug window in a new tab):
normal S
AssertEqual tabnr, tabpagenr()
q
unlet g:plug_window
unlet g:plug_window tabnr
**********************************************************************
~ g:plug_url_format
@@ -947,7 +976,7 @@ Execute (Update plugin with U key in normal mode):
q
Execute (Update plugins with U key in visual mode):
silent! call system('rm -rf '.g:plugs['vim-easy-align'].dir)
silent! call RmRf(g:plugs['vim-easy-align'].dir)
PlugStatus
normal VGU
@@ -974,7 +1003,7 @@ Execute (plug#begin should expand env vars):
**********************************************************************
Execute (Plug directory with comma):
call plug#begin(temp_plugged . '/p,l,u,g,g,e,d')
call plug#begin(g:temp_plugged . '/p,l,u,g,g,e,d')
Plug 'junegunn/vim-emoji'
call plug#end()
Log &rtp
@@ -984,10 +1013,12 @@ Execute (Plug directory with comma):
let found = filter(split(globpath(&rtp, 'README.md'), '\n'), 'v:val =~ ","')
Log found
AssertEqual 1, len(found)
unlet found
**********************************************************************
Execute (Strict load order):
let g:total_order = []
call ReloadPlug()
call plug#begin()
Plug '$PLUG_FIXTURES/xxx'
Plug '$PLUG_FIXTURES/yyy', { 'for': ['xxx'] }
@@ -1001,6 +1032,7 @@ Execute (Strict load order):
let len = len(split(&rtp, ','))
let g:total_order = []
call ReloadPlug()
call plug#begin()
Plug '$PLUG_FIXTURES/xxx', { 'for': ['xxx'] }
Plug '$PLUG_FIXTURES/yyy'
@@ -1018,6 +1050,9 @@ Execute (Strict load order):
AssertEqual len + 2, len(split(&rtp, ','))
let g:total_order = []
call ReloadPlug()
set rtp^=manually-prepended
set rtp+=manually-appended
call plug#begin()
Plug '$PLUG_FIXTURES/xxx', { 'for': ['xxx'] }
Plug '$PLUG_FIXTURES/yyy', { 'for': ['xxx'] }
@@ -1051,6 +1086,7 @@ Execute (PlugClean should not try to remove unmanaged plugins inside g:plug_home
**********************************************************************
Execute (PlugSnapshot / #154 issues with paths containing spaces):
let $TMPDIR = '/tmp'
call plug#begin('$TMPDIR/plug with spaces')
Plug 'junegunn/vim-easy-align'
Plug 'junegunn/seoul256.vim'
@@ -1073,3 +1109,60 @@ Execute (PlugSnapshot / #154 issues with paths containing spaces):
AssertEqual 'snapshot.sh', fnamemodify(expand('%'), ':t')
q
**********************************************************************
Execute (#221 Shallow-clone and tag option):
call plug#begin(g:temp_plugged)
Plug 'junegunn/goyo.vim'
call plug#end()
PlugInstall
execute 'cd' g:plugs['goyo.vim'].dir
Assert len(split(system('git log --oneline'), '\n')) == 1
Assert filereadable('.git/shallow')
Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' }
PlugUpdate
q
Assert len(split(system('git log --oneline'), '\n')) > 1
Assert system('git describe --tag') =~ '^1.5.3'
Assert !filereadable('.git/shallow')
cd -
Execute (#221 Shallow-clone disabled by g:plug_shallow = 0):
call plug#begin(g:temp_plugged)
call plug#end()
PlugClean!
let g:plug_shallow = 0
call plug#begin(g:temp_plugged)
Plug 'junegunn/goyo.vim'
call plug#end()
PlugInstall
q
execute 'cd' g:plugs['goyo.vim'].dir
Assert len(split(system('git log --oneline'), '\n')) > 1, 'not shallow'
Assert !filereadable('.git/shallow'), 'not shallow'
cd -
unlet g:plug_shallow
Execute (#221 Shallow-clone disabled by tag):
call plug#begin(g:temp_plugged)
call plug#end()
PlugClean!
call plug#begin(g:temp_plugged)
Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' }
call plug#end()
Assert !isdirectory(g:plugs['goyo.vim'].dir)
PlugInstall
Assert isdirectory(g:plugs['goyo.vim'].dir)
q
execute 'cd' g:plugs['goyo.vim'].dir
Assert system('git describe --tag') =~ '^1.5.3'
Assert len(split(system('git log --oneline'), '\n')) > 1
Assert !filereadable('.git/shallow')
cd -