mirror of
https://github.com/junegunn/vim-plug.git
synced 2025-12-07 09:34:25 +08:00
Compare commits
37 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f31477407a | ||
|
|
0e907d4f38 | ||
|
|
cb08d6036b | ||
|
|
9d63fe6aeb | ||
|
|
0489b5deed | ||
|
|
cac2f9f439 | ||
|
|
115a25de79 | ||
|
|
a64b156682 | ||
|
|
a9fa8f44e5 | ||
|
|
d6590fa883 | ||
|
|
cabaf7b431 | ||
|
|
6e509db6ff | ||
|
|
7b7778d5ba | ||
|
|
f3e2d214df | ||
|
|
5ec1faefab | ||
|
|
6406d73c9a | ||
|
|
ff4cbe23c0 | ||
|
|
681ca2d43a | ||
|
|
adb2413f0d | ||
|
|
dda21b50bf | ||
|
|
537a5321aa | ||
|
|
99f6f36b69 | ||
|
|
3f82808bea | ||
|
|
7474edf13f | ||
|
|
25b0fb7583 | ||
|
|
a868ee4c11 | ||
|
|
49851436ff | ||
|
|
2f9a94e8c0 | ||
|
|
ab3bd3b17c | ||
|
|
3572ffde79 | ||
|
|
18c8b54793 | ||
|
|
1752de5b7c | ||
|
|
2f3225fc60 | ||
|
|
1022acad0b | ||
|
|
68c7fbbf9d | ||
|
|
da24f714e0 | ||
|
|
c1bbbaf3ef |
34
README.md
34
README.md
@@ -1,15 +1,15 @@
|
||||

|
||||

|
||||

