mirror of
https://github.com/junegunn/vim-plug.git
synced 2025-12-09 02:14:46 +08:00
Compare commits
51 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
240dc9cbb6 | ||
|
|
f85d4d774b | ||
|
|
50cd5e5819 | ||
|
|
099057da65 | ||
|
|
8e0fcf88c0 | ||
|
|
025f314144 | ||
|
|
48fba1454b | ||
|
|
2ed1f27aa2 | ||
|
|
7760f1c22b | ||
|
|
0bd23f5b47 | ||
|
|
0227c78910 | ||
|
|
8a72305371 | ||
|
|
018b48e071 | ||
|
|
7ace0c42db | ||
|
|
179fa7bb82 | ||
|
|
76bce26ab8 | ||
|
|
36e4364b81 | ||
|
|
76ec644114 | ||
|
|
9e0a082a3d | ||
|
|
9bee42ca0a | ||
|
|
18313fa43e | ||
|
|
32eb4f5cbe | ||
|
|
96824ccd14 | ||
|
|
ef4549d2d1 | ||
|
|
d738da2ddb | ||
|
|
d17d10dccb | ||
|
|
6677e8bffd | ||
|
|
80ca4ebf54 | ||
|
|
8f1df15cc3 | ||
|
|
2218b8fe20 | ||
|
|
c632c1fd6a | ||
|
|
42300e0c4d | ||
|
|
13de76383d | ||
|
|
481a400ba4 | ||
|
|
02710070a1 | ||
|
|
e04f93b162 | ||
|
|
923f3fb3d5 | ||
|
|
6a7efea26b | ||
|
|
0e3e1cab75 | ||
|
|
27354c826e | ||
|
|
650927980d | ||
|
|
047fbba4cd | ||
|
|
fa5ece81f7 | ||
|
|
e1b7f1ae85 | ||
|
|
cf1f644aa8 | ||
|
|
8da3942484 | ||
|
|
cbaf4f3088 | ||
|
|
a06687b4ed | ||
|
|
9abd50facd | ||
|
|
b3226fbbf6 | ||
|
|
d0120cfb45 |
@@ -4,19 +4,22 @@ rvm:
|
|||||||
- 1.9.2 # Test with vim-nox package on ubuntu
|
- 1.9.2 # Test with vim-nox package on ubuntu
|
||||||
- 1.9.3 # Test against python installer
|
- 1.9.3 # Test against python installer
|
||||||
- 2.0.0
|
- 2.0.0
|
||||||
|
- 2.1.0 # Test against python3 installer
|
||||||
|
|
||||||
before_script: |
|
before_script: |
|
||||||
if [ $(ruby -e 'puts RUBY_VERSION') = 1.9.2 ]; then
|
|
||||||
sudo apt-get update -y
|
sudo apt-get update -y
|
||||||
|
if [ $(ruby -e 'puts RUBY_VERSION') = 1.9.2 ]; then
|
||||||
sudo apt-get install -y vim-nox
|
sudo apt-get install -y vim-nox
|
||||||
sudo ln -s /usr/bin/vim /usr/local/bin/vim
|
sudo ln -s /usr/bin/vim /usr/local/bin/vim
|
||||||
else
|
else
|
||||||
hg clone https://code.google.com/p/vim/
|
git clone --depth 1 https://github.com/vim/vim
|
||||||
cd vim
|
cd vim
|
||||||
if [ $(ruby -e 'puts RUBY_VERSION') = 1.9.3 ]; then
|
if [ $(ruby -e 'puts RUBY_VERSION') = 1.9.3 ]; then
|
||||||
sudo apt-get update -y
|
|
||||||
sudo apt-get install -y python2.7-dev
|
sudo apt-get install -y python2.7-dev
|
||||||
./configure --with-features=huge --enable-pythoninterp
|
./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
|
else
|
||||||
./configure --with-features=huge --enable-rubyinterp
|
./configure --with-features=huge --enable-rubyinterp
|
||||||
fi
|
fi
|
||||||
|
|||||||
19
README.md
19
README.md
@@ -1,5 +1,5 @@
|
|||||||
<img src="https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.png" height="56" alt="vim-plug">
|
<img src="https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.png" height="75" alt="vim-plug">[](https://travis-ci.org/junegunn/vim-plug)
|
||||||
[](https://travis-ci.org/junegunn/vim-plug)
|
===
|
||||||
|
|
||||||
A minimalist Vim plugin manager.
|
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 setup: Single file. No boilerplate code required.
|
||||||
- Easier to use: Concise, intuitive syntax
|
- Easier to use: Concise, intuitive syntax
|
||||||
- [Super-fast][40/4] parallel installation/update
|
- [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]
|
- On-demand loading for [faster startup time][startup-time]
|
||||||
- Can review and rollback updates
|
- Can review and rollback updates
|
||||||
- Branch/tag support
|
- Branch/tag support
|
||||||
@@ -18,8 +19,6 @@ A minimalist Vim plugin manager.
|
|||||||
- Support for externally managed plugins
|
- Support for externally managed plugins
|
||||||
|
|
||||||
[40/4]: https://raw.githubusercontent.com/junegunn/i/master/vim-plug/40-in-4.gif
|
[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/
|
[nv]: http://neovim.org/
|
||||||
[startup-time]: http://junegunn.kr/images/vim-startup-time.png
|
[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/seoul256.vim'
|
||||||
Plug 'junegunn/vim-easy-align'
|
Plug 'junegunn/vim-easy-align'
|
||||||
|
|
||||||
|
" Group dependencies, vim-snippets depends on ultisnips
|
||||||
|
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
|
||||||
|
|
||||||
" On-demand loading
|
" On-demand loading
|
||||||
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
|
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
|
||||||
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
|
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'
|
Plug 'https://github.com/junegunn/vim-github-dashboard.git'
|
||||||
|
|
||||||
" Plugin options
|
" 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
|
" Plugin outside ~/.vim/plugged with post-update hook
|
||||||
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': 'yes \| ./install' }
|
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': 'yes \| ./install' }
|
||||||
@@ -94,6 +96,7 @@ Reload .vimrc and `:PlugInstall` to install plugins.
|
|||||||
| `g:plug_threads` | 16 | Default number of threads to use |
|
| `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_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_retries` | 2 | Number of retries in case of timeout (*Ruby & Python*) |
|
||||||
|
| `g:plug_shallow` | 1 | Use shallow clone |
|
||||||
| `g:plug_window` | `vertical topleft new` | Command to open plug window |
|
| `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_url_format` | `https://git::@github.com/%s.git` | `printf` format to build repo URL |
|
||||||
|
|
||||||
@@ -134,6 +137,10 @@ Plug 'kovisoft/paredit', { 'for': ['clojure', 'scheme'] }
|
|||||||
|
|
||||||
" On-demand loading on both conditions
|
" On-demand loading on both conditions
|
||||||
Plug 'junegunn/vader.vim', { 'on': 'Vader', 'for': 'vader' }
|
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
|
`for` option is generally not needed as most plugins for specific file types
|
||||||
|
|||||||
BIN
plug.png
BIN
plug.png
Binary file not shown.
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 23 KiB |
313
plug.vim
313
plug.vim
@@ -3,8 +3,7 @@
|
|||||||
"
|
"
|
||||||
" Download plug.vim and put it in ~/.vim/autoload
|
" Download plug.vim and put it in ~/.vim/autoload
|
||||||
"
|
"
|
||||||
" mkdir -p ~/.vim/autoload
|
" curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
|
||||||
" curl -fLo ~/.vim/autoload/plug.vim \
|
|
||||||
" https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
" https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||||
"
|
"
|
||||||
" Edit your .vimrc
|
" Edit your .vimrc
|
||||||
@@ -15,6 +14,9 @@
|
|||||||
" Plug 'junegunn/seoul256.vim'
|
" Plug 'junegunn/seoul256.vim'
|
||||||
" Plug 'junegunn/vim-easy-align'
|
" Plug 'junegunn/vim-easy-align'
|
||||||
"
|
"
|
||||||
|
" " Group dependencies, vim-snippets depends on ultisnips
|
||||||
|
" Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
|
||||||
|
"
|
||||||
" " On-demand loading
|
" " On-demand loading
|
||||||
" Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
|
" Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
|
||||||
" Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
|
" Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
|
||||||
@@ -23,7 +25,7 @@
|
|||||||
" Plug 'https://github.com/junegunn/vim-github-dashboard.git'
|
" Plug 'https://github.com/junegunn/vim-github-dashboard.git'
|
||||||
"
|
"
|
||||||
" " Plugin options
|
" " 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
|
" " Plugin outside ~/.vim/plugged with post-update hook
|
||||||
" Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': 'yes \| ./install' }
|
" Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': 'yes \| ./install' }
|
||||||
@@ -37,7 +39,7 @@
|
|||||||
" Visit https://github.com/junegunn/vim-plug for more information.
|
" Visit https://github.com/junegunn/vim-plug for more information.
|
||||||
"
|
"
|
||||||
"
|
"
|
||||||
" Copyright (c) 2014 Junegunn Choi
|
" Copyright (c) 2015 Junegunn Choi
|
||||||
"
|
"
|
||||||
" MIT License
|
" MIT License
|
||||||
"
|
"
|
||||||
@@ -68,14 +70,12 @@ let g:loaded_plug = 1
|
|||||||
let s:cpo_save = &cpo
|
let s:cpo_save = &cpo
|
||||||
set cpo&vim
|
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_tab = get(s:, 'plug_tab', -1)
|
||||||
let s:plug_buf = get(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: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:py2 = has('python') && !s:is_win
|
let s:nvim = has('nvim') && exists('*jobwait') && !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:me = resolve(expand('<sfile>:p'))
|
let s:me = resolve(expand('<sfile>:p'))
|
||||||
let s:base_spec = { 'branch': 'master', 'frozen': 0 }
|
let s:base_spec = { 'branch': 'master', 'frozen': 0 }
|
||||||
let s:TYPE = {
|
let s:TYPE = {
|
||||||
@@ -166,7 +166,7 @@ function! plug#end()
|
|||||||
if has_key(plug, 'on')
|
if has_key(plug, 'on')
|
||||||
let s:triggers[name] = { 'map': [], 'cmd': [] }
|
let s:triggers[name] = { 'map': [], 'cmd': [] }
|
||||||
for cmd in s:to_a(plug.on)
|
for cmd in s:to_a(plug.on)
|
||||||
if cmd =~ '^<Plug>.\+'
|
if cmd =~? '^<Plug>.\+'
|
||||||
if empty(mapcheck(cmd)) && empty(mapcheck(cmd, 'i'))
|
if empty(mapcheck(cmd)) && empty(mapcheck(cmd, 'i'))
|
||||||
call s:assoc(lod.map, cmd, name)
|
call s:assoc(lod.map, cmd, name)
|
||||||
endif
|
endif
|
||||||
@@ -271,7 +271,7 @@ if s:is_win
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:is_local_plug(repo)
|
function! s:is_local_plug(repo)
|
||||||
return a:repo =~? '^[a-z]:'
|
return a:repo =~? '^[a-z]:\|^[%~]'
|
||||||
endfunction
|
endfunction
|
||||||
else
|
else
|
||||||
function! s:rtp(spec)
|
function! s:rtp(spec)
|
||||||
@@ -359,7 +359,9 @@ function! plug#load(...)
|
|||||||
for name in a:000
|
for name in a:000
|
||||||
call s:lod([name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
call s:lod([name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
||||||
endfor
|
endfor
|
||||||
|
if exists('#BufRead')
|
||||||
doautocmd BufRead
|
doautocmd BufRead
|
||||||
|
endif
|
||||||
return 1
|
return 1
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -389,14 +391,21 @@ function! s:lod(names, types)
|
|||||||
for dir in a:types
|
for dir in a:types
|
||||||
call s:source(rtp, dir.'/**/*.vim')
|
call s:source(rtp, dir.'/**/*.vim')
|
||||||
endfor
|
endfor
|
||||||
|
if exists('#User#'.name)
|
||||||
|
execute 'doautocmd User' name
|
||||||
|
endif
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:lod_ft(pat, names)
|
function! s:lod_ft(pat, names)
|
||||||
call s:lod(a:names, ['plugin', 'after/plugin'])
|
call s:lod(a:names, ['plugin', 'after/plugin'])
|
||||||
execute 'autocmd! PlugLOD FileType' a:pat
|
execute 'autocmd! PlugLOD FileType' a:pat
|
||||||
|
if exists('#filetypeplugin#FileType')
|
||||||
doautocmd filetypeplugin FileType
|
doautocmd filetypeplugin FileType
|
||||||
|
endif
|
||||||
|
if exists('#filetypeindent#FileType')
|
||||||
doautocmd filetypeindent FileType
|
doautocmd filetypeindent FileType
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:lod_cmd(cmd, bang, l1, l2, args, names)
|
function! s:lod_cmd(cmd, bang, l1, l2, args, names)
|
||||||
@@ -431,7 +440,7 @@ function! s:add(repo, ...)
|
|||||||
call add(g:plugs_order, name)
|
call add(g:plugs_order, name)
|
||||||
endif
|
endif
|
||||||
let g:plugs[name] = spec
|
let g:plugs[name] = spec
|
||||||
let s:loaded[name] = 0
|
let s:loaded[name] = get(s:loaded, name, 0)
|
||||||
catch
|
catch
|
||||||
return s:err(v:exception)
|
return s:err(v:exception)
|
||||||
endtry
|
endtry
|
||||||
@@ -710,7 +719,7 @@ endfunction
|
|||||||
function! s:update_impl(pull, force, args) abort
|
function! s:update_impl(pull, force, args) abort
|
||||||
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]*$') ?
|
||||||
\ 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 managed = filter(copy(g:plugs), 's:is_managed(v:key)')
|
||||||
let todo = empty(args) ? filter(managed, '!v:val.frozen || !isdirectory(v:val.dir)') :
|
let todo = empty(args) ? filter(managed, '!v:val.frozen || !isdirectory(v:val.dir)') :
|
||||||
@@ -741,6 +750,16 @@ function! s:update_impl(pull, force, args) abort
|
|||||||
endtry
|
endtry
|
||||||
endif
|
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 = {
|
let s:update = {
|
||||||
\ 'start': reltime(),
|
\ 'start': reltime(),
|
||||||
\ 'all': todo,
|
\ 'all': todo,
|
||||||
@@ -749,7 +768,7 @@ function! s:update_impl(pull, force, args) abort
|
|||||||
\ 'pull': a:pull,
|
\ 'pull': a:pull,
|
||||||
\ 'force': a:force,
|
\ 'force': a:force,
|
||||||
\ 'new': {},
|
\ 'new': {},
|
||||||
\ 'threads': (s:py2 || s:ruby || s:nvim) ? min([len(todo), threads]) : 1,
|
\ 'threads': (python || ruby || s:nvim) ? min([len(todo), threads]) : 1,
|
||||||
\ 'bar': '',
|
\ 'bar': '',
|
||||||
\ 'fin': 0
|
\ 'fin': 0
|
||||||
\ }
|
\ }
|
||||||
@@ -757,22 +776,27 @@ function! s:update_impl(pull, force, args) abort
|
|||||||
call s:prepare()
|
call s:prepare()
|
||||||
call append(0, ['', ''])
|
call append(0, ['', ''])
|
||||||
normal! 2G
|
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)
|
" 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
|
redir => pyv
|
||||||
silent python import platform; print(platform.python_version())
|
silent python import platform; print(platform.python_version())
|
||||||
redir END
|
redir END
|
||||||
let s:py2 = s:version_requirement(
|
let python = s:version_requirement(
|
||||||
\ map(split(split(pyv)[0], '\.'), 'str2nr(v:val)'), [2, 6])
|
\ map(split(split(pyv)[0], '\.'), 'str2nr(v:val)'), [2, 6])
|
||||||
endif
|
endif
|
||||||
if (s:py2 || s:ruby) && !s:nvim && s:update.threads > 1
|
|
||||||
|
if (python || ruby) && s:update.threads > 1
|
||||||
try
|
try
|
||||||
let imd = &imd
|
let imd = &imd
|
||||||
if s:mac_gui
|
if s:mac_gui
|
||||||
set noimd
|
set noimd
|
||||||
endif
|
endif
|
||||||
if s:ruby
|
if ruby
|
||||||
call s:update_ruby()
|
call s:update_ruby()
|
||||||
else
|
else
|
||||||
call s:update_python()
|
call s:update_python()
|
||||||
@@ -818,9 +842,7 @@ function! s:job_abort()
|
|||||||
if !s:nvim || !exists('s:jobs')
|
if !s:nvim || !exists('s:jobs')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
augroup PlugJobControl
|
|
||||||
autocmd!
|
|
||||||
augroup END
|
|
||||||
for [name, j] in items(s:jobs)
|
for [name, j] in items(s:jobs)
|
||||||
silent! call jobstop(j.jobid)
|
silent! call jobstop(j.jobid)
|
||||||
if j.new
|
if j.new
|
||||||
@@ -830,52 +852,48 @@ function! s:job_abort()
|
|||||||
let s:jobs = {}
|
let s:jobs = {}
|
||||||
endfunction
|
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
|
if !s:plug_window_exists() " plug window closed
|
||||||
return s:job_abort()
|
return s:job_abort()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !has_key(s:jobs, a:name)
|
if a:event == 'stdout'
|
||||||
return
|
let self.result .= substitute(s:to_s(a:data), '[\r\n]', '', 'g') . "\n"
|
||||||
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])
|
|
||||||
" To reduce the number of buffer updates
|
" To reduce the number of buffer updates
|
||||||
let job.tick = get(job, 'tick', -1) + 1
|
let self.tick = get(self, 'tick', -1) + 1
|
||||||
if job.tick % len(s:jobs) == 0
|
if self.tick % len(s:jobs) == 0
|
||||||
call s:log(job.new ? '+' : '*', a:name, job.result)
|
call s:log(self.new ? '+' : '*', self.name, self.result)
|
||||||
endif
|
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
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:spawn(name, cmd, opts)
|
function! s:spawn(name, cmd, opts)
|
||||||
let job = { 'running': 1, 'new': get(a:opts, 'new', 0),
|
let job = { 'name': a:name, 'running': 1, 'error': 0, 'result': '',
|
||||||
\ '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
|
let s:jobs[a:name] = job
|
||||||
|
|
||||||
if s:nvim
|
if s:nvim
|
||||||
let x = jobstart(a:name, 'sh', ['-c',
|
let argv = [ 'sh', '-c',
|
||||||
\ (has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd)
|
\ (has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd) ]
|
||||||
\ . ' || echo Error'])
|
let jid = jobstart(argv, job)
|
||||||
if x > 0
|
if jid > 0
|
||||||
let job.jobid = x
|
let job.jobid = jid
|
||||||
augroup PlugJobControl
|
|
||||||
execute 'autocmd JobActivity' a:name printf('call s:job_handler(%s)', string(a:name))
|
|
||||||
augroup END
|
|
||||||
else
|
else
|
||||||
let job.running = 0
|
let job.running = 0
|
||||||
let job.error = 1
|
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)'
|
\ 'Invalid arguments (or job table is full)'
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
@@ -887,10 +905,6 @@ function! s:spawn(name, cmd, opts)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:reap(name)
|
function! s:reap(name)
|
||||||
if s:nvim
|
|
||||||
silent! execute 'autocmd! PlugJobControl JobActivity' a:name
|
|
||||||
endif
|
|
||||||
|
|
||||||
let job = s:jobs[a:name]
|
let job = s:jobs[a:name]
|
||||||
if job.error
|
if job.error
|
||||||
call add(s:update.errors, a:name)
|
call add(s:update.errors, a:name)
|
||||||
@@ -966,16 +980,18 @@ while 1 " Without TCO, Vim stack is bound to explode
|
|||||||
call s:log(new ? '+' : '*', name, pull ? 'Updating ...' : 'Installing ...')
|
call s:log(new ? '+' : '*', name, pull ? 'Updating ...' : 'Installing ...')
|
||||||
redraw
|
redraw
|
||||||
|
|
||||||
let checkout = s:shellesc(has_key(spec, 'tag') ? spec.tag : spec.branch)
|
let has_tag = has_key(spec, 'tag')
|
||||||
let merge = s:shellesc(has_key(spec, 'tag') ? spec.tag : 'origin/'.spec.branch)
|
let checkout = s:shellesc(has_tag ? spec.tag : spec.branch)
|
||||||
|
let merge = s:shellesc(has_tag ? spec.tag : 'origin/'.spec.branch)
|
||||||
|
|
||||||
if !new
|
if !new
|
||||||
let [valid, msg] = s:git_valid(spec, 0)
|
let [valid, msg] = s:git_valid(spec, 0)
|
||||||
if valid
|
if valid
|
||||||
if pull
|
if pull
|
||||||
|
let fetch_opt = (has_tag && !empty(globpath(spec.dir, '.git/shallow'))) ? '--depth 99999999' : ''
|
||||||
call s:spawn(name,
|
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)',
|
\ 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)',
|
||||||
\ prog, checkout, merge), { 'dir': spec.dir })
|
\ fetch_opt, prog, checkout, merge), { 'dir': spec.dir })
|
||||||
else
|
else
|
||||||
let s:jobs[name] = { 'running': 0, 'result': 'Already installed', 'error': 0 }
|
let s:jobs[name] = { 'running': 0, 'result': 'Already installed', 'error': 0 }
|
||||||
endif
|
endif
|
||||||
@@ -984,7 +1000,8 @@ while 1 " Without TCO, Vim stack is bound to explode
|
|||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
call s:spawn(name,
|
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,
|
\ prog,
|
||||||
\ s:shellesc(spec.uri),
|
\ s:shellesc(spec.uri),
|
||||||
\ checkout,
|
\ checkout,
|
||||||
@@ -1001,12 +1018,16 @@ endwhile
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:update_python()
|
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. """
|
""" Due to use of signals this function is POSIX only. """
|
||||||
import datetime
|
import datetime
|
||||||
import functools
|
import functools
|
||||||
import os
|
import os
|
||||||
import Queue
|
try:
|
||||||
|
import queue
|
||||||
|
except ImportError:
|
||||||
|
import Queue as queue
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
@@ -1018,18 +1039,27 @@ import time
|
|||||||
import traceback
|
import traceback
|
||||||
import vim
|
import vim
|
||||||
|
|
||||||
|
G_NVIM = vim.eval("has('nvim')") == '1'
|
||||||
G_PULL = vim.eval('s:update.pull') == '1'
|
G_PULL = vim.eval('s:update.pull') == '1'
|
||||||
G_RETRIES = int(vim.eval('get(g:, "plug_retries", 2)')) + 1
|
G_RETRIES = int(vim.eval('get(g:, "plug_retries", 2)')) + 1
|
||||||
G_TIMEOUT = int(vim.eval('get(g:, "plug_timeout", 60)'))
|
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_PROGRESS = vim.eval('s:progress_opt(1)')
|
||||||
G_LOG_PROB = 1.0 / int(vim.eval('s:update.threads'))
|
G_LOG_PROB = 1.0 / int(vim.eval('s:update.threads'))
|
||||||
G_STOP = thr.Event()
|
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
|
pass
|
||||||
class CmdFailed(Exception):
|
class CmdFailed(BaseExc):
|
||||||
pass
|
pass
|
||||||
class InvalidURI(Exception):
|
class InvalidURI(BaseExc):
|
||||||
pass
|
pass
|
||||||
class Action(object):
|
class Action(object):
|
||||||
INSTALL, UPDATE, ERROR, DONE = ['+', '*', 'x', '-']
|
INSTALL, UPDATE, ERROR, DONE = ['+', '*', 'x', '-']
|
||||||
@@ -1053,13 +1083,13 @@ class GLog(object):
|
|||||||
with open(fname, 'ab') as flog:
|
with open(fname, 'ab') as flog:
|
||||||
ltime = datetime.datetime.now().strftime("%H:%M:%S.%f")
|
ltime = datetime.datetime.now().strftime("%H:%M:%S.%f")
|
||||||
msg = '[{0},{1}] {2}{3}'.format(name, ltime, msg, '\n')
|
msg = '[{0},{1}] {2}{3}'.format(name, ltime, msg, '\n')
|
||||||
flog.write(msg)
|
flog.write(msg.encode())
|
||||||
|
|
||||||
class Buffer(object):
|
class Buffer(object):
|
||||||
def __init__(self, lock, num_plugs):
|
def __init__(self, lock, num_plugs, is_pull, is_win):
|
||||||
self.bar = ''
|
self.bar = ''
|
||||||
self.event = 'Updating' if vim.eval('s:update.pull') == '1' else 'Installing'
|
self.event = 'Updating' if is_pull else 'Installing'
|
||||||
self.is_win = vim.eval('s:is_win') == '1'
|
self.is_win = is_win
|
||||||
self.lock = lock
|
self.lock = lock
|
||||||
self.maxy = int(vim.eval('winheight(".")'))
|
self.maxy = int(vim.eval('winheight(".")'))
|
||||||
self.num_plugs = num_plugs
|
self.num_plugs = num_plugs
|
||||||
@@ -1085,15 +1115,12 @@ class Buffer(object):
|
|||||||
num_spaces = self.num_plugs - len(self.bar)
|
num_spaces = self.num_plugs - len(self.bar)
|
||||||
curbuf[1] = '[{0}{1}]'.format(self.bar, num_spaces * ' ')
|
curbuf[1] = '[{0}{1}]'.format(self.bar, num_spaces * ' ')
|
||||||
|
|
||||||
|
with self.lock:
|
||||||
vim.command('normal! 2G')
|
vim.command('normal! 2G')
|
||||||
if not self.is_win:
|
if not self.is_win:
|
||||||
vim.command('redraw')
|
vim.command('redraw')
|
||||||
|
|
||||||
def write(self, *args, **kwargs):
|
def write(self, action, name, lines):
|
||||||
with self.lock:
|
|
||||||
self._write(*args, **kwargs)
|
|
||||||
|
|
||||||
def _write(self, action, name, lines):
|
|
||||||
first, rest = lines[0], lines[1:]
|
first, rest = lines[0], lines[1:]
|
||||||
msg = ['{0} {1}{2}{3}'.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]
|
padded_rest = [' ' + line for line in rest]
|
||||||
@@ -1164,7 +1191,7 @@ class Command(object):
|
|||||||
proc = None
|
proc = None
|
||||||
first_line = True
|
first_line = True
|
||||||
try:
|
try:
|
||||||
tfile = tempfile.NamedTemporaryFile()
|
tfile = tempfile.NamedTemporaryFile(mode='w+b', delete=False)
|
||||||
proc = subprocess.Popen(self.cmd, cwd=self.cmd_dir, stdout=tfile,
|
proc = subprocess.Popen(self.cmd, cwd=self.cmd_dir, stdout=tfile,
|
||||||
stderr=subprocess.STDOUT, shell=True, preexec_fn=os.setsid)
|
stderr=subprocess.STDOUT, shell=True, preexec_fn=os.setsid)
|
||||||
while proc.poll() is None:
|
while proc.poll() is None:
|
||||||
@@ -1185,7 +1212,7 @@ class Command(object):
|
|||||||
raise CmdTimedOut(['Timeout!'])
|
raise CmdTimedOut(['Timeout!'])
|
||||||
|
|
||||||
tfile.seek(0)
|
tfile.seek(0)
|
||||||
result = [line.rstrip() for line in tfile]
|
result = [line.decode().rstrip() for line in tfile]
|
||||||
|
|
||||||
if proc.returncode != 0:
|
if proc.returncode != 0:
|
||||||
msg = ['']
|
msg = ['']
|
||||||
@@ -1197,18 +1224,21 @@ class Command(object):
|
|||||||
if self.clean:
|
if self.clean:
|
||||||
self.clean()
|
self.clean()
|
||||||
raise
|
raise
|
||||||
|
finally:
|
||||||
|
os.remove(tfile.name)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
class Plugin(object):
|
class Plugin(object):
|
||||||
def __init__(self, name, args, buf, lock):
|
def __init__(self, name, args, buf_q, lock):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.args = args
|
self.args = args
|
||||||
self.buf = buf
|
self.buf_q = buf_q
|
||||||
self.lock = lock
|
self.lock = lock
|
||||||
tag = args.get('tag', 0)
|
tag = args.get('tag', 0)
|
||||||
self.checkout = esc(tag if tag else args['branch'])
|
self.checkout = esc(tag if tag else args['branch'])
|
||||||
self.merge = esc(tag if tag else 'origin/' + args['branch'])
|
self.merge = esc(tag if tag else 'origin/' + args['branch'])
|
||||||
|
self.tag = tag
|
||||||
|
|
||||||
def manage(self):
|
def manage(self):
|
||||||
try:
|
try:
|
||||||
@@ -1217,9 +1247,9 @@ class Plugin(object):
|
|||||||
else:
|
else:
|
||||||
self.install()
|
self.install()
|
||||||
with self.lock:
|
with self.lock:
|
||||||
vim.command("let s:update.new['{0}'] = 1".format(self.name))
|
thread_vim_command("let s:update.new['{0}'] = 1".format(self.name))
|
||||||
except (CmdTimedOut, CmdFailed, InvalidURI) as exc:
|
except (CmdTimedOut, CmdFailed, InvalidURI) as exc:
|
||||||
self.write(Action.ERROR, self.name, exc.message)
|
self.write(Action.ERROR, self.name, exc.msg)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
G_STOP.set()
|
G_STOP.set()
|
||||||
self.write(Action.ERROR, self.name, ['Interrupted!'])
|
self.write(Action.ERROR, self.name, ['Interrupted!'])
|
||||||
@@ -1241,9 +1271,9 @@ class Plugin(object):
|
|||||||
return _clean
|
return _clean
|
||||||
|
|
||||||
self.write(Action.INSTALL, self.name, ['Installing ...'])
|
self.write(Action.INSTALL, self.name, ['Installing ...'])
|
||||||
callback = functools.partial(self.buf.write, Action.INSTALL, self.name)
|
callback = functools.partial(self.write, Action.INSTALL, self.name)
|
||||||
cmd = 'git clone {0} --recursive {1} -b {2} {3} 2>&1'.format(
|
cmd = 'git clone {0} {1} --recursive {2} -b {3} {4} 2>&1'.format(
|
||||||
G_PROGRESS, self.args['uri'], self.checkout, esc(target))
|
'' 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))
|
com = Command(cmd, None, G_TIMEOUT, G_RETRIES, callback, clean(target))
|
||||||
result = com.attempt_cmd()
|
result = com.attempt_cmd()
|
||||||
self.write(Action.DONE, self.name, result[-1:])
|
self.write(Action.DONE, self.name, result[-1:])
|
||||||
@@ -1261,8 +1291,9 @@ class Plugin(object):
|
|||||||
|
|
||||||
if G_PULL:
|
if G_PULL:
|
||||||
self.write(Action.UPDATE, self.name, ['Updating ...'])
|
self.write(Action.UPDATE, self.name, ['Updating ...'])
|
||||||
callback = functools.partial(self.buf.write, Action.UPDATE, self.name)
|
callback = functools.partial(self.write, Action.UPDATE, self.name)
|
||||||
cmds = ['git fetch {0}'.format(G_PROGRESS),
|
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 checkout -q {0}'.format(self.checkout),
|
||||||
'git merge --ff-only {0}'.format(self.merge),
|
'git merge --ff-only {0}'.format(self.merge),
|
||||||
'git submodule update --init --recursive']
|
'git submodule update --init --recursive']
|
||||||
@@ -1283,7 +1314,7 @@ class Plugin(object):
|
|||||||
|
|
||||||
def write(self, action, name, msg):
|
def write(self, action, name, msg):
|
||||||
GLog.write('{0} {1}: {2}'.format(action, name, '\n'.join(msg)))
|
GLog.write('{0} {1}: {2}'.format(action, name, '\n'.join(msg)))
|
||||||
self.buf.write(action, name, msg)
|
self.buf_q.put((action, name, msg))
|
||||||
|
|
||||||
class PlugThread(thr.Thread):
|
class PlugThread(thr.Thread):
|
||||||
def __init__(self, tname, args):
|
def __init__(self, tname, args):
|
||||||
@@ -1293,17 +1324,21 @@ class PlugThread(thr.Thread):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
thr.current_thread().name = self.tname
|
thr.current_thread().name = self.tname
|
||||||
work_q, lock, buf = self.args
|
buf_q, work_q, lock = self.args
|
||||||
|
|
||||||
try:
|
try:
|
||||||
while not G_STOP.is_set():
|
while not G_STOP.is_set():
|
||||||
name, args = work_q.get_nowait()
|
name, args = work_q.get_nowait()
|
||||||
GLog.write('{0}: Dir {1}'.format(name, args['dir']))
|
GLog.write('{0}: Dir {1}'.format(name, args['dir']))
|
||||||
plug = Plugin(name, args, buf, lock)
|
plug = Plugin(name, args, buf_q, lock)
|
||||||
plug.manage()
|
plug.manage()
|
||||||
work_q.task_done()
|
work_q.task_done()
|
||||||
except Queue.Empty:
|
except queue.Empty:
|
||||||
GLog.write('Queue now empty.')
|
GLog.write('Queue now empty.')
|
||||||
|
finally:
|
||||||
|
global G_THREADS
|
||||||
|
with lock:
|
||||||
|
del G_THREADS[thr.current_thread().name]
|
||||||
|
|
||||||
class RefreshThread(thr.Thread):
|
class RefreshThread(thr.Thread):
|
||||||
def __init__(self, lock):
|
def __init__(self, lock):
|
||||||
@@ -1314,19 +1349,26 @@ class RefreshThread(thr.Thread):
|
|||||||
def run(self):
|
def run(self):
|
||||||
while self.running:
|
while self.running:
|
||||||
with self.lock:
|
with self.lock:
|
||||||
vim.command('noautocmd normal! a')
|
thread_vim_command('noautocmd normal! a')
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self.running = False
|
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):
|
def esc(name):
|
||||||
return '"' + name.replace('"', '\"') + '"'
|
return '"' + name.replace('"', '\"') + '"'
|
||||||
|
|
||||||
def nonblock_read(fname):
|
def nonblock_read(fname):
|
||||||
""" Read a file with nonblock flag. Return the last line. """
|
""" Read a file with nonblock flag. Return the last line. """
|
||||||
fread = os.open(fname, os.O_RDONLY | os.O_NONBLOCK)
|
fread = os.open(fname, os.O_RDONLY | os.O_NONBLOCK)
|
||||||
buf = os.read(fread, 100000)
|
buf = os.read(fread, 100000).decode()
|
||||||
os.close(fread)
|
os.close(fread)
|
||||||
|
|
||||||
line = buf.rstrip('\r\n')
|
line = buf.rstrip('\r\n')
|
||||||
@@ -1343,7 +1385,6 @@ def main():
|
|||||||
if GLog.ON and os.path.exists(GLog.LOGDIR):
|
if GLog.ON and os.path.exists(GLog.LOGDIR):
|
||||||
shutil.rmtree(GLog.LOGDIR)
|
shutil.rmtree(GLog.LOGDIR)
|
||||||
|
|
||||||
threads = []
|
|
||||||
nthreads = int(vim.eval('s:update.threads'))
|
nthreads = int(vim.eval('s:update.threads'))
|
||||||
plugs = vim.eval('s:update.todo')
|
plugs = vim.eval('s:update.todo')
|
||||||
mac_gui = vim.eval('s:mac_gui') == '1'
|
mac_gui = vim.eval('s:mac_gui') == '1'
|
||||||
@@ -1353,24 +1394,33 @@ def main():
|
|||||||
GLog.write('Num Threads: {0}'.format(nthreads))
|
GLog.write('Num Threads: {0}'.format(nthreads))
|
||||||
|
|
||||||
lock = thr.Lock()
|
lock = thr.Lock()
|
||||||
buf = Buffer(lock, len(plugs))
|
buf = Buffer(lock, len(plugs), G_PULL, is_win)
|
||||||
work_q = Queue.Queue()
|
buf_q, work_q = queue.Queue(), queue.Queue()
|
||||||
for work in plugs.items():
|
for work in plugs.items():
|
||||||
work_q.put(work)
|
work_q.put(work)
|
||||||
|
|
||||||
GLog.write('Starting Threads')
|
GLog.write('Starting Threads')
|
||||||
|
global G_THREADS
|
||||||
for num in range(nthreads):
|
for num in range(nthreads):
|
||||||
tname = 'PlugT-{0:02}'.format(num)
|
tname = 'PlugT-{0:02}'.format(num)
|
||||||
thread = PlugThread(tname, (work_q, lock, buf))
|
thread = PlugThread(tname, (buf_q, work_q, lock))
|
||||||
thread.start()
|
thread.start()
|
||||||
threads.append(thread)
|
G_THREADS[tname] = thread
|
||||||
if mac_gui:
|
if mac_gui:
|
||||||
rthread = RefreshThread(lock)
|
rthread = RefreshThread(lock)
|
||||||
rthread.start()
|
rthread.start()
|
||||||
|
|
||||||
GLog.write('Joining Live Threads')
|
GLog.write('Buffer Writing Loop')
|
||||||
for thread in threads:
|
while not buf_q.empty() or len(G_THREADS) != 0:
|
||||||
thread.join()
|
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:
|
if mac_gui:
|
||||||
rthread.stop()
|
rthread.stop()
|
||||||
rthread.join()
|
rthread.join()
|
||||||
@@ -1538,6 +1588,7 @@ function! s:update_ruby()
|
|||||||
end
|
end
|
||||||
} if VIM::evaluate('s:mac_gui') == 1
|
} if VIM::evaluate('s:mac_gui') == 1
|
||||||
|
|
||||||
|
clone_opt = VIM::evaluate('s:clone_opt')
|
||||||
progress = VIM::evaluate('s:progress_opt(1)')
|
progress = VIM::evaluate('s:progress_opt(1)')
|
||||||
nthr.times do
|
nthr.times do
|
||||||
mtx.synchronize do
|
mtx.synchronize do
|
||||||
@@ -1567,7 +1618,8 @@ function! s:update_ruby()
|
|||||||
else
|
else
|
||||||
if pull
|
if pull
|
||||||
log.call name, 'Updating ...', :update
|
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
|
else
|
||||||
[true, skip]
|
[true, skip]
|
||||||
end
|
end
|
||||||
@@ -1575,7 +1627,7 @@ function! s:update_ruby()
|
|||||||
else
|
else
|
||||||
d = esc dir.sub(%r{[\\/]+$}, '')
|
d = esc dir.sub(%r{[\\/]+$}, '')
|
||||||
log.call name, 'Installing ...', :install
|
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
|
FileUtils.rm_rf dir
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@@ -1625,14 +1677,14 @@ endfunction
|
|||||||
|
|
||||||
function! s:system(cmd, ...)
|
function! s:system(cmd, ...)
|
||||||
try
|
try
|
||||||
let sh = &shell
|
let [sh, shrd] = [&shell, &shellredir]
|
||||||
if !s:is_win
|
if !s:is_win
|
||||||
set shell=sh
|
set shell=sh shellredir=>%s\ 2>&1
|
||||||
endif
|
endif
|
||||||
let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd
|
let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd
|
||||||
return system(s:is_win ? '('.cmd.')' : cmd)
|
return system(s:is_win ? '('.cmd.')' : cmd)
|
||||||
finally
|
finally
|
||||||
let &shell = sh
|
let [&shell, &shellredir] = [sh, shrd]
|
||||||
endtry
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -1679,6 +1731,12 @@ function! s:git_valid(spec, check_branch)
|
|||||||
return [ret, msg]
|
return [ret, msg]
|
||||||
endfunction
|
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)
|
function! s:clean(force)
|
||||||
call s:prepare()
|
call s:prepare()
|
||||||
call append(0, 'Searching for unused plugins in '.g:plug_home)
|
call append(0, 'Searching for unused plugins in '.g:plug_home)
|
||||||
@@ -1727,9 +1785,7 @@ function! s:clean(force)
|
|||||||
call inputrestore()
|
call inputrestore()
|
||||||
if yes
|
if yes
|
||||||
for dir in todo
|
for dir in todo
|
||||||
if isdirectory(dir)
|
call s:rm_rf(dir)
|
||||||
call s:system((s:is_win ? 'rmdir /S /Q ' : 'rm -rf ') . s:shellesc(dir))
|
|
||||||
endif
|
|
||||||
endfor
|
endfor
|
||||||
call append(line('$'), 'Removed.')
|
call append(line('$'), 'Removed.')
|
||||||
else
|
else
|
||||||
@@ -1740,29 +1796,19 @@ function! s:clean(force)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:upgrade()
|
function! s:upgrade()
|
||||||
let new = s:me . '.new'
|
echo 'Downloading the latest version of vim-plug'
|
||||||
echo 'Downloading '. s:plug_src
|
|
||||||
redraw
|
redraw
|
||||||
|
let tmp = tempname()
|
||||||
|
let new = tmp . '/plug.vim'
|
||||||
|
|
||||||
try
|
try
|
||||||
if executable('curl')
|
let out = s:system(printf('git clone --depth 1 %s %s', s:plug_src, tmp))
|
||||||
let output = s:system(printf('curl -fLo %s %s', s:shellesc(new), s:plug_src))
|
|
||||||
if v:shell_error
|
if v:shell_error
|
||||||
throw get(s:lines(output), -1, v:shell_error)
|
return s:err('Error upgrading vim-plug: '. out)
|
||||||
endif
|
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')
|
|
||||||
endif
|
|
||||||
catch
|
|
||||||
return s:err('Error upgrading vim-plug: '. v:exception)
|
|
||||||
endtry
|
|
||||||
|
|
||||||
if readfile(s:me) ==# readfile(new)
|
if readfile(s:me) ==# readfile(new)
|
||||||
echo 'vim-plug is already up-to-date'
|
echo 'vim-plug is already up-to-date'
|
||||||
silent! call delete(new)
|
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
call rename(s:me, s:me . '.old')
|
call rename(s:me, s:me . '.old')
|
||||||
@@ -1771,24 +1817,9 @@ function! s:upgrade()
|
|||||||
echo 'vim-plug has been upgraded'
|
echo 'vim-plug has been upgraded'
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
endfunction
|
finally
|
||||||
|
silent! call s:rm_rf(tmp)
|
||||||
function! s:upgrade_using_ruby(new)
|
endtry
|
||||||
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
|
endfunction
|
||||||
|
|
||||||
function! s:upgrade_specs()
|
function! s:upgrade_specs()
|
||||||
@@ -1906,7 +1937,7 @@ function! s:preview_commit()
|
|||||||
execute 'pedit' sha
|
execute 'pedit' sha
|
||||||
wincmd P
|
wincmd P
|
||||||
setlocal filetype=git buftype=nofile nobuflisted
|
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
|
normal! gg"_dd
|
||||||
wincmd p
|
wincmd p
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
5
test/fixtures/.gitignore
vendored
5
test/fixtures/.gitignore
vendored
@@ -1,5 +0,0 @@
|
|||||||
fzf*
|
|
||||||
xxx
|
|
||||||
yyy
|
|
||||||
z1
|
|
||||||
z2
|
|
||||||
1
test/fixtures/ftplugin-msg/ftplugin/c.vim
vendored
1
test/fixtures/ftplugin-msg/ftplugin/c.vim
vendored
@@ -1 +0,0 @@
|
|||||||
echomsg 'ftplugin'
|
|
||||||
@@ -19,7 +19,7 @@ Execute (#112 On-demand loading should not suppress messages from ftplugin):
|
|||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
Execute (#114 Should not contain empty path in &rtp):
|
Execute (#114 Should not contain empty path in &rtp):
|
||||||
call plug#begin('$TMPDIR/plugged')
|
call plug#begin('/tmp/plugged')
|
||||||
call plug#end()
|
call plug#end()
|
||||||
|
|
||||||
Log &rtp
|
Log &rtp
|
||||||
@@ -34,7 +34,8 @@ Execute (#130 Proper cleanup of on-demand loading triggers):
|
|||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" Cleared on command
|
" Cleared on command
|
||||||
call plug#begin('$TMPDIR/plugged')
|
call ReloadPlug()
|
||||||
|
call plug#begin('/tmp/plugged')
|
||||||
Plug 'junegunn/vim-emoji', { 'on': ['EmojiCommand', 'EmojiCommand2', '<Plug>(EmojiMapping)'] }
|
Plug 'junegunn/vim-emoji', { 'on': ['EmojiCommand', 'EmojiCommand2', '<Plug>(EmojiMapping)'] }
|
||||||
call plug#end()
|
call plug#end()
|
||||||
PlugInstall | q
|
PlugInstall | q
|
||||||
@@ -50,7 +51,8 @@ Execute (#130 Proper cleanup of on-demand loading triggers):
|
|||||||
Assert empty(mapcheck('<Plug>(EmojiMapping)')), '<Plug>(EmojiMapping) defined'
|
Assert empty(mapcheck('<Plug>(EmojiMapping)')), '<Plug>(EmojiMapping) defined'
|
||||||
|
|
||||||
" Cleared on FileType
|
" 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'] }
|
Plug 'junegunn/vim-emoji', { 'on': ['EmojiCommandExtra', '<Plug>(EmojiMappingExtra)'], 'for': ['emoji'] }
|
||||||
call plug#end()
|
call plug#end()
|
||||||
|
|
||||||
@@ -64,25 +66,25 @@ Execute (#130 Proper cleanup of on-demand loading triggers):
|
|||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
Execute (#131 Syntax error):
|
Execute (#131 Syntax error):
|
||||||
call plug#begin('/no-permission')
|
call plug#begin('/proc/no-permission')
|
||||||
Plug 'junegunn/vim-emoji'
|
Plug 'junegunn/vim-emoji'
|
||||||
call plug#end()
|
call plug#end()
|
||||||
|
|
||||||
redir => out
|
redir => out
|
||||||
silent PlugInstall
|
silent PlugInstall
|
||||||
redir END
|
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):
|
Execute (#139-1 Using new remote branch):
|
||||||
" Make sure to remove the clone
|
" Make sure to remove the clone
|
||||||
call plug#begin('$TMPDIR/plugged')
|
call plug#begin('/tmp/plugged')
|
||||||
call plug#end()
|
call plug#end()
|
||||||
PlugClean!
|
PlugClean!
|
||||||
|
|
||||||
" Install master branch
|
" Install master branch
|
||||||
call plug#begin('$TMPDIR/plugged')
|
call plug#begin('/tmp/plugged')
|
||||||
Plug expand('file:///$TMPDIR/new-branch')
|
Plug expand('file:////tmp/new-branch')
|
||||||
call plug#end()
|
call plug#end()
|
||||||
PlugUpdate
|
PlugUpdate
|
||||||
|
|
||||||
@@ -93,14 +95,14 @@ Execute (#139-1 Using new remote branch):
|
|||||||
Assert !exists('g:baz'), 'g:baz should not be found'
|
Assert !exists('g:baz'), 'g:baz should not be found'
|
||||||
|
|
||||||
" Create a new branch on origin
|
" 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 &&'
|
\. 'echo "let g:bar = 1" > plugin/bar.vim && git add plugin/bar.vim &&'
|
||||||
\. 'git commit -m second')
|
\. 'git commit -m second')
|
||||||
|
|
||||||
" We're setting up two plugins so that parallel installer is used
|
" 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 'junegunn/seoul256.vim'
|
||||||
Plug expand('file:///$TMPDIR/new-branch'), { 'branch': 'new' }
|
Plug expand('file:////tmp/new-branch'), { 'branch': 'new' }
|
||||||
call plug#end()
|
call plug#end()
|
||||||
PlugUpdate
|
PlugUpdate
|
||||||
silent %y
|
silent %y
|
||||||
@@ -123,14 +125,14 @@ Expect:
|
|||||||
|
|
||||||
Execute (#139-2 Using yet another new remote branch):
|
Execute (#139-2 Using yet another new remote branch):
|
||||||
" Create another branch on origin
|
" 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 &&'
|
\. 'git checkout -b brand-new &&'
|
||||||
\. 'echo "let g:baz = 1" > plugin/baz.vim && git add plugin/baz.vim &&'
|
\. 'echo "let g:baz = 1" > plugin/baz.vim && git add plugin/baz.vim &&'
|
||||||
\. 'git commit -m third')
|
\. 'git commit -m third')
|
||||||
|
|
||||||
" Test Vim installer here
|
" Test Vim installer here
|
||||||
call plug#begin('$TMPDIR/plugged')
|
call plug#begin('/tmp/plugged')
|
||||||
Plug expand('file:///$TMPDIR/new-branch'), { 'branch': 'brand-new' }
|
Plug expand('file:////tmp/new-branch'), { 'branch': 'brand-new' }
|
||||||
call plug#end()
|
call plug#end()
|
||||||
PlugUpdate
|
PlugUpdate
|
||||||
silent %y
|
silent %y
|
||||||
@@ -152,24 +154,25 @@ Expect:
|
|||||||
|
|
||||||
Execute (#139-3 Should fail when not possible to fast-forward):
|
Execute (#139-3 Should fail when not possible to fast-forward):
|
||||||
" Commit on cloned repo
|
" 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')
|
\. 'touch foobar && git add foobar && git commit -m foobar')
|
||||||
|
|
||||||
" Different commit on remote
|
" 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')
|
\. 'touch foobaz && git add foobaz && git commit -m foobaz')
|
||||||
|
|
||||||
for multi in [0, 1]
|
for multi in [0, 1]
|
||||||
call plug#begin('$TMPDIR/plugged')
|
call plug#begin('/tmp/plugged')
|
||||||
if multi
|
if multi
|
||||||
Plug 'junegunn/seoul256.vim'
|
Plug 'junegunn/seoul256.vim'
|
||||||
endif
|
endif
|
||||||
Plug expand('file:///$TMPDIR/new-branch')
|
Plug expand('file:////tmp/new-branch')
|
||||||
call plug#end()
|
call plug#end()
|
||||||
PlugUpdate
|
PlugUpdate
|
||||||
silent %y
|
silent %y
|
||||||
Assert @" =~ 'Not possible to fast-forward', @"
|
Assert @" =~ 'Not possible to fast-forward', @"
|
||||||
endfor
|
endfor
|
||||||
|
q
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
Execute (#145: Merging on-demand loading triggers - cmd):
|
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):
|
Execute (#145: Merging on-demand loading triggers - map):
|
||||||
unlet! g:xxx g:yyy
|
unlet! g:xxx g:yyy
|
||||||
|
|
||||||
|
call ReloadPlug()
|
||||||
call plug#begin()
|
call plug#begin()
|
||||||
Plug '$PLUG_FIXTURES/xxx', { 'on': '<Plug>(xxx)' }
|
Plug '$PLUG_FIXTURES/xxx', { 'on': '<Plug>(xxx)' }
|
||||||
Plug '$PLUG_FIXTURES/yyy', { 'on': ['<Plug>(xxx)' ,'<Plug>(yyy)' ] }
|
Plug '$PLUG_FIXTURES/yyy', { 'on': ['<Plug>(xxx)' ,'<Plug>(yyy)' ] }
|
||||||
@@ -206,7 +210,7 @@ Execute (#159: shell=/bin/tcsh):
|
|||||||
let org = &shell
|
let org = &shell
|
||||||
try
|
try
|
||||||
set shell=/bin/tcsh
|
set shell=/bin/tcsh
|
||||||
call plug#begin('$TMPDIR/plugged')
|
call plug#begin('/tmp/plugged')
|
||||||
Plug 'junegunn/seoul256.vim'
|
Plug 'junegunn/seoul256.vim'
|
||||||
call plug#end()
|
call plug#end()
|
||||||
|
|
||||||
@@ -220,7 +224,7 @@ Execute (#159: shell=/bin/tcsh):
|
|||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
Execute (#154: Spaces in &rtp should not be escaped):
|
Execute (#154: Spaces in &rtp should not be escaped):
|
||||||
call plug#begin('$TMPDIR/plug it')
|
call plug#begin('/tmp/plug it')
|
||||||
Plug 'seoul256 vim'
|
Plug 'seoul256 vim'
|
||||||
call plug#end()
|
call plug#end()
|
||||||
Log &rtp
|
Log &rtp
|
||||||
@@ -228,7 +232,7 @@ Execute (#154: Spaces in &rtp should not be escaped):
|
|||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
Execute (#184: Duplicate entries in &rtp):
|
Execute (#184: Duplicate entries in &rtp):
|
||||||
call plug#begin('$TMPDIR/plugged')
|
call plug#begin('/tmp/plugged')
|
||||||
Plug 'plugin1'
|
Plug 'plugin1'
|
||||||
\| Plug 'plugin0'
|
\| Plug 'plugin0'
|
||||||
|
|
||||||
@@ -240,3 +244,22 @@ Execute (#184: Duplicate entries in &rtp):
|
|||||||
Log &rtp
|
Log &rtp
|
||||||
AssertEqual 3, len(filter(split(&rtp, ','), 'stridx(v:val, "plugged") >= 0'))
|
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'
|
||||||
|
|||||||
64
test/run
64
test/run
@@ -1,11 +1,16 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
cd $(dirname $BASH_SOURCE)
|
cd $(dirname "${BASH_SOURCE[0]}")
|
||||||
cd ..
|
|
||||||
PLUG_SRC=$(pwd)/plug.vim
|
|
||||||
cd - > /dev/null
|
|
||||||
|
|
||||||
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() {
|
clone() {
|
||||||
if [ ! -d $2 ]; then
|
if [ ! -d $2 ]; then
|
||||||
@@ -13,7 +18,7 @@ clone() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Clone
|
clone_repos() {
|
||||||
cd /tmp
|
cd /tmp
|
||||||
mkdir -p junegunn vim-scripts jg
|
mkdir -p junegunn vim-scripts jg
|
||||||
for repo in vader.vim goyo.vim rust.vim seoul256.vim vim-easy-align vim-fnr \
|
for repo in vader.vim goyo.vim rust.vim seoul256.vim vim-easy-align vim-fnr \
|
||||||
@@ -21,17 +26,17 @@ for repo in vader.vim goyo.vim rust.vim seoul256.vim vim-easy-align vim-fnr \
|
|||||||
clone https://github.com/junegunn/${repo}.git junegunn/$repo &
|
clone https://github.com/junegunn/${repo}.git junegunn/$repo &
|
||||||
done
|
done
|
||||||
clone https://github.com/vim-scripts/beauty256.git vim-scripts/beauty256 &
|
clone https://github.com/vim-scripts/beauty256.git vim-scripts/beauty256 &
|
||||||
|
clone https://github.com/junegunn/fzf.git fzf &
|
||||||
rm -rf $PLUG_FIXTURES/fzf
|
|
||||||
clone https://github.com/junegunn/fzf.git $PLUG_FIXTURES/fzf-staged &
|
|
||||||
wait
|
wait
|
||||||
|
|
||||||
(cd junegunn/seoul256.vim &&
|
|
||||||
git checkout no-t_co && git checkout master) > /dev/null 2>&1
|
|
||||||
clone junegunn/vim-emoji jg/vim-emoji
|
clone junegunn/vim-emoji jg/vim-emoji
|
||||||
cd - > /dev/null
|
cd junegunn/seoul256.vim && git checkout no-t_co && git checkout master
|
||||||
|
|
||||||
|
cd "$BASE"
|
||||||
|
}
|
||||||
|
|
||||||
make_dirs() {
|
make_dirs() {
|
||||||
|
rm -rf "$PLUG_FIXTURES/$1"
|
||||||
mkdir -p "$PLUG_FIXTURES/$1"
|
mkdir -p "$PLUG_FIXTURES/$1"
|
||||||
cd "$PLUG_FIXTURES/$1"
|
cd "$PLUG_FIXTURES/$1"
|
||||||
mkdir -p autoload colors ftdetect ftplugin indent plugin syntax
|
mkdir -p autoload colors ftdetect ftplugin indent plugin syntax
|
||||||
@@ -46,17 +51,15 @@ make_dirs() {
|
|||||||
call add(g:total_order, s:name)
|
call add(g:total_order, s:name)
|
||||||
EOF
|
EOF
|
||||||
done
|
done
|
||||||
cd - > /dev/null
|
|
||||||
|
cd "$BASE"
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
prepare() {
|
||||||
rm -rf $PLUG_FIXTURES/{xxx,yyy,z1,z2}
|
|
||||||
rm -rf $TMPDIR/new-branch
|
|
||||||
|
|
||||||
make_dirs xxx/ xxx
|
make_dirs xxx/ xxx
|
||||||
make_dirs xxx/after xxx
|
make_dirs xxx/after xxx
|
||||||
mkdir -p $PLUG_FIXTURES/xxx/doc
|
mkdir -p "$PLUG_FIXTURES/xxx/doc"
|
||||||
cat > $PLUG_FIXTURES/xxx/doc/xxx.txt << DOC
|
cat > "$PLUG_FIXTURES/xxx/doc/xxx.txt" << DOC
|
||||||
hello *xxx*
|
hello *xxx*
|
||||||
DOC
|
DOC
|
||||||
|
|
||||||
@@ -66,28 +69,27 @@ DOC
|
|||||||
make_dirs z1/ z1
|
make_dirs z1/ z1
|
||||||
make_dirs z2/ z2
|
make_dirs z2/ z2
|
||||||
|
|
||||||
(
|
rm -rf "$PLUG_FIXTURES/ftplugin-msg"
|
||||||
cd $TMPDIR
|
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
|
git init new-branch
|
||||||
cd new-branch
|
cd new-branch
|
||||||
mkdir plugin
|
mkdir plugin
|
||||||
echo 'let g:foo = 1' > plugin/foo.vim
|
echo 'let g:foo = 1' > plugin/foo.vim
|
||||||
git add plugin/foo.vim
|
git add plugin/foo.vim
|
||||||
git commit -m initial
|
git commit -m initial
|
||||||
)
|
|
||||||
|
cd "$BASE"
|
||||||
}
|
}
|
||||||
|
|
||||||
cat > /tmp/mini-vimrc << VIMRC
|
clone_repos
|
||||||
set rtp+=/tmp/junegunn/vader.vim
|
prepare
|
||||||
set shell=/bin/bash
|
|
||||||
source $PLUG_SRC
|
|
||||||
VIMRC
|
|
||||||
|
|
||||||
[ -z "$TMPDIR" ] && export TMPDIR=/tmp/
|
|
||||||
init
|
|
||||||
if [ "$1" = '!' ]; then
|
if [ "$1" = '!' ]; then
|
||||||
/usr/local/bin/vim -Nu /tmp/mini-vimrc -c 'Vader! test.vader' > /dev/null &&
|
/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
|
/usr/local/bin/vim -Nu /tmp/mini-vimrc -c 'let g:plug_threads = 1 | Vader! test.vader' > /dev/null
|
||||||
else
|
else
|
||||||
/usr/local/bin/vim -Nu /tmp/mini-vimrc -c 'Vader test.vader'
|
/usr/local/bin/vim -Nu /tmp/mini-vimrc -c 'Vader test.vader'
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
Execute (Initialize test environment):
|
Execute (Initialize test environment):
|
||||||
Save &rtp, g:plugs, g:plug_home, g:plug_window
|
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
|
unlet! g:plugs g:plug_home g:plug_window
|
||||||
|
|
||||||
let g:plug_url_format = 'file:///tmp/%s'
|
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
|
set t_Co=256
|
||||||
colo default
|
colo default
|
||||||
@@ -39,12 +41,26 @@ Execute (Initialize test environment):
|
|||||||
endif
|
endif
|
||||||
endfunction
|
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):
|
Execute (Print Interpreter Version):
|
||||||
redir => out
|
redir => out
|
||||||
if has('ruby')
|
if has('ruby')
|
||||||
silent ruby puts 'Ruby: ' + RUBY_VERSION
|
silent ruby puts 'Ruby: ' + RUBY_VERSION
|
||||||
elseif has('python')
|
elseif has('python')
|
||||||
silent python import sys; svi = sys.version_info; print 'Python: {}.{}.{}'.format(svi[0], svi[1], svi[2])
|
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
|
endif
|
||||||
redir END
|
redir END
|
||||||
Log substitute(out, '\n', '', 'g')
|
Log substitute(out, '\n', '', 'g')
|
||||||
@@ -53,20 +69,18 @@ Include: workflow.vader
|
|||||||
Include: regressions.vader
|
Include: regressions.vader
|
||||||
|
|
||||||
Execute (Cleanup):
|
Execute (Cleanup):
|
||||||
silent! call system('rm -rf '.temp_plugged)
|
silent! call RmRf(g:temp_plugged)
|
||||||
silent! call system('rm -rf '.temp_plugged)
|
silent! unlet g:plugs g:plug_home g:plug_url_format
|
||||||
silent! call rename(fzf, expand('$PLUG_FIXTURES/fzf-staged'))
|
silent! unlet g:temp_plugged g:first_rtp g:last_rtp g:base_rtp out
|
||||||
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! delf PlugStatusSorted
|
silent! delf PlugStatusSorted
|
||||||
silent! delf AssertExpect
|
silent! delf AssertExpect
|
||||||
silent! delf PlugUpdated
|
silent! delf PlugUpdated
|
||||||
silent! delf EnsureLoaded
|
silent! delf EnsureLoaded
|
||||||
|
silent! delf ReloadPlug
|
||||||
silent! delc AssertExpect
|
silent! delc AssertExpect
|
||||||
silent! unmap /
|
silent! unmap /
|
||||||
silent! unmap ?
|
silent! unmap ?
|
||||||
|
call system('mv $PLUG_SRC.org $PLUG_SRC')
|
||||||
|
|
||||||
Restore
|
Restore
|
||||||
|
|
||||||
|
|||||||
@@ -17,25 +17,25 @@ Execute (plug#begin() without path argument with empty &rtp):
|
|||||||
redir END
|
redir END
|
||||||
Assert stridx(out, 'Unable to determine plug home') >= 0
|
Assert stridx(out, 'Unable to determine plug home') >= 0
|
||||||
let &rtp = save_rtp
|
let &rtp = save_rtp
|
||||||
|
unlet save_rtp
|
||||||
|
|
||||||
Execute (plug#begin(path)):
|
Execute (plug#begin(path)):
|
||||||
let temp_plugged = tempname()
|
call plug#begin(g:temp_plugged.'/')
|
||||||
call plug#begin(temp_plugged.'/')
|
|
||||||
Assert g:plug_home !~ '[/\\]$', 'Trailing / should be stripped from g:plug_home'
|
Assert g:plug_home !~ '[/\\]$', 'Trailing / should be stripped from g:plug_home'
|
||||||
|
|
||||||
AssertEqual 0, len(g:plugs)
|
AssertEqual 0, len(g:plugs)
|
||||||
AssertEqual temp_plugged, g:plug_home
|
AssertEqual g:temp_plugged, g:plug_home
|
||||||
AssertEqual basertp, &rtp
|
AssertEqual g:base_rtp, &rtp
|
||||||
|
|
||||||
Execute (Subsequent plug#begin() calls will reuse g:plug_home):
|
Execute (Subsequent plug#begin() calls will reuse g:plug_home):
|
||||||
call plug#begin()
|
call plug#begin()
|
||||||
AssertEqual temp_plugged, g:plug_home
|
AssertEqual g:temp_plugged, g:plug_home
|
||||||
|
|
||||||
Execute (Test Plug command):
|
Execute (Test Plug command):
|
||||||
^ Git repo with branch (DEPRECATED. USE BRANCH OPTION)
|
^ Git repo with branch (DEPRECATED. USE BRANCH OPTION)
|
||||||
Plug 'junegunn/seoul256.vim', { 'branch': 'yes-t_co' }
|
Plug 'junegunn/seoul256.vim', { 'branch': 'yes-t_co' }
|
||||||
AssertEqual 'file:///tmp/junegunn/seoul256.vim', g:plugs['seoul256.vim'].uri
|
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
|
AssertEqual 'yes-t_co', g:plugs['seoul256.vim'].branch
|
||||||
|
|
||||||
Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co' } " Using branch option
|
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)
|
^ Git repo with tag (DEPRECATED. USE TAG OPTION)
|
||||||
Plug 'junegunn/goyo.vim', '1.5.2'
|
Plug 'junegunn/goyo.vim', '1.5.2'
|
||||||
AssertEqual 'file:///tmp/junegunn/goyo.vim', g:plugs['goyo.vim'].uri
|
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
|
AssertEqual '1.5.2', g:plugs['goyo.vim'].tag
|
||||||
|
|
||||||
Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' } " Using tag option
|
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'
|
Plug 'file:///tmp/jg/vim-emoji'
|
||||||
AssertEqual 'file:///tmp/jg/vim-emoji', g:plugs['vim-emoji'].uri
|
AssertEqual 'file:///tmp/jg/vim-emoji', g:plugs['vim-emoji'].uri
|
||||||
AssertEqual 'master', g:plugs['vim-emoji'].branch
|
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/
|
" vim-scripts/
|
||||||
Plug 'beauty256'
|
Plug 'beauty256'
|
||||||
@@ -66,7 +66,7 @@ Execute (Test Plug command):
|
|||||||
Execute (Plug command with dictionary option):
|
Execute (Plug command with dictionary option):
|
||||||
Log string(g:plugs)
|
Log string(g:plugs)
|
||||||
Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co', 'rtp': '././' }
|
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
|
AssertEqual '././', g:plugs['seoul256.vim'].rtp
|
||||||
|
|
||||||
Log string(g:plugs)
|
Log string(g:plugs)
|
||||||
@@ -84,9 +84,9 @@ Execute (PlugClean before installation):
|
|||||||
|
|
||||||
Execute (plug#end() updates &rtp):
|
Execute (plug#end() updates &rtp):
|
||||||
call plug#end()
|
call plug#end()
|
||||||
Assert len(&rtp) > len(basertp)
|
Assert len(&rtp) > len(g:base_rtp)
|
||||||
AssertEqual first_rtp, split(&rtp, ',')[0]
|
AssertEqual g:first_rtp, split(&rtp, ',')[0]
|
||||||
AssertEqual last_rtp, split(&rtp, ',')[-1]
|
AssertEqual g:last_rtp, split(&rtp, ',')[-1]
|
||||||
|
|
||||||
Execute (Yet, plugins are not available):
|
Execute (Yet, plugins are not available):
|
||||||
Assert empty(globpath(&rtp, 'autoload/emoji.vim'))
|
Assert empty(globpath(&rtp, 'autoload/emoji.vim'))
|
||||||
@@ -270,10 +270,13 @@ Execute (PlugDiff - 'No updates.'):
|
|||||||
AssertEqual 'No updates.', getline(1)
|
AssertEqual 'No updates.', getline(1)
|
||||||
q
|
q
|
||||||
|
|
||||||
Execute (Rollback recent updates, PlugUpdate, then PlugDiff):
|
Execute (New commits on remote, PlugUpdate, then PlugDiff):
|
||||||
for repo in ['seoul256.vim', 'vim-emoji']
|
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
|
||||||
|
endfor
|
||||||
|
unlet repo
|
||||||
PlugUpdate
|
PlugUpdate
|
||||||
|
|
||||||
" Now we have updates
|
" Now we have updates
|
||||||
@@ -307,6 +310,7 @@ Execute (Rollback recent updates, PlugUpdate, then PlugDiff):
|
|||||||
" [[ motion
|
" [[ motion
|
||||||
execute 'normal 0[['
|
execute 'normal 0[['
|
||||||
AssertEqual lnum, line('.')
|
AssertEqual lnum, line('.')
|
||||||
|
unlet lnum
|
||||||
AssertEqual 3, col('.')
|
AssertEqual 3, col('.')
|
||||||
|
|
||||||
" X key to revert the update
|
" X key to revert the update
|
||||||
@@ -346,12 +350,14 @@ Execute (Reuse Plug window in another tab):
|
|||||||
AssertEqual tabnr, tabpagenr()
|
AssertEqual tabnr, tabpagenr()
|
||||||
normal! gt
|
normal! gt
|
||||||
q
|
q
|
||||||
|
unlet tabnr
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
~ On-demand loading / Partial installation/update ~
|
~ On-demand loading / Partial installation/update ~
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
|
|
||||||
Execute (Trying to execute on-demand commands when plugin is not installed):
|
Execute (Trying to execute on-demand commands when plugin is not installed):
|
||||||
|
call ReloadPlug()
|
||||||
call plug#begin()
|
call plug#begin()
|
||||||
Plug 'junegunn/vim-easy-align', { 'on': ['EasyAlign', 'LiveEasyAlign'] }
|
Plug 'junegunn/vim-easy-align', { 'on': ['EasyAlign', 'LiveEasyAlign'] }
|
||||||
call plug#end()
|
call plug#end()
|
||||||
@@ -364,16 +370,22 @@ Execute (Trying to execute on-demand commands when plugin is not installed):
|
|||||||
Assert !exists(':LiveEasyAlign')
|
Assert !exists(':LiveEasyAlign')
|
||||||
|
|
||||||
Execute (New set of plugins):
|
Execute (New set of plugins):
|
||||||
|
call ReloadPlug()
|
||||||
call plug#begin()
|
call plug#begin()
|
||||||
Plug 'junegunn/vim-fnr'
|
Plug 'junegunn/vim-fnr'
|
||||||
Plug 'junegunn/vim-pseudocl'
|
Plug 'junegunn/vim-pseudocl'
|
||||||
Plug 'junegunn/vim-easy-align', { 'on': 'EasyAlign' }
|
Plug 'junegunn/vim-easy-align', { 'on': 'EasyAlign' }
|
||||||
Plug 'junegunn/vim-redis', { 'for': 'redis' }
|
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()
|
call plug#end()
|
||||||
|
|
||||||
Execute (Check commands):
|
Execute (Check commands):
|
||||||
Assert !exists(':FNR'), 'FNR command should not be found'
|
Assert !exists(':FNR'), 'FNR command should not be found'
|
||||||
Assert !exists(':RedisExecute'), 'RedisExecute command should not be found'
|
Assert !exists(':RedisExecute'), 'RedisExecute command should not be found'
|
||||||
|
Assert empty(user_autocmd)
|
||||||
|
|
||||||
Execute (Partial PlugInstall):
|
Execute (Partial PlugInstall):
|
||||||
PlugInstall vim-fnr vim-easy-align
|
PlugInstall vim-fnr vim-easy-align
|
||||||
@@ -383,8 +395,8 @@ Execute (Partial PlugInstall):
|
|||||||
PlugInstall vim-fnr vim-easy-align 1
|
PlugInstall vim-fnr vim-easy-align 1
|
||||||
AssertExpect 'vim-fnr', 1
|
AssertExpect 'vim-fnr', 1
|
||||||
AssertExpect 'vim-easy-align', 1
|
AssertExpect 'vim-easy-align', 1
|
||||||
AssertEqual first_rtp, split(&rtp, ',')[0]
|
AssertEqual g:first_rtp, split(&rtp, ',')[0]
|
||||||
AssertEqual last_rtp, split(&rtp, ',')[-1]
|
AssertEqual g:last_rtp, split(&rtp, ',')[-1]
|
||||||
q
|
q
|
||||||
|
|
||||||
Given (Unaligned code):
|
Given (Unaligned code):
|
||||||
@@ -403,6 +415,10 @@ Expect (Aligned code):
|
|||||||
a = 1
|
a = 1
|
||||||
aa = 2
|
aa = 2
|
||||||
|
|
||||||
|
Then (autocmd executed):
|
||||||
|
Assert user_autocmd.easy_align
|
||||||
|
AssertEqual 1, len(user_autocmd)
|
||||||
|
|
||||||
Given:
|
Given:
|
||||||
Execute (Partial PlugUpdate):
|
Execute (Partial PlugUpdate):
|
||||||
PlugUpdate vim-redis
|
PlugUpdate vim-redis
|
||||||
@@ -412,6 +428,11 @@ Execute (On-demand loading based on filetypes):
|
|||||||
Assert !exists(':RedisExecute'), 'RedisExecute command still should not be found'
|
Assert !exists(':RedisExecute'), 'RedisExecute command still should not be found'
|
||||||
set ft=redis
|
set ft=redis
|
||||||
Assert exists(':RedisExecute'), 'RedisExecute command is now found'
|
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
|
~ Local (unmanaged) plugins
|
||||||
@@ -419,6 +440,7 @@ Execute (On-demand loading based on filetypes):
|
|||||||
|
|
||||||
Execute (Add unmanaged plugin):
|
Execute (Add unmanaged plugin):
|
||||||
let fzf = expand('$PLUG_FIXTURES/fzf')
|
let fzf = expand('$PLUG_FIXTURES/fzf')
|
||||||
|
call RmRf(fzf)
|
||||||
Log fzf
|
Log fzf
|
||||||
|
|
||||||
call plug#begin()
|
call plug#begin()
|
||||||
@@ -477,7 +499,8 @@ Execute (PlugStatus should point out that the plugin is missing):
|
|||||||
|
|
||||||
Execute (Deploy unmanaged plugin):
|
Execute (Deploy unmanaged plugin):
|
||||||
Assert !exists(':FZF'), ':FZF command should not exist'
|
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):
|
Execute (PlugUpdate still should not care):
|
||||||
PlugUpdate
|
PlugUpdate
|
||||||
@@ -497,8 +520,8 @@ Execute (Check &rtp after SomeCommand):
|
|||||||
Assert &rtp !~ 'fzf'
|
Assert &rtp !~ 'fzf'
|
||||||
silent! SomeCommand
|
silent! SomeCommand
|
||||||
Assert &rtp =~ 'fzf'
|
Assert &rtp =~ 'fzf'
|
||||||
AssertEqual first_rtp, split(&rtp, ',')[0]
|
AssertEqual g:first_rtp, split(&rtp, ',')[0]
|
||||||
AssertEqual last_rtp, split(&rtp, ',')[-1]
|
AssertEqual g:last_rtp, split(&rtp, ',')[-1]
|
||||||
|
|
||||||
Execute (Common parent):
|
Execute (Common parent):
|
||||||
call plug#begin()
|
call plug#begin()
|
||||||
@@ -512,6 +535,8 @@ Execute (Common parent):
|
|||||||
AssertExpect! '[===]', 1
|
AssertExpect! '[===]', 1
|
||||||
q
|
q
|
||||||
|
|
||||||
|
unlet fzf
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
~ Frozen plugins
|
~ Frozen plugins
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
@@ -639,8 +664,8 @@ Execute (On update):
|
|||||||
Plug 'junegunn/vim-pseudocl', { 'do': 'touch updated' }
|
Plug 'junegunn/vim-pseudocl', { 'do': 'touch updated' }
|
||||||
call plug#end()
|
call plug#end()
|
||||||
|
|
||||||
" Reset for updates
|
" New commits on remote
|
||||||
call system('cd '.g:plugs['vim-pseudocl'].dir.' && git reset --hard HEAD^')
|
call system('cd /tmp/junegunn/vim-pseudocl && git commit --allow-empty -m "update"')
|
||||||
|
|
||||||
silent PlugUpdate
|
silent PlugUpdate
|
||||||
Log getline(1, '$')
|
Log getline(1, '$')
|
||||||
@@ -703,8 +728,9 @@ Execute (Using Funcref):
|
|||||||
Plug 'junegunn/vim-pseudocl', { 'do': function('PlugUpdated') }
|
Plug 'junegunn/vim-pseudocl', { 'do': function('PlugUpdated') }
|
||||||
call plug#end()
|
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('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
|
PlugUpdate
|
||||||
Log getline(1, '$')
|
Log getline(1, '$')
|
||||||
@@ -714,7 +740,7 @@ Execute (Using Funcref):
|
|||||||
Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclinstalled03'),
|
Assert filereadable(g:plugs['vim-pseudocl'].dir.'/vim-pseudoclinstalled03'),
|
||||||
\ 'vim-pseudocl/vim-pseudoclinstalled03 should exist'
|
\ 'vim-pseudocl/vim-pseudoclinstalled03 should exist'
|
||||||
|
|
||||||
call system('rm -rf '.g:plugs['vim-pseudocl'].dir)
|
call RmRf(g:plugs['vim-pseudocl'].dir)
|
||||||
PlugInstall!
|
PlugInstall!
|
||||||
q
|
q
|
||||||
Assert filereadable(g:plugs['vim-easy-align'].dir.'/vim-easy-alignunchanged13'),
|
Assert filereadable(g:plugs['vim-easy-align'].dir.'/vim-easy-alignunchanged13'),
|
||||||
@@ -737,11 +763,11 @@ Execute (Using Funcref):
|
|||||||
Execute (Using custom dir):
|
Execute (Using custom dir):
|
||||||
Assert isdirectory(g:plugs['vim-easy-align'].dir)
|
Assert isdirectory(g:plugs['vim-easy-align'].dir)
|
||||||
|
|
||||||
call system('rm -rf '.$TMPDIR.'easy-align')
|
call RmRf('/tmp/easy-align')
|
||||||
call plug#begin()
|
call plug#begin()
|
||||||
Plug 'junegunn/vim-easy-align', { 'dir': $TMPDIR.'easy-align' }
|
Plug 'junegunn/vim-easy-align', { 'dir': '/tmp/easy-align' }
|
||||||
call plug#end()
|
call plug#end()
|
||||||
AssertEqual $TMPDIR.'easy-align/', g:plugs['vim-easy-align'].dir
|
AssertEqual '/tmp/easy-align/', g:plugs['vim-easy-align'].dir
|
||||||
|
|
||||||
PlugClean!
|
PlugClean!
|
||||||
Assert !isdirectory(g:plugs['vim-easy-align'].dir)
|
Assert !isdirectory(g:plugs['vim-easy-align'].dir)
|
||||||
@@ -760,6 +786,7 @@ Before (Clear global vars):
|
|||||||
set rtp-=$PLUG_FIXTURES/xxx/after
|
set rtp-=$PLUG_FIXTURES/xxx/after
|
||||||
|
|
||||||
Execute (Immediate loading):
|
Execute (Immediate loading):
|
||||||
|
call ReloadPlug()
|
||||||
call plug#begin()
|
call plug#begin()
|
||||||
Plug '$PLUG_FIXTURES/xxx'
|
Plug '$PLUG_FIXTURES/xxx'
|
||||||
call plug#end()
|
call plug#end()
|
||||||
@@ -774,6 +801,7 @@ Execute (Immediate loading):
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
Execute (Command-based on-demand loading):
|
Execute (Command-based on-demand loading):
|
||||||
|
call ReloadPlug()
|
||||||
call plug#begin()
|
call plug#begin()
|
||||||
Plug '$PLUG_FIXTURES/xxx', { 'on': 'XXX' }
|
Plug '$PLUG_FIXTURES/xxx', { 'on': 'XXX' }
|
||||||
call plug#end()
|
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
|
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):
|
Execute (Filetype-based on-demand loading):
|
||||||
|
call ReloadPlug()
|
||||||
call plug#begin()
|
call plug#begin()
|
||||||
Plug '$PLUG_FIXTURES/xxx', { 'for': 'xxx' }
|
Plug '$PLUG_FIXTURES/xxx', { 'for': 'xxx' }
|
||||||
call plug#end()
|
call plug#end()
|
||||||
@@ -901,7 +930,7 @@ Execute (Open plug window in a new tab):
|
|||||||
normal S
|
normal S
|
||||||
AssertEqual tabnr, tabpagenr()
|
AssertEqual tabnr, tabpagenr()
|
||||||
q
|
q
|
||||||
unlet g:plug_window
|
unlet g:plug_window tabnr
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
~ g:plug_url_format
|
~ g:plug_url_format
|
||||||
@@ -947,7 +976,7 @@ Execute (Update plugin with U key in normal mode):
|
|||||||
q
|
q
|
||||||
|
|
||||||
Execute (Update plugins with U key in visual mode):
|
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
|
PlugStatus
|
||||||
normal VGU
|
normal VGU
|
||||||
@@ -974,7 +1003,7 @@ Execute (plug#begin should expand env vars):
|
|||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
Execute (Plug directory with comma):
|
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'
|
Plug 'junegunn/vim-emoji'
|
||||||
call plug#end()
|
call plug#end()
|
||||||
Log &rtp
|
Log &rtp
|
||||||
@@ -984,10 +1013,12 @@ Execute (Plug directory with comma):
|
|||||||
let found = filter(split(globpath(&rtp, 'README.md'), '\n'), 'v:val =~ ","')
|
let found = filter(split(globpath(&rtp, 'README.md'), '\n'), 'v:val =~ ","')
|
||||||
Log found
|
Log found
|
||||||
AssertEqual 1, len(found)
|
AssertEqual 1, len(found)
|
||||||
|
unlet found
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
Execute (Strict load order):
|
Execute (Strict load order):
|
||||||
let g:total_order = []
|
let g:total_order = []
|
||||||
|
call ReloadPlug()
|
||||||
call plug#begin()
|
call plug#begin()
|
||||||
Plug '$PLUG_FIXTURES/xxx'
|
Plug '$PLUG_FIXTURES/xxx'
|
||||||
Plug '$PLUG_FIXTURES/yyy', { 'for': ['xxx'] }
|
Plug '$PLUG_FIXTURES/yyy', { 'for': ['xxx'] }
|
||||||
@@ -1001,6 +1032,7 @@ Execute (Strict load order):
|
|||||||
let len = len(split(&rtp, ','))
|
let len = len(split(&rtp, ','))
|
||||||
|
|
||||||
let g:total_order = []
|
let g:total_order = []
|
||||||
|
call ReloadPlug()
|
||||||
call plug#begin()
|
call plug#begin()
|
||||||
Plug '$PLUG_FIXTURES/xxx', { 'for': ['xxx'] }
|
Plug '$PLUG_FIXTURES/xxx', { 'for': ['xxx'] }
|
||||||
Plug '$PLUG_FIXTURES/yyy'
|
Plug '$PLUG_FIXTURES/yyy'
|
||||||
@@ -1018,6 +1050,9 @@ Execute (Strict load order):
|
|||||||
AssertEqual len + 2, len(split(&rtp, ','))
|
AssertEqual len + 2, len(split(&rtp, ','))
|
||||||
|
|
||||||
let g:total_order = []
|
let g:total_order = []
|
||||||
|
call ReloadPlug()
|
||||||
|
set rtp^=manually-prepended
|
||||||
|
set rtp+=manually-appended
|
||||||
call plug#begin()
|
call plug#begin()
|
||||||
Plug '$PLUG_FIXTURES/xxx', { 'for': ['xxx'] }
|
Plug '$PLUG_FIXTURES/xxx', { 'for': ['xxx'] }
|
||||||
Plug '$PLUG_FIXTURES/yyy', { '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):
|
Execute (PlugSnapshot / #154 issues with paths containing spaces):
|
||||||
|
let $TMPDIR = '/tmp'
|
||||||
call plug#begin('$TMPDIR/plug with spaces')
|
call plug#begin('$TMPDIR/plug with spaces')
|
||||||
Plug 'junegunn/vim-easy-align'
|
Plug 'junegunn/vim-easy-align'
|
||||||
Plug 'junegunn/seoul256.vim'
|
Plug 'junegunn/seoul256.vim'
|
||||||
@@ -1073,3 +1109,60 @@ Execute (PlugSnapshot / #154 issues with paths containing spaces):
|
|||||||
AssertEqual 'snapshot.sh', fnamemodify(expand('%'), ':t')
|
AssertEqual 'snapshot.sh', fnamemodify(expand('%'), ':t')
|
||||||
q
|
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 -
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user