|
||||
[](https://travis-ci.org/junegunn/vim-plug)
|
||||
|
||||
A minimalist Vim plugin manager.
|
||||
|
||||

|
||||

|
||||
|
||||
### Pros.
|
||||
|
||||
- Easier to setup: Single file. No boilerplate code required.
|
||||
- Easier to use: Concise, intuitive syntax
|
||||
- [Super-fast](https://raw.github.com/junegunn/i/master/vim-plug/40-in-4.gif)
|
||||
- [Super-fast](https://raw.githubusercontent.com/junegunn/i/master/vim-plug/40-in-4.gif)
|
||||
parallel installation/update (requires
|
||||
[+ruby](https://github.com/junegunn/vim-plug/wiki/ruby))
|
||||
- On-demand loading to achieve
|
||||
@@ -20,13 +20,13 @@ A minimalist Vim plugin manager.
|
||||
|
||||
### Usage
|
||||
|
||||
[Download plug.vim](https://raw.github.com/junegunn/vim-plug/master/plug.vim)
|
||||
[Download plug.vim](https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim)
|
||||
and put it in ~/.vim/autoload
|
||||
|
||||
```sh
|
||||
mkdir -p ~/.vim/autoload
|
||||
curl -fLo ~/.vim/autoload/plug.vim \
|
||||
https://raw.github.com/junegunn/vim-plug/master/plug.vim
|
||||
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||
```
|
||||
|
||||
Edit your .vimrc
|
||||
@@ -82,19 +82,22 @@ Reload .vimrc and `:PlugInstall` to install plugins.
|
||||
| `for` | On-demand loading: File types |
|
||||
| `frozen` | Do not install/update plugin unless explicitly given as the argument |
|
||||
|
||||
### Options for parallel installer
|
||||
### Global options
|
||||
|
||||
| Flag | Default | Description |
|
||||
| ---------------- | ------- | ------------------------------------ |
|
||||
| `g:plug_threads` | 16 | Default number of threads to use |
|
||||
| `g:plug_timeout` | 60 | Time limit of each task in seconds |
|
||||
| `g:plug_retries` | 2 | Number of retries in case of timeout |
|
||||
| Flag | Default | Description |
|
||||
| ------------------- | --------------------------------- | ------------------------------------ |
|
||||
| `g:plug_threads` | 16 | Default number of threads to use |
|
||||
| `g:plug_timeout` | 60 | Time limit of each task in seconds |
|
||||
| `g:plug_retries` | 2 | Number of retries in case of timeout |
|
||||
| `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
|
||||
|
||||
- `D` - `PlugDiff`
|
||||
- `S` - `PlugStatus`
|
||||
- `R` - Retry failed update or installation tasks
|
||||
- `U` - Update plugins in the selected range
|
||||
- `q` - Close the window
|
||||
- `:PlugStatus`
|
||||
- `L` - Load plugin
|
||||
@@ -121,10 +124,17 @@ Plug 'junegunn/vim-github-dashboard', { 'on': ['GHDashboard', 'GHActivity'] }
|
||||
" Loaded when clojure file is opened
|
||||
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
|
||||
|
||||
" Multiple file types
|
||||
Plug 'kovisoft/paredit', { 'for': ['clojure', 'scheme'] }
|
||||
|
||||
" On-demand loading on both conditions
|
||||
Plug 'junegunn/vader.vim', { 'on': 'Vader', 'for': 'vader' }
|
||||
```
|
||||
|
||||
`for` option is generally not needed as most plugins for specific file types
|
||||
usually don't have too much code in `plugin` directory. You might want to
|
||||
examine the output of `vim --startuptime` before applying the option.
|
||||
|
||||
### Post-update hooks
|
||||
|
||||
There are some plugins that require extra steps after installation or update.
|
||||
|
||||
311
plug.vim
311
plug.vim
@@ -5,7 +5,7 @@
|
||||
"
|
||||
" mkdir -p ~/.vim/autoload
|
||||
" curl -fLo ~/.vim/autoload/plug.vim \
|
||||
" https://raw.github.com/junegunn/vim-plug/master/plug.vim
|
||||
" https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||
"
|
||||
" Edit your .vimrc
|
||||
"
|
||||
@@ -68,11 +68,11 @@ let g:loaded_plug = 1
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
let s:plug_source = 'https://raw.github.com/junegunn/vim-plug/master/plug.vim'
|
||||
let s:plug_source = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
|
||||
let s:plug_buf = get(s:, 'plug_buf', -1)
|
||||
let s:mac_gui = has('gui_macvim') && has('gui_running')
|
||||
let s:is_win = has('win32') || has('win64')
|
||||
let s:me = expand('<sfile>:p')
|
||||
let s:me = resolve(expand('<sfile>:p'))
|
||||
let s:base_spec = { 'branch': 'master', 'frozen': 0 }
|
||||
let s:TYPE = {
|
||||
\ 'string': type(''),
|
||||
@@ -84,7 +84,7 @@ let s:loaded = get(s:, 'loaded', {})
|
||||
|
||||
function! plug#begin(...)
|
||||
if a:0 > 0
|
||||
let home = s:path(fnamemodify(a:1, ':p'))
|
||||
let home = s:path(fnamemodify(expand(a:1), ':p'))
|
||||
elseif exists('g:plug_home')
|
||||
let home = s:path(g:plug_home)
|
||||
elseif !empty(&rtp)
|
||||
@@ -93,10 +93,6 @@ function! plug#begin(...)
|
||||
return s:err('Unable to determine plug home. Try calling plug#begin() with a path argument.')
|
||||
endif
|
||||
|
||||
if !executable('git')
|
||||
return s:err('`git` executable not found. vim-plug requires git.')
|
||||
endif
|
||||
|
||||
let g:plug_home = home
|
||||
let g:plugs = {}
|
||||
" we want to keep track of the order plugins where registered.
|
||||
@@ -107,11 +103,14 @@ function! plug#begin(...)
|
||||
endfunction
|
||||
|
||||
function! s:define_commands()
|
||||
command! -nargs=+ -bar Plug call s:add(<args>)
|
||||
command! -nargs=* -bar -bang -complete=customlist,s:names PlugInstall call s:install('<bang>' == '!', <f-args>)
|
||||
command! -nargs=* -bar -bang -complete=customlist,s:names PlugUpdate call s:update('<bang>' == '!', <f-args>)
|
||||
command! -nargs=+ -bar Plug call s:add(<args>)
|
||||
if !executable('git')
|
||||
return s:err('`git` executable not found. vim-plug requires git.')
|
||||
endif
|
||||
command! -nargs=* -bar -bang -complete=customlist,s:names PlugInstall call s:install('<bang>' == '!', [<f-args>])
|
||||
command! -nargs=* -bar -bang -complete=customlist,s:names PlugUpdate call s:update('<bang>' == '!', [<f-args>])
|
||||
command! -nargs=0 -bar -bang PlugClean call s:clean('<bang>' == '!')
|
||||
command! -nargs=0 -bar PlugUpgrade if s:upgrade() | execute 'source '. s:me | endif
|
||||
command! -nargs=0 -bar PlugUpgrade if s:upgrade() | execute 'source' s:me | endif
|
||||
command! -nargs=0 -bar PlugStatus call s:status()
|
||||
command! -nargs=0 -bar PlugDiff call s:diff()
|
||||
endfunction
|
||||
@@ -123,13 +122,12 @@ endfunction
|
||||
function! s:source(from, ...)
|
||||
for pattern in a:000
|
||||
for vim in split(globpath(a:from, pattern), '\n')
|
||||
execute 'source '.vim
|
||||
execute 'source' vim
|
||||
endfor
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! plug#end()
|
||||
let reload = !has('vim_starting')
|
||||
if !exists('g:plugs')
|
||||
return s:err('Call plug#begin() first')
|
||||
endif
|
||||
@@ -143,17 +141,10 @@ function! plug#end()
|
||||
let lod = {}
|
||||
|
||||
filetype off
|
||||
" we want to make sure the plugin directories are added to rtp in the same
|
||||
" order that they are registered with the Plug command. since the s:add_rtp
|
||||
" function uses ^= to add plugin directories to the front of the rtp, we
|
||||
" need to loop through the plugins in reverse
|
||||
for name in reverse(copy(g:plugs_order))
|
||||
for name in g:plugs_order
|
||||
let plug = g:plugs[name]
|
||||
if get(s:loaded, plug.dir, 0) || !has_key(plug, 'on') && !has_key(plug, 'for')
|
||||
let rtp = s:add_rtp(plug)
|
||||
if reload
|
||||
call s:source(rtp, 'plugin/**/*.vim', 'after/plugin/**/*.vim')
|
||||
endif
|
||||
if get(s:loaded, name, 0) || !has_key(plug, 'on') && !has_key(plug, 'for')
|
||||
let s:loaded[name] = 1
|
||||
continue
|
||||
endif
|
||||
|
||||
@@ -193,12 +184,27 @@ function! plug#end()
|
||||
for [key, names] in items(lod)
|
||||
augroup PlugLOD
|
||||
execute printf('autocmd FileType %s call <SID>lod_ft(%s, %s)',
|
||||
\ key, string(key), string(reverse(names)))
|
||||
\ key, string(key), string(names))
|
||||
augroup END
|
||||
endfor
|
||||
|
||||
call s:reorg_rtp()
|
||||
filetype plugin indent on
|
||||
syntax on
|
||||
if has('vim_starting')
|
||||
syntax enable
|
||||
else
|
||||
call s:reload()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:loaded_names()
|
||||
return filter(copy(g:plugs_order), 'get(s:loaded, v:val, 0)')
|
||||
endfunction
|
||||
|
||||
function! s:reload()
|
||||
for name in s:loaded_names()
|
||||
call s:source(s:rtp(g:plugs[name]), 'plugin/**/*.vim', 'after/plugin/**/*.vim')
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:trim(str)
|
||||
@@ -247,27 +253,46 @@ function! s:err(msg)
|
||||
endfunction
|
||||
|
||||
function! s:esc(path)
|
||||
return substitute(a:path, ' ', '\\ ', 'g')
|
||||
return escape(a:path, ' ')
|
||||
endfunction
|
||||
|
||||
function! s:add_rtp(plug)
|
||||
let rtp = s:rtp(a:plug)
|
||||
execute 'set rtp^='.s:esc(rtp)
|
||||
let after = globpath(rtp, 'after')
|
||||
if isdirectory(after)
|
||||
execute 'set rtp+='.s:esc(after)
|
||||
endif
|
||||
let s:loaded[a:plug.dir] = 1
|
||||
return rtp
|
||||
function! s:escrtp(path)
|
||||
return escape(a:path, ' ,')
|
||||
endfunction
|
||||
|
||||
function! s:remove_rtp()
|
||||
for name in s:loaded_names()
|
||||
let rtp = s:rtp(g:plugs[name])
|
||||
execute 'set rtp-='.s:escrtp(rtp)
|
||||
let after = globpath(rtp, 'after')
|
||||
if isdirectory(after)
|
||||
execute 'set rtp-='.s:escrtp(after)
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:reorg_rtp()
|
||||
if !empty(s:first_rtp)
|
||||
execute 'set rtp-='.s:first_rtp
|
||||
execute 'set rtp^='.s:first_rtp
|
||||
endif
|
||||
if s:last_rtp !=# s:first_rtp
|
||||
execute 'set rtp-='.s:last_rtp
|
||||
endif
|
||||
|
||||
" &rtp is modified from outside
|
||||
if exists('s:prtp') && s:prtp !=# &rtp
|
||||
call s:remove_rtp()
|
||||
unlet! s:middle
|
||||
endif
|
||||
|
||||
let s:middle = get(s:, 'middle', &rtp)
|
||||
let rtps = map(s:loaded_names(), 's:rtp(g:plugs[v:val])')
|
||||
let afters = filter(map(copy(rtps), 'globpath(v:val, "after")'), 'isdirectory(v:val)')
|
||||
let &rtp = join(map(rtps, 's:escrtp(v:val)'), ',')
|
||||
\ . substitute(','.s:middle.',', '^,,$', ',', '')
|
||||
\ . join(map(afters, 's:escrtp(v:val)'), ',')
|
||||
let s:prtp = &rtp
|
||||
|
||||
if !empty(s:first_rtp)
|
||||
execute 'set rtp^='.s:first_rtp
|
||||
execute 'set rtp+='.s:last_rtp
|
||||
endif
|
||||
endfunction
|
||||
@@ -285,42 +310,43 @@ function! plug#load(...)
|
||||
return s:err(printf('Unknown plugin%s: %s', s, join(unknowns, ', ')))
|
||||
end
|
||||
for name in a:000
|
||||
call s:lod(g:plugs[name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
||||
call s:lod([name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
||||
endfor
|
||||
call s:reorg_rtp()
|
||||
silent! doautocmd BufRead
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! s:lod(plug, types)
|
||||
let rtp = s:add_rtp(a:plug)
|
||||
for dir in a:types
|
||||
call s:source(rtp, dir.'/**/*.vim')
|
||||
function! s:lod(names, types)
|
||||
for name in a:names
|
||||
let s:loaded[name] = 1
|
||||
endfor
|
||||
call s:reorg_rtp()
|
||||
|
||||
for name in a:names
|
||||
let rtp = s:rtp(g:plugs[name])
|
||||
for dir in a:types
|
||||
call s:source(rtp, dir.'/**/*.vim')
|
||||
endfor
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:lod_ft(pat, names)
|
||||
for name in a:names
|
||||
call s:lod(g:plugs[name], ['plugin', 'after/plugin'])
|
||||
endfor
|
||||
call s:reorg_rtp()
|
||||
execute 'autocmd! PlugLOD FileType ' . a:pat
|
||||
call s:lod(a:names, ['plugin', 'after/plugin'])
|
||||
execute 'autocmd! PlugLOD FileType' a:pat
|
||||
silent! doautocmd filetypeplugin FileType
|
||||
silent! doautocmd filetypeindent FileType
|
||||
endfunction
|
||||
|
||||
function! s:lod_cmd(cmd, bang, l1, l2, args, name)
|
||||
execute 'delc '.a:cmd
|
||||
call s:lod(g:plugs[a:name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
||||
call s:reorg_rtp()
|
||||
execute 'delc' a:cmd
|
||||
call s:lod([a:name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
||||
execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args)
|
||||
endfunction
|
||||
|
||||
function! s:lod_map(map, name, prefix)
|
||||
execute 'unmap '.a:map
|
||||
execute 'iunmap '.a:map
|
||||
call s:lod(g:plugs[a:name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
||||
call s:reorg_rtp()
|
||||
execute 'unmap' a:map
|
||||
execute 'iunmap' a:map
|
||||
call s:lod([a:name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
||||
let extra = ''
|
||||
while 1
|
||||
let c = getchar(0)
|
||||
@@ -344,7 +370,7 @@ function! s:add(repo, ...)
|
||||
\ a:0 == 1 ? s:parse_options(a:1) : s:base_spec)
|
||||
let g:plugs[name] = spec
|
||||
let g:plugs_order += [name]
|
||||
let s:loaded[spec.dir] = 0
|
||||
let s:loaded[name] = 0
|
||||
catch
|
||||
return s:err(v:exception)
|
||||
endtry
|
||||
@@ -380,19 +406,20 @@ function! s:infer_properties(name, repo)
|
||||
if repo !~ '/'
|
||||
let repo = 'vim-scripts/'. repo
|
||||
endif
|
||||
let uri = 'https://git:@github.com/' . repo . '.git'
|
||||
let fmt = get(g:, 'plug_url_format', 'https://git::@github.com/%s.git')
|
||||
let uri = printf(fmt, repo)
|
||||
endif
|
||||
let dir = s:dirpath( fnamemodify(join([g:plug_home, a:name], '/'), ':p') )
|
||||
return { 'dir': dir, 'uri': uri }
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:install(force, ...)
|
||||
call s:update_impl(0, a:force, a:000)
|
||||
function! s:install(force, names)
|
||||
call s:update_impl(0, a:force, a:names)
|
||||
endfunction
|
||||
|
||||
function! s:update(force, ...)
|
||||
call s:update_impl(1, a:force, a:000)
|
||||
function! s:update(force, names)
|
||||
call s:update_impl(1, a:force, a:names)
|
||||
endfunction
|
||||
|
||||
function! plug#helptags()
|
||||
@@ -402,7 +429,7 @@ function! plug#helptags()
|
||||
for spec in values(g:plugs)
|
||||
let docd = join([spec.dir, 'doc'], '/')
|
||||
if isdirectory(docd)
|
||||
silent! execute 'helptags '. s:esc(docd)
|
||||
silent! execute 'helptags' s:esc(docd)
|
||||
endif
|
||||
endfor
|
||||
return 1
|
||||
@@ -459,23 +486,29 @@ function! s:lastline(msg)
|
||||
return get(lines, -1, '')
|
||||
endfunction
|
||||
|
||||
function! s:new_window()
|
||||
execute get(g:, 'plug_window', 'vertical topleft new')
|
||||
endfunction
|
||||
|
||||
function! s:prepare()
|
||||
if bufexists(s:plug_buf)
|
||||
let winnr = bufwinnr(s:plug_buf)
|
||||
if winnr < 0
|
||||
vertical topleft new
|
||||
execute 'buffer ' . s:plug_buf
|
||||
call s:new_window()
|
||||
execute 'buffer' s:plug_buf
|
||||
else
|
||||
execute winnr . 'wincmd w'
|
||||
endif
|
||||
setlocal modifiable
|
||||
silent %d _
|
||||
else
|
||||
vertical topleft new
|
||||
nnoremap <silent> <buffer> q :if b:plug_preview==1<bar>pc<bar>endif<bar>q<cr>
|
||||
call s:new_window()
|
||||
nnoremap <silent> <buffer> q :if b:plug_preview==1<bar>pc<bar>endif<bar>echo<bar>q<cr>
|
||||
nnoremap <silent> <buffer> R :silent! call <SID>retry()<cr>
|
||||
nnoremap <silent> <buffer> D :PlugDiff<cr>
|
||||
nnoremap <silent> <buffer> S :PlugStatus<cr>
|
||||
nnoremap <silent> <buffer> U :call <SID>status_update()<cr>
|
||||
xnoremap <silent> <buffer> U :call <SID>status_update()<cr>
|
||||
nnoremap <silent> <buffer> ]] :silent! call <SID>section('')<cr>
|
||||
nnoremap <silent> <buffer> [[ :silent! call <SID>section('b')<cr>
|
||||
let b:plug_preview = -1
|
||||
@@ -499,7 +532,7 @@ function! s:assign_name()
|
||||
let name = printf('%s (%s)', prefix, idx)
|
||||
let idx = idx + 1
|
||||
endwhile
|
||||
silent! execute 'f '.fnameescape(name)
|
||||
silent! execute 'f' fnameescape(name)
|
||||
endfunction
|
||||
|
||||
function! s:do(pull, force, todo)
|
||||
@@ -507,7 +540,7 @@ function! s:do(pull, force, todo)
|
||||
if !isdirectory(spec.dir)
|
||||
continue
|
||||
endif
|
||||
execute 'cd '.s:esc(spec.dir)
|
||||
execute 'cd' s:esc(spec.dir)
|
||||
let installed = has_key(s:prev_update.new, name)
|
||||
let updated = installed ? 0 :
|
||||
\ (a:pull && !empty(s:system_chomp('git log --pretty=format:"%h" "HEAD...HEAD@{1}"')))
|
||||
@@ -554,7 +587,8 @@ function! s:finish(pull)
|
||||
if !empty(s:prev_update.errors)
|
||||
call add(msgs, "Press 'R' to retry.")
|
||||
endif
|
||||
if a:pull
|
||||
if a:pull && !empty(filter(getline(5, '$'),
|
||||
\ "v:val =~ '^- ' && stridx(v:val, 'Already up-to-date') < 0"))
|
||||
call add(msgs, "Press 'D' to see the updated changes.")
|
||||
endif
|
||||
echo join(msgs, ' ')
|
||||
@@ -619,9 +653,9 @@ function! s:update_impl(pull, force, args) abort
|
||||
catch
|
||||
let lines = getline(4, '$')
|
||||
let printed = {}
|
||||
silent 4,$d
|
||||
silent 4,$d _
|
||||
for line in lines
|
||||
let name = get(matchlist(line, '^. \([^:]\+\):'), 1, '')
|
||||
let name = matchstr(line, '^. \zs[^:]\+\ze:')
|
||||
if empty(name) || !has_key(printed, name)
|
||||
call append('$', line)
|
||||
if !empty(name)
|
||||
@@ -661,12 +695,12 @@ function! s:update_serial(pull, todo)
|
||||
for [name, spec] in items(todo)
|
||||
let done[name] = 1
|
||||
if isdirectory(spec.dir)
|
||||
execute 'cd '.s:esc(spec.dir)
|
||||
execute 'cd' s:esc(spec.dir)
|
||||
let [valid, msg] = s:git_valid(spec, 0, 0)
|
||||
if valid
|
||||
let result = a:pull ?
|
||||
\ s:system(
|
||||
\ printf('git checkout -q %s 2>&1 && git pull origin %s 2>&1 && git submodule update --init --recursive 2>&1',
|
||||
\ printf('git checkout -q %s 2>&1 && git pull --no-rebase origin %s 2>&1 && git submodule update --init --recursive 2>&1',
|
||||
\ s:shellesc(spec.branch), s:shellesc(spec.branch))) : 'Already installed'
|
||||
let error = a:pull ? v:shell_error != 0 : 0
|
||||
else
|
||||
@@ -718,7 +752,7 @@ function! s:update_parallel(pull, todo, threads)
|
||||
|
||||
def killall pid
|
||||
pids = [pid]
|
||||
unless `which pgrep`.empty?
|
||||
unless `which pgrep 2> /dev/null`.empty?
|
||||
children = pids
|
||||
until children.empty?
|
||||
children = children.map { |pid|
|
||||
@@ -784,7 +818,7 @@ function! s:update_parallel(pull, todo, threads)
|
||||
logh.call
|
||||
end
|
||||
}
|
||||
bt = proc { |cmd, name, type|
|
||||
bt = proc { |cmd, name, type, cleanup|
|
||||
tried = timeout = 0
|
||||
begin
|
||||
tried += 1
|
||||
@@ -815,6 +849,7 @@ function! s:update_parallel(pull, todo, threads)
|
||||
killall fd.pid
|
||||
fd.close
|
||||
end
|
||||
cleanup.call if cleanup
|
||||
if e.is_a?(Timeout::Error) && tried < tries
|
||||
3.downto(1) do |countdown|
|
||||
s = countdown > 1 ? 's' : ''
|
||||
@@ -863,7 +898,7 @@ function! s:update_parallel(pull, todo, threads)
|
||||
ok, result =
|
||||
if exists
|
||||
dir = esc dir
|
||||
ret, data = bt.call "#{cd} #{dir} && git rev-parse --abbrev-ref HEAD 2>&1 && git config remote.origin.url", nil, nil
|
||||
ret, data = bt.call "#{cd} #{dir} && git rev-parse --abbrev-ref HEAD 2>&1 && git config remote.origin.url", nil, nil, nil
|
||||
current_uri = data.lines.to_a.last
|
||||
if !ret
|
||||
if data =~ /^Interrupted|^Timeout/
|
||||
@@ -871,14 +906,14 @@ function! s:update_parallel(pull, todo, threads)
|
||||
else
|
||||
[false, [data.chomp, "PlugClean required."].join($/)]
|
||||
end
|
||||
elsif current_uri.sub(/git:@/, '') != uri.sub(/git:@/, '')
|
||||
elsif current_uri.sub(/git::?@/, '') != uri.sub(/git::?@/, '')
|
||||
[false, ["Invalid URI: #{current_uri}",
|
||||
"Expected: #{uri}",
|
||||
"PlugClean required."].join($/)]
|
||||
else
|
||||
if pull
|
||||
log.call name, 'Updating ...', :update
|
||||
bt.call "#{cd} #{dir} && git checkout -q #{branch} 2>&1 && (git pull origin #{branch} #{progress} 2>&1 && #{subm})", name, :update
|
||||
bt.call "#{cd} #{dir} && git checkout -q #{branch} 2>&1 && (git pull --no-rebase origin #{branch} #{progress} 2>&1 && #{subm})", name, :update, nil
|
||||
else
|
||||
[true, skip]
|
||||
end
|
||||
@@ -886,7 +921,9 @@ function! s:update_parallel(pull, todo, threads)
|
||||
else
|
||||
d = esc dir.sub(%r{[\\/]+$}, '')
|
||||
log.call name, 'Installing ...', :install
|
||||
bt.call "(git clone #{progress} --recursive #{uri} -b #{branch} #{d} 2>&1 && cd #{esc dir} && #{subm})", name, :install
|
||||
bt.call "(git clone #{progress} --recursive #{uri} -b #{branch} #{d} 2>&1 && cd #{esc dir} && #{subm})", name, :install, proc {
|
||||
FileUtils.rm_rf dir
|
||||
}
|
||||
end
|
||||
mtx.synchronize { VIM::command("let s:prev_update.new['#{name}'] = 1") } if !exists && ok
|
||||
log.call name, result, ok
|
||||
@@ -914,8 +951,8 @@ function! s:progress_bar(line, bar, total)
|
||||
endfunction
|
||||
|
||||
function! s:compare_git_uri(a, b)
|
||||
let a = substitute(a:a, 'git:@', '', '')
|
||||
let b = substitute(a:b, 'git:@', '', '')
|
||||
let a = substitute(a:a, 'git:\{1,2}@', '', '')
|
||||
let b = substitute(a:b, 'git:\{1,2}@', '', '')
|
||||
return a ==# b
|
||||
endfunction
|
||||
|
||||
@@ -941,7 +978,7 @@ function! s:git_valid(spec, check_branch, cd)
|
||||
let ret = 1
|
||||
let msg = 'OK'
|
||||
if isdirectory(a:spec.dir)
|
||||
if a:cd | execute 'cd ' . s:esc(a:spec.dir) | endif
|
||||
if a:cd | execute 'cd' s:esc(a:spec.dir) | endif
|
||||
let result = split(s:system('git rev-parse --abbrev-ref HEAD 2>&1 && git config remote.origin.url'), '\n')
|
||||
let remote = result[-1]
|
||||
if v:shell_error
|
||||
@@ -1032,44 +1069,40 @@ function! s:clean(force)
|
||||
endfunction
|
||||
|
||||
function! s:upgrade()
|
||||
if executable('curl')
|
||||
let mee = s:shellesc(s:me)
|
||||
let new = s:shellesc(s:me . '.new')
|
||||
echo 'Downloading '. s:plug_source
|
||||
redraw
|
||||
let mv = s:is_win ? 'move /Y' : 'mv -f'
|
||||
let cp = s:is_win ? 'copy /Y' : 'cp -f'
|
||||
call system(printf(
|
||||
\ 'curl -fLo %s %s && '.cp.' %s %s.old && '.mv.' %s %s',
|
||||
\ new, s:plug_source, mee, mee, new, mee))
|
||||
if v:shell_error
|
||||
return s:err('Error upgrading vim-plug')
|
||||
endif
|
||||
elseif has('ruby')
|
||||
echo 'Downloading '. s:plug_source
|
||||
try
|
||||
let new = s:me . '.new'
|
||||
echo 'Downloading '. s:plug_source
|
||||
redraw
|
||||
try
|
||||
if executable('curl')
|
||||
let output = system(printf('curl -fLo %s %s', s:shellesc(new), s:plug_source))
|
||||
if v:shell_error
|
||||
throw get(split(output, '\n'), -1, v:shell_error)
|
||||
endif
|
||||
elseif has('ruby')
|
||||
ruby << EOF
|
||||
require 'open-uri'
|
||||
require 'fileutils'
|
||||
me = VIM::evaluate('s:me')
|
||||
old = me + '.old'
|
||||
new = me + '.new'
|
||||
File.open(new, 'w') do |f|
|
||||
File.open(VIM::evaluate('new'), 'w') do |f|
|
||||
f << open(VIM::evaluate('s:plug_source')).read
|
||||
end
|
||||
FileUtils.cp me, old
|
||||
File.rename new, me
|
||||
EOF
|
||||
catch
|
||||
return s:err('Error upgrading vim-plug')
|
||||
endtry
|
||||
else
|
||||
return s:err('curl executable or ruby support not found')
|
||||
endif
|
||||
else
|
||||
return s:err('curl executable or ruby support not found')
|
||||
endif
|
||||
catch
|
||||
return s:err('Error upgrading vim-plug: '. v:exception)
|
||||
endtry
|
||||
|
||||
unlet g:loaded_plug
|
||||
echo 'Downloaded '. s:plug_source
|
||||
return 1
|
||||
if readfile(s:me) ==# readfile(new)
|
||||
echo 'vim-plug is 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 is upgraded'
|
||||
return 1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:upgrade_specs()
|
||||
@@ -1103,7 +1136,7 @@ function! s:status()
|
||||
let cnt += 1
|
||||
let ecnt += !valid
|
||||
" `s:loaded` entry can be missing if PlugUpgraded
|
||||
if valid && get(s:loaded, spec.dir, -1) == 0
|
||||
if valid && get(s:loaded, name, -1) == 0
|
||||
let unloaded = 1
|
||||
let msg .= ' (not loaded)'
|
||||
endif
|
||||
@@ -1116,17 +1149,20 @@ function! s:status()
|
||||
normal! gg
|
||||
setlocal nomodifiable
|
||||
if unloaded
|
||||
echo "Press 'L' on each line to load plugin"
|
||||
echo "Press 'L' on each line to load plugin, or 'U' to update"
|
||||
nnoremap <silent> <buffer> L :call <SID>status_load(line('.'))<cr>
|
||||
xnoremap <silent> <buffer> L :call <SID>status_load(line('.'))<cr>
|
||||
end
|
||||
endfunction
|
||||
|
||||
function! s:extract_name(str, prefix, suffix)
|
||||
return matchstr(a:str, '^'.a:prefix.' \zs[^:]\+\ze:.*'.a:suffix.'$')
|
||||
endfunction
|
||||
|
||||
function! s:status_load(lnum)
|
||||
let line = getline(a:lnum)
|
||||
let matches = matchlist(line, '^- \([^:]*\):.*(not loaded)$')
|
||||
if !empty(matches)
|
||||
let name = matches[1]
|
||||
let name = s:extract_name(line, '-', '(not loaded)')
|
||||
if !empty(name)
|
||||
call plug#load(name)
|
||||
setlocal modifiable
|
||||
call setline(a:lnum, substitute(line, ' (not loaded)$', '', ''))
|
||||
@@ -1134,6 +1170,15 @@ function! s:status_load(lnum)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:status_update() range
|
||||
let lines = getline(a:firstline, a:lastline)
|
||||
let names = filter(map(lines, 's:extract_name(v:val, "[x-]", "")'), '!empty(v:val)')
|
||||
if !empty(names)
|
||||
echo
|
||||
execute 'PlugUpdate' join(names)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:is_preview_window_open()
|
||||
silent! wincmd P
|
||||
if &previewwindow
|
||||
@@ -1172,14 +1217,14 @@ function! s:preview_commit()
|
||||
return
|
||||
endif
|
||||
|
||||
execute 'cd '.s:esc(g:plugs[name].dir)
|
||||
execute 'pedit '.sha
|
||||
execute 'pedit' sha
|
||||
wincmd P
|
||||
setlocal filetype=git buftype=nofile nobuflisted
|
||||
execute 'silent read !git show '.sha
|
||||
normal! ggdd
|
||||
wincmd p
|
||||
execute 'cd' s:esc(g:plugs[name].dir)
|
||||
execute 'silent read !git show' sha
|
||||
cd -
|
||||
normal! gg"_dd
|
||||
wincmd p
|
||||
endfunction
|
||||
|
||||
function! s:section(flags)
|
||||
@@ -1198,7 +1243,7 @@ function! s:diff()
|
||||
continue
|
||||
endif
|
||||
|
||||
execute 'cd '.s:esc(v.dir)
|
||||
execute 'cd' s:esc(v.dir)
|
||||
let diff = system('git log --pretty=format:"%h %s (%cr)" "HEAD...HEAD@{1}"')
|
||||
if !v:shell_error && !empty(diff)
|
||||
call append(1, '')
|
||||
@@ -1228,17 +1273,21 @@ function! s:revert()
|
||||
return
|
||||
endif
|
||||
|
||||
execute 'cd '.s:esc(g:plugs[name].dir)
|
||||
execute 'cd' s:esc(g:plugs[name].dir)
|
||||
call system('git reset --hard HEAD@{1} && git checkout '.s:esc(g:plugs[name].branch))
|
||||
cd -
|
||||
setlocal modifiable
|
||||
normal! dap
|
||||
normal! "_dap
|
||||
setlocal nomodifiable
|
||||
echo 'Reverted.'
|
||||
endfunction
|
||||
|
||||
let s:first_rtp = s:esc(get(split(&rtp, ','), 0, ''))
|
||||
let s:last_rtp = s:esc(get(split(&rtp, ','), -1, ''))
|
||||
function! s:split_rtp()
|
||||
return split(&rtp, '\\\@<!,')
|
||||
endfunction
|
||||
|
||||
let s:first_rtp = s:escrtp(get(s:split_rtp(), 0, ''))
|
||||
let s:last_rtp = s:escrtp(get(s:split_rtp(), -1, ''))
|
||||
|
||||
if exists('g:plugs')
|
||||
let g:plugs_order = get(g:, 'plugs_order', keys(g:plugs))
|
||||
|
||||
10
test/run
10
test/run
@@ -19,10 +19,14 @@ make_dirs() {
|
||||
cd "$1"
|
||||
mkdir -p autoload colors ftdetect ftplugin indent plugin syntax
|
||||
for d in *; do
|
||||
[ -d $d ] || continue
|
||||
cat > $d/xxx.vim << EOF
|
||||
" echom expand('<sfile>')
|
||||
let g:total_order = get(g:, 'total_order', [])
|
||||
let g:$2 = get(g:, '$2', [])
|
||||
call add(g:$2, '${1:4}/$d')
|
||||
let s:name = join(filter(['$2', '${1:4}', '$d'], '!empty(v:val)'), '/')
|
||||
call add(g:$2, s:name)
|
||||
call add(g:total_order, s:name)
|
||||
EOF
|
||||
done
|
||||
cd - > /dev/null
|
||||
@@ -30,12 +34,14 @@ EOF
|
||||
|
||||
make_dirs xxx/ xxx
|
||||
make_dirs xxx/after xxx
|
||||
mkdir xxx/doc
|
||||
mkdir -p xxx/doc
|
||||
cat > xxx/doc/xxx.txt << DOC
|
||||
hello *xxx*
|
||||
DOC
|
||||
|
||||
make_dirs yyy/ yyy
|
||||
make_dirs yyy/after yyy
|
||||
|
||||
make_dirs z1/ z1
|
||||
make_dirs z2/ z2
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Execute (Initialize test environment):
|
||||
Save &rtp, g:plugs, g:plug_home
|
||||
Save &rtp, g:plugs, g:plug_home, g:plug_window
|
||||
|
||||
let first_rtp = split(&rtp, ',')[0]
|
||||
let last_rtp = split(&rtp, ',')[-1]
|
||||
@@ -11,8 +11,7 @@ Execute (Initialize test environment):
|
||||
execute 'set rtp^='.plug
|
||||
let basertp = &rtp
|
||||
|
||||
unlet! g:plugs
|
||||
unlet! g:plug_home
|
||||
unlet! g:plugs g:plug_home g:plug_window
|
||||
|
||||
set t_Co=256
|
||||
colo default
|
||||
@@ -28,11 +27,17 @@ Execute (Initialize test environment):
|
||||
endfunction
|
||||
|
||||
function! AssertExpect(bang, pat, cnt)
|
||||
let op = a:bang ? '==' : '=~'
|
||||
let op = a:bang ? '==#' : '=~#'
|
||||
AssertEqual a:cnt, len(filter(getline(1, '$'), "v:val ".op." '".a:pat."'"))
|
||||
endfunction
|
||||
command! -nargs=+ -bang AssertExpect call AssertExpect('<bang>' == '!', <args>)
|
||||
|
||||
function! EnsureLoaded()
|
||||
if has('vim_starting')
|
||||
runtime! plugin/**/*.vim
|
||||
endif
|
||||
endfunction
|
||||
|
||||
Execute (Print Ruby version):
|
||||
redir => out
|
||||
silent ruby puts RUBY_VERSION
|
||||
@@ -75,7 +80,7 @@ Execute (Subsequent plug#begin() calls will reuse g:plug_home):
|
||||
Execute (Test Plug command):
|
||||
" Git repo with branch
|
||||
Plug 'junegunn/seoul256.vim', 'yes-t_co'
|
||||
AssertEqual 'https://git:@github.com/junegunn/seoul256.vim.git', g:plugs['seoul256.vim'].uri
|
||||
AssertEqual 'https://git::@github.com/junegunn/seoul256.vim.git', g:plugs['seoul256.vim'].uri
|
||||
AssertEqual join([temp_plugged, 'seoul256.vim/'], '/'), g:plugs['seoul256.vim'].dir
|
||||
AssertEqual 'yes-t_co', g:plugs['seoul256.vim'].branch
|
||||
|
||||
@@ -84,7 +89,7 @@ Execute (Test Plug command):
|
||||
|
||||
" Git repo with tag
|
||||
Plug 'junegunn/goyo.vim', '1.5.2'
|
||||
AssertEqual 'https://git:@github.com/junegunn/goyo.vim.git', g:plugs['goyo.vim'].uri
|
||||
AssertEqual 'https://git::@github.com/junegunn/goyo.vim.git', g:plugs['goyo.vim'].uri
|
||||
AssertEqual join([temp_plugged, 'goyo.vim/'], '/'), g:plugs['goyo.vim'].dir
|
||||
AssertEqual '1.5.2', g:plugs['goyo.vim'].branch
|
||||
|
||||
@@ -99,7 +104,7 @@ Execute (Test Plug command):
|
||||
|
||||
" vim-scripts/
|
||||
Plug 'beauty256'
|
||||
AssertEqual 'https://git:@github.com/vim-scripts/beauty256.git', g:plugs.beauty256.uri
|
||||
AssertEqual 'https://git::@github.com/vim-scripts/beauty256.git', g:plugs.beauty256.uri
|
||||
AssertEqual 'master', g:plugs.beauty256.branch
|
||||
|
||||
AssertEqual 4, len(g:plugs)
|
||||
@@ -199,8 +204,8 @@ Execute (PlugStatus):
|
||||
call PlugStatusSorted()
|
||||
|
||||
Expect:
|
||||
Expected: https://git:@github.com/junegunn.choi/seoul256.vim.git
|
||||
Invalid URI: https://git:@github.com/junegunn/seoul256.vim.git
|
||||
Expected: https://git::@github.com/junegunn.choi/seoul256.vim.git
|
||||
Invalid URI: https://git::@github.com/junegunn/seoul256.vim.git
|
||||
PlugClean required.
|
||||
- vim-emoji: OK
|
||||
Finished. 1 error(s).
|
||||
@@ -233,7 +238,7 @@ Execute (PlugStatus):
|
||||
call PlugStatusSorted()
|
||||
|
||||
Expect:
|
||||
Expected: https://git:@github.com/junegunn/vim-emoji.git
|
||||
Expected: https://git::@github.com/junegunn/vim-emoji.git
|
||||
Invalid URI: https://bitbucket.org/junegunn/vim-emoji.git
|
||||
Not found. Try PlugInstall.
|
||||
PlugClean required.
|
||||
@@ -389,10 +394,7 @@ Given (Unaligned code):
|
||||
aa=2
|
||||
|
||||
Execute (Check installed plugins):
|
||||
if has('vim_starting')
|
||||
Log 'Vader is run from commandline'
|
||||
runtime! plugin/**/*.vim
|
||||
endif
|
||||
call EnsureLoaded()
|
||||
Assert exists(':FNR'), 'FNR command should be found'
|
||||
Assert !exists(':RedisExecute'), 'RedisExecute command still should not be found'
|
||||
|
||||
@@ -741,9 +743,9 @@ Execute (Immediate loading):
|
||||
" Different result when Vader is run from commandline with `-c` option
|
||||
Log g:xxx
|
||||
if has('vim_starting')
|
||||
AssertEqual ['/ftdetect', 'after/ftdetect'], g:xxx
|
||||
AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect'], g:xxx
|
||||
else
|
||||
AssertEqual ['/plugin', 'after/plugin', '/ftdetect', 'after/ftdetect'], g:xxx
|
||||
AssertEqual ['xxx/plugin', 'xxx/after/plugin', 'xxx/ftdetect', 'xxx/after/ftdetect'], g:xxx
|
||||
endif
|
||||
|
||||
Execute (Command-based on-demand loading):
|
||||
@@ -754,20 +756,20 @@ Execute (Command-based on-demand loading):
|
||||
AssertEqual [], g:xxx
|
||||
|
||||
silent! XXX
|
||||
AssertEqual ['/ftdetect', 'after/ftdetect', '/plugin', 'after/plugin'], g:xxx
|
||||
AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect', 'xxx/plugin', 'xxx/after/plugin'], g:xxx
|
||||
|
||||
setf xxx
|
||||
AssertEqual ['/ftdetect', 'after/ftdetect', '/plugin', 'after/plugin', '/ftplugin', 'after/ftplugin', '/indent', 'after/indent', '/syntax', '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):
|
||||
call plug#begin()
|
||||
Plug '$PWD/xxx', { 'for': 'xxx' }
|
||||
call plug#end()
|
||||
|
||||
AssertEqual ['/ftdetect', 'after/ftdetect'], g:xxx
|
||||
AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect'], g:xxx
|
||||
|
||||
setf xxx
|
||||
AssertEqual ['/ftdetect', 'after/ftdetect', '/plugin', 'after/plugin', '/ftplugin', 'after/ftplugin', '/indent', 'after/indent', '/syntax', '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
|
||||
|
||||
Before:
|
||||
|
||||
@@ -848,15 +850,171 @@ Execute (Load plugin from PlugStatus screen with L key in visual mode):
|
||||
Assert exists('g:z2'), 'z2 loaded'
|
||||
q
|
||||
|
||||
**********************************************************************
|
||||
~ g:plug_window
|
||||
**********************************************************************
|
||||
Execute (Open plug window in a new tab):
|
||||
" Without g:plug_window, plug window is open on the left split
|
||||
let tabnr = tabpagenr()
|
||||
PlugStatus
|
||||
AssertEqual tabnr, tabpagenr()
|
||||
AssertEqual 1, winnr()
|
||||
|
||||
" PlugStatus again inside the window should not change the view
|
||||
normal S
|
||||
AssertEqual tabnr, tabpagenr()
|
||||
AssertEqual 1, winnr()
|
||||
q
|
||||
|
||||
" Define g:plug_window so that plug window is open in a new tab
|
||||
let g:plug_window = 'tabnew'
|
||||
PlugStatus
|
||||
AssertNotEqual tabnr, tabpagenr()
|
||||
|
||||
" PlugStatus again inside the window should not change the view
|
||||
let tabnr = tabpagenr()
|
||||
normal S
|
||||
AssertEqual tabnr, tabpagenr()
|
||||
q
|
||||
unlet g:plug_window
|
||||
|
||||
**********************************************************************
|
||||
~ g:plug_url_format
|
||||
**********************************************************************
|
||||
Execute (Using g:plug_url_format):
|
||||
call plug#begin()
|
||||
let g:plug_url_format = 'git@bitbucket.org:%s.git'
|
||||
Plug 'junegunn/seoul256.vim'
|
||||
let g:plug_url_format = 'git@bitsocket.org:%s.git'
|
||||
Plug 'beauty256'
|
||||
AssertEqual 'git@bitbucket.org:junegunn/seoul256.vim.git', g:plugs['seoul256.vim'].uri
|
||||
AssertEqual 'git@bitsocket.org:vim-scripts/beauty256.git', g:plugs['beauty256'].uri
|
||||
unlet g:plug_url_format
|
||||
|
||||
**********************************************************************
|
||||
~ U
|
||||
**********************************************************************
|
||||
Execute (Plug block):
|
||||
call plug#begin()
|
||||
Plug 'junegunn/vim-easy-align'
|
||||
Plug 'junegunn/vim-emoji'
|
||||
call plug#end()
|
||||
|
||||
Execute (Update plugin with U key in normal mode):
|
||||
PlugStatus
|
||||
/emoji
|
||||
normal U
|
||||
Log getline(1, '$')
|
||||
AssertExpect 'Updated', 1
|
||||
AssertExpect 'vim-emoji', 1
|
||||
AssertExpect 'vim-easy-align', 0
|
||||
AssertExpect! '[=]', 1
|
||||
|
||||
" From PlugInstall screen
|
||||
PlugInstall
|
||||
/easy-align
|
||||
normal U
|
||||
AssertExpect 'Updated', 1
|
||||
AssertExpect 'vim-emoji', 0
|
||||
AssertExpect 'vim-easy-align', 1
|
||||
AssertExpect! '[=]', 1
|
||||
q
|
||||
|
||||
Execute (Update plugins with U key in visual mode):
|
||||
silent! call system('rm -rf '.g:plugs['vim-easy-align'].dir)
|
||||
|
||||
PlugStatus
|
||||
normal VGU
|
||||
Log getline(1, '$')
|
||||
AssertExpect 'Updated', 1
|
||||
AssertExpect 'vim-emoji', 1
|
||||
AssertExpect 'vim-easy-align', 1
|
||||
AssertExpect! '[==]', 1
|
||||
|
||||
" From PlugUpdate screen
|
||||
normal VGU
|
||||
Log getline(1, '$')
|
||||
AssertExpect 'Updated', 1
|
||||
AssertExpect 'vim-emoji', 1
|
||||
AssertExpect 'vim-easy-align', 1
|
||||
AssertExpect! '[==]', 1
|
||||
q
|
||||
|
||||
**********************************************************************
|
||||
Execute (plug#begin should expand env vars):
|
||||
AssertNotEqual '$HOME/.emacs/plugged', expand('$HOME/.emacs/plugged')
|
||||
call plug#begin('$HOME/.emacs/plugged')
|
||||
AssertEqual expand('$HOME/.emacs/plugged'), g:plug_home
|
||||
|
||||
**********************************************************************
|
||||
Execute (Plug directory with comma):
|
||||
call plug#begin(temp_plugged . '/p,l,u,g,g,e,d')
|
||||
Plug 'junegunn/vim-emoji'
|
||||
call plug#end()
|
||||
Log &rtp
|
||||
|
||||
PlugInstall
|
||||
q
|
||||
let found = filter(split(globpath(&rtp, 'README.md'), '\n'), 'v:val =~ ","')
|
||||
Log found
|
||||
AssertEqual 1, len(found)
|
||||
|
||||
**********************************************************************
|
||||
Execute (Strict load order):
|
||||
let g:total_order = []
|
||||
call plug#begin()
|
||||
Plug '$PWD/xxx'
|
||||
Plug '$PWD/yyy', { 'for': ['xxx'] }
|
||||
call plug#end()
|
||||
call EnsureLoaded()
|
||||
setf xxx
|
||||
Log 'Case 1: ' . &rtp
|
||||
AssertEqual ['yyy/ftdetect', 'yyy/after/ftdetect', 'xxx/ftdetect', 'xxx/after/ftdetect'], g:total_order[0:3]
|
||||
Assert index(g:total_order, 'xxx/plugin') < index(g:total_order, 'yyy/plugin')
|
||||
Assert index(g:total_order, 'xxx/after/plugin') < index(g:total_order, 'yyy/after/plugin')
|
||||
let len = len(split(&rtp, ','))
|
||||
|
||||
let g:total_order = []
|
||||
call plug#begin()
|
||||
Plug '$PWD/xxx', { 'for': ['xxx'] }
|
||||
Plug '$PWD/yyy'
|
||||
call plug#end()
|
||||
call EnsureLoaded()
|
||||
set rtp^=manually-prepended
|
||||
set rtp+=manually-appended
|
||||
setf xxx
|
||||
Log 'Case 2: ' . &rtp
|
||||
AssertEqual 'manually-prepended', split(&rtp, ',')[3]
|
||||
AssertEqual 'manually-appended', split(&rtp, ',')[-4]
|
||||
AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect', 'yyy/ftdetect', 'yyy/after/ftdetect'], g:total_order[0:3]
|
||||
Assert index(g:total_order, 'yyy/plugin') < index(g:total_order, 'xxx/plugin')
|
||||
Assert index(g:total_order, 'yyy/after/plugin') < index(g:total_order, 'xxx/after/plugin')
|
||||
AssertEqual len + 2, len(split(&rtp, ','))
|
||||
|
||||
let g:total_order = []
|
||||
call plug#begin()
|
||||
Plug '$PWD/xxx', { 'for': ['xxx'] }
|
||||
Plug '$PWD/yyy', { 'for': ['xxx'] }
|
||||
call plug#end()
|
||||
call EnsureLoaded()
|
||||
setf xxx
|
||||
Log 'Case 3: ' . &rtp
|
||||
AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect', 'yyy/ftdetect', 'yyy/after/ftdetect'], g:total_order[0:3]
|
||||
Assert index(g:total_order, 'xxx/plugin') < index(g:total_order, 'yyy/plugin')
|
||||
Assert index(g:total_order, 'xxx/after/plugin') < index(g:total_order, 'yyy/after/plugin')
|
||||
AssertEqual len + 2, len(split(&rtp, ','))
|
||||
|
||||
Execute (Cleanup):
|
||||
silent! call system('rm -rf '.temp_plugged)
|
||||
silent! call rename('fzf', 'fzf-staged')
|
||||
silent! unlet g:plugs
|
||||
silent! unlet g:plug_home
|
||||
silent! unlet temp_plugged vader plug basertp save_rtp repo lnum fzf out
|
||||
silent! 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 AssertExpect
|
||||
silent! delf PlugUpdated
|
||||
silent! delf EnsureLoaded
|
||||
silent! delc AssertExpect
|
||||
silent! unmap /
|
||||
silent! unmap ?
|
||||
|
||||
Reference in New Issue
Block a user