19 Commits
0.9.0 ... 0.9.1

Author SHA1 Message Date
Junegunn Choi
b44ea685aa Merge pull request #508 from mhinz/silence-deletions
Silence :delete commands
2016-08-01 09:52:29 +09:00
Marco Hinz
9df0580eff Silence :delete commands
Add :silence to all :delete commands to avoid filling up the message history
with "1 line less" messages, in case 'report' is set to 0.
2016-07-31 22:50:50 +02:00
Junegunn Choi
e15598fe45 Add g:plug_pwindow for customizing preview window layout
Close #504
2016-07-23 18:36:30 +09:00
Junegunn Choi
326cb71a2a No period in echo message 2016-07-23 18:07:12 +09:00
Junegunn Choi
c9a7ca1e9e Define d operator for selectively removing invalid directories
Fix #503
2016-07-23 18:02:00 +09:00
Junegunn Choi
5695fb8474 Do not proceed if $GIT_DIR or $GIT_WORK_TREE is found
Close #506
2016-07-23 10:13:25 +09:00
Junegunn Choi
f68a4fddae Update example: youcompleteme#Enable is no longer needed
Close #501
2016-07-15 12:18:21 +09:00
Junegunn Choi
17996cedce Support { 'do': ':VimCommand' } notation
Close #450
2016-07-13 23:01:41 +09:00
Junegunn Choi
460fbe82e0 Ignore inconsistencies between g:plugs and g:plugs_order
https://github.com/junegunn/vim-plug/issues/469#issuecomment-226965736
2016-06-19 11:18:20 +09:00
Junegunn Choi
05a1620bb1 Put cursor inside the installer window after post-update hook
https://github.com/chrisbra/unicode.vim/issues/16
2016-06-16 22:17:21 +09:00
Junegunn Choi
cb5bed0e35 Always set register in map-based ODL 2016-05-31 15:27:27 +09:00
Junegunn Choi
44893a1901 Fix #491 - Lazy-loading with omaps 2016-05-31 12:44:48 +09:00
Junegunn Choi
765a2d21d3 Do not trigger BufRead if not necessary
Close #490
2016-05-23 22:22:43 +09:00
Junegunn Choi
eb25f320a0 Fix travis CI build 2016-05-23 13:15:57 +09:00
Junegunn Choi
7c7ef8cf2f Trigger BufRead when a plugin is loaded by on condition
Close #489
2016-05-23 13:11:06 +09:00
Junegunn Choi
a8b09617f9 Clarify that function call requires call
Close #487
2016-05-23 01:12:09 +09:00
Junegunn Choi
bf1e0fb8eb Do not use Ruby older than 1.8.7
Close #482
2016-05-13 02:06:00 +09:00
Junegunn Choi
656ccef8dc Switch &shell during submodule update
Fix #481
2016-04-29 13:39:17 +09:00
Junegunn Choi
41de3c713c Export Plug command as plug# function
https://github.com/junegunn/vim-plug/issues/477#issuecomment-212746298

One can directly use it to redefine Plug command:

    function! s:plug_with_default(...)
      call plug#(a:1, extend(get(g:, 'plug_opts', {}), get(a:000, 1, {})))
    endfunction
    command! -nargs=+ Plug call s:plug_with_default(<args>)
2016-04-22 02:50:04 +09:00
6 changed files with 284 additions and 125 deletions

View File

@@ -62,9 +62,9 @@ $uri = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
Add a vim-plug section to your `~/.vimrc` (or `~/.config/nvim/init.vim` for Neovim): Add a vim-plug section to your `~/.vimrc` (or `~/.config/nvim/init.vim` for Neovim):
1. Begin the section with `plug#begin()` 1. Begin the section with `call plug#begin()`
1. List the plugins with `Plug` commands 1. List the plugins with `Plug` commands
1. `plug#end()` to update `&runtimepath` and initialize plugin system 1. `call plug#end()` to update `&runtimepath` and initialize plugin system
#### Example #### Example
@@ -141,6 +141,7 @@ Reload .vimrc and `:PlugInstall` to install plugins.
| `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_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_pwindow` | `above 12new` | Command to open preview window in `PlugDiff` |
| `g:plug_url_format` | `https://git::@github.com/%s.git` | `printf` format to build repo URL (Only applies to the subsequent `Plug` commands) | | `g:plug_url_format` | `https://git::@github.com/%s.git` | `printf` format to build repo URL (Only applies to the subsequent `Plug` commands) |
@@ -182,9 +183,9 @@ 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 " Code to execute when the plugin is lazily loaded on demand
Plug 'Valloric/YouCompleteMe', { 'for': 'cpp' } Plug 'junegunn/goyo.vim', { 'for': 'markdown' }
autocmd! User YouCompleteMe if !has('vim_starting') | call youcompleteme#Enable() | endif autocmd! User goyo.vim echom 'Goyo is now loaded!'
``` ```
`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
@@ -201,6 +202,12 @@ Plug 'Shougo/vimproc.vim', { 'do': 'make' }
Plug 'Valloric/YouCompleteMe', { 'do': './install.py' } Plug 'Valloric/YouCompleteMe', { 'do': './install.py' }
``` ```
If the value starts with `:`, it will be recognized as a Vim command.
```vim
Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
```
If you need more control, you can pass a reference to a Vim function that If you need more control, you can pass a reference to a Vim function that
takes a single argument. takes a single argument.

178
plug.vim
View File

@@ -131,7 +131,7 @@ function! plug#begin(...)
endfunction endfunction
function! s:define_commands() function! s:define_commands()
command! -nargs=+ -bar Plug call s:Plug(<args>) command! -nargs=+ -bar Plug call plug#(<args>)
if !executable('git') if !executable('git')
return s:err('`git` executable not found. Most commands will not be available. To suppress this message, prepend `silent!` to `call plug#begin(...)`.') return s:err('`git` executable not found. Most commands will not be available. To suppress this message, prepend `silent!` to `call plug#begin(...)`.')
endif endif
@@ -171,14 +171,22 @@ function! s:assoc(dict, key, val)
let a:dict[a:key] = add(get(a:dict, a:key, []), a:val) let a:dict[a:key] = add(get(a:dict, a:key, []), a:val)
endfunction endfunction
function! s:ask(message) function! s:ask(message, ...)
call inputsave() call inputsave()
echohl WarningMsg echohl WarningMsg
let proceed = input(a:message.' (y/N) ') =~? '^y' let answer = input(a:message.(a:0 ? ' (y/N/a) ' : ' (y/N) '))
echohl None echohl None
call inputrestore() call inputrestore()
echo "\r" echo "\r"
return proceed return (a:0 && answer =~? '^a') ? 2 : (answer =~? '^y') ? 1 : 0
endfunction
function! s:ask_no_interrupt(...)
try
return call('s:ask', a:000)
catch
return 0
endtry
endfunction endfunction
function! plug#end() function! plug#end()
@@ -196,6 +204,9 @@ function! plug#end()
filetype off filetype off
for name in g:plugs_order for name in g:plugs_order
if !has_key(g:plugs, name)
continue
endif
let plug = g:plugs[name] let plug = g:plugs[name]
if get(s:loaded, name, 0) || !has_key(plug, 'on') && !has_key(plug, 'for') if get(s:loaded, name, 0) || !has_key(plug, 'on') && !has_key(plug, 'for')
let s:loaded[name] = 1 let s:loaded[name] = 1
@@ -264,7 +275,7 @@ function! plug#end()
syntax enable syntax enable
end end
else else
call s:reload() call s:reload_plugins()
endif endif
endfunction endfunction
@@ -272,9 +283,13 @@ function! s:loaded_names()
return filter(copy(g:plugs_order), 'get(s:loaded, v:val, 0)') return filter(copy(g:plugs_order), 'get(s:loaded, v:val, 0)')
endfunction endfunction
function! s:reload() function! s:load_plugin(spec)
call s:source(s:rtp(a:spec), 'plugin/**/*.vim', 'after/plugin/**/*.vim')
endfunction
function! s:reload_plugins()
for name in s:loaded_names() for name in s:loaded_names()
call s:source(s:rtp(g:plugs[name]), 'plugin/**/*.vim', 'after/plugin/**/*.vim') call s:load_plugin(g:plugs[name])
endfor endfor
endfunction endfunction
@@ -397,7 +412,20 @@ function! s:reorg_rtp()
endfunction endfunction
function! s:doautocmd(...) function! s:doautocmd(...)
if exists('#'.join(a:000, '#'))
execute 'doautocmd' ((v:version > 703 || has('patch442')) ? '<nomodeline>' : '') join(a:000) execute 'doautocmd' ((v:version > 703 || has('patch442')) ? '<nomodeline>' : '') join(a:000)
endif
endfunction
function! s:dobufread(names)
for name in a:names
let path = s:rtp(g:plugs[name]).'/**'
for dir in ['ftdetect', 'ftplugin']
if len(finddir(dir, path))
return s:doautocmd('BufRead')
endif
endfor
endfor
endfunction endfunction
function! plug#load(...) function! plug#load(...)
@@ -415,9 +443,7 @@ 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') call s:dobufread(a:000)
doautocmd BufRead
endif
return 1 return 1
endfunction endfunction
@@ -453,9 +479,7 @@ function! s:lod(names, types, ...)
endif endif
call s:source(rtp, a:2) call s:source(rtp, a:2)
endif endif
if exists('#User#'.name)
call s:doautocmd('User', name) call s:doautocmd('User', name)
endif
endfor endfor
endfunction endfunction
@@ -463,21 +487,19 @@ function! s:lod_ft(pat, names)
let syn = 'syntax/'.a:pat.'.vim' let syn = 'syntax/'.a:pat.'.vim'
call s:lod(a:names, ['plugin', 'after/plugin'], syn, 'after/'.syn) call s:lod(a:names, ['plugin', 'after/plugin'], syn, 'after/'.syn)
execute 'autocmd! PlugLOD FileType' a:pat execute 'autocmd! PlugLOD FileType' a:pat
if exists('#filetypeplugin#FileType') call s:doautocmd('filetypeplugin', 'FileType')
doautocmd filetypeplugin FileType call s:doautocmd('filetypeindent', 'FileType')
endif
if exists('#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)
call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
call s:dobufread(a:names)
execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args) execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args)
endfunction endfunction
function! s:lod_map(map, names, prefix) function! s:lod_map(map, names, prefix)
call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
call s:dobufread(a:names)
let extra = '' let extra = ''
while 1 while 1
let c = getchar(0) let c = getchar(0)
@@ -486,10 +508,17 @@ function! s:lod_map(map, names, prefix)
endif endif
let extra .= nr2char(c) let extra .= nr2char(c)
endwhile endwhile
if v:count
call feedkeys(v:count, 'n')
endif
call feedkeys('"'.v:register, 'n')
if mode(1) == 'no'
call feedkeys(v:operator)
endif
call feedkeys(a:prefix . substitute(a:map, '^<Plug>', "\<Plug>", '') . extra) call feedkeys(a:prefix . substitute(a:map, '^<Plug>', "\<Plug>", '') . extra)
endfunction endfunction
function! s:Plug(repo, ...) function! plug#(repo, ...)
if a:0 > 1 if a:0 > 1
return s:err('Invalid number of arguments (1..2)') return s:err('Invalid number of arguments (1..2)')
endif endif
@@ -588,6 +617,7 @@ function! s:syntax()
syn match plugRelDate /([^)]*)$/ contained syn match plugRelDate /([^)]*)$/ contained
syn match plugNotLoaded /(not loaded)$/ syn match plugNotLoaded /(not loaded)$/
syn match plugError /^x.*/ syn match plugError /^x.*/
syn region plugDeleted start=/^\~ .*/ end=/^\ze\S/
syn match plugH2 /^.*:\n-\+$/ syn match plugH2 /^.*:\n-\+$/
syn keyword Function PlugInstall PlugStatus PlugUpdate PlugClean syn keyword Function PlugInstall PlugStatus PlugUpdate PlugClean
hi def link plug1 Title hi def link plug1 Title
@@ -607,6 +637,7 @@ function! s:syntax()
hi def link plugUpdate Type hi def link plugUpdate Type
hi def link plugError Error hi def link plugError Error
hi def link plugDeleted Ignore
hi def link plugRelDate Comment hi def link plugRelDate Comment
hi def link plugEdge PreProc hi def link plugEdge PreProc
hi def link plugSha Identifier hi def link plugSha Identifier
@@ -684,6 +715,12 @@ function! s:prepare(...)
throw 'Invalid current working directory. Cannot proceed.' throw 'Invalid current working directory. Cannot proceed.'
endif endif
for evar in ['$GIT_DIR', '$GIT_WORK_TREE']
if exists(evar)
throw evar.' detected. Cannot proceed.'
endif
endfor
call s:job_abort() call s:job_abort()
if s:switch_in() if s:switch_in()
normal q normal q
@@ -699,10 +736,9 @@ function! s:prepare(...)
let s:plug_buf = winbufnr(0) let s:plug_buf = winbufnr(0)
call s:assign_name() call s:assign_name()
silent! unmap <buffer> <cr> for k in ['<cr>', 'L', 'o', 'X', 'd', 'dd']
silent! unmap <buffer> L execute 'silent! unmap <buffer>' k
silent! unmap <buffer> o endfor
silent! unmap <buffer> X
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap cursorline modifiable setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap cursorline modifiable
setf vim-plug setf vim-plug
if exists('g:syntax_on') if exists('g:syntax_on')
@@ -722,15 +758,25 @@ function! s:assign_name()
silent! execute 'f' fnameescape(name) silent! execute 'f' fnameescape(name)
endfunction endfunction
function! s:chsh(swap)
let prev = [&shell, &shellredir]
if !s:is_win && a:swap
set shell=sh shellredir=>%s\ 2>&1
endif
return prev
endfunction
function! s:bang(cmd, ...) function! s:bang(cmd, ...)
try try
let [sh, shrd] = s:chsh(a:0)
" FIXME: Escaping is incomplete. We could use shellescape with eval, " FIXME: Escaping is incomplete. We could use shellescape with eval,
" but it won't work on Windows. " but it won't work on Windows.
let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd let cmd = a:0 ? s:with_cd(a:cmd, a:1) : a:cmd
let g:_plug_bang = '!'.escape(cmd, '#!%') let g:_plug_bang = '!'.escape(cmd, '#!%')
execute "normal! :execute g:_plug_bang\<cr>\<cr>" execute "normal! :execute g:_plug_bang\<cr>\<cr>"
finally finally
unlet g:_plug_bang unlet g:_plug_bang
let [&shell, &shellredir] = [sh, shrd]
endtry endtry
return v:shell_error ? 'Exit status: ' . v:shell_error : '' return v:shell_error ? 'Exit status: ' . v:shell_error : ''
endfunction endfunction
@@ -758,7 +804,12 @@ function! s:do(pull, force, todo)
let error = '' let error = ''
let type = type(spec.do) let type = type(spec.do)
if type == s:TYPE.string if type == s:TYPE.string
if spec.do[0] == ':'
call s:load_plugin(spec)
execute spec.do[1:]
else
let error = s:bang(spec.do) let error = s:bang(spec.do)
endif
elseif type == s:TYPE.funcref elseif type == s:TYPE.funcref
try try
let status = installed ? 'installed' : (updated ? 'updated' : 'unchanged') let status = installed ? 'installed' : (updated ? 'updated' : 'unchanged')
@@ -769,6 +820,7 @@ function! s:do(pull, force, todo)
else else
let error = 'Invalid hook type' let error = 'Invalid hook type'
endif endif
call s:switch_in()
call setline(4, empty(error) ? (getline(4) . 'OK') call setline(4, empty(error) ? (getline(4) . 'OK')
\ : ('x' . getline(4)[1:] . error)) \ : ('x' . getline(4)[1:] . error))
if !empty(error) if !empty(error)
@@ -836,13 +888,14 @@ function! s:names(...)
endfunction endfunction
function! s:check_ruby() function! s:check_ruby()
silent! ruby require 'thread'; VIM::command('let g:plug_ruby = 1') silent! ruby require 'thread'; VIM::command("let g:plug_ruby = '#{RUBY_VERSION}'")
if get(g:, 'plug_ruby', 0) if !exists('g:plug_ruby')
unlet g:plug_ruby
return 1
endif
redraw! redraw!
return s:warn('echom', 'Warning: Ruby interface is broken') return s:warn('echom', 'Warning: Ruby interface is broken')
endif
let ruby_version = split(g:plug_ruby, '\.')
unlet g:plug_ruby
return s:version_requirement(ruby_version, [1, 8, 7])
endfunction endfunction
function! s:update_impl(pull, force, args) abort function! s:update_impl(pull, force, args) abort
@@ -995,14 +1048,14 @@ function! s:update_finish()
if v:shell_error if v:shell_error
call add(s:update.errors, name) call add(s:update.errors, name)
call s:regress_bar() call s:regress_bar()
execute pos 'd _' silent execute pos 'd _'
call append(4, msg) | 4 call append(4, msg) | 4
elseif !empty(out) elseif !empty(out)
call setline(pos, msg) call setline(pos, msg)
endif endif
redraw redraw
endfor endfor
4 d _ silent 4 d _
call s:do(s:update.pull, s:update.force, filter(copy(s:update.all), 'index(s:update.errors, v:key) < 0 && has_key(v:val, "do")')) call s:do(s:update.pull, s:update.force, filter(copy(s:update.all), 'index(s:update.errors, v:key) < 0 && has_key(v:val, "do")'))
call s:finish(s:update.pull) call s:finish(s:update.pull)
call setline(1, 'Updated. Elapsed time: ' . split(reltimestr(reltime(s:update.start)))[0] . ' sec.') call setline(1, 'Updated. Elapsed time: ' . split(reltimestr(reltime(s:update.start)))[0] . ' sec.')
@@ -1119,7 +1172,7 @@ function! s:log(bullet, name, lines)
if s:switch_in() if s:switch_in()
let pos = s:logpos(a:name) let pos = s:logpos(a:name)
if pos > 0 if pos > 0
execute pos 'd _' silent execute pos 'd _'
if pos > winheight('.') if pos > winheight('.')
let pos = 4 let pos = 4
endif endif
@@ -1823,10 +1876,7 @@ endfunction
function! s:system(cmd, ...) function! s:system(cmd, ...)
try try
let [sh, shrd] = [&shell, &shellredir] let [sh, shrd] = s:chsh(1)
if !s:is_win
set shell=sh shellredir=>%s\ 2>&1
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
@@ -1948,16 +1998,48 @@ function! s:clean(force)
if empty(todo) if empty(todo)
call append(line('$'), 'Already clean.') call append(line('$'), 'Already clean.')
else else
if a:force || s:ask('Proceed?') let s:clean_count = 0
for dir in todo call append(3, ['Directories to delete:', ''])
call s:rm_rf(dir) redraw!
endfor if a:force || s:ask_no_interrupt('Delete all directories?')
call append(3, ['Removed.', '']) call s:delete([6, line('$')], 1)
else else
call append(3, ['Cancelled.', '']) call setline(4, 'Cancelled.')
nnoremap <silent> <buffer> d :set opfunc=<sid>delete_op<cr>g@
nmap <silent> <buffer> dd d_
xnoremap <silent> <buffer> d :<c-u>call <sid>delete_op(visualmode(), 1)<cr>
echo 'Delete the lines (d{motion}) to delete the corresponding directories'
endif endif
endif endif
4 4
setlocal nomodifiable
endfunction
function! s:delete_op(type, ...)
call s:delete(a:0 ? [line("'<"), line("'>")] : [line("'["), line("']")], 0)
endfunction
function! s:delete(range, force)
let [l1, l2] = a:range
let force = a:force
while l1 <= l2
let line = getline(l1)
if line =~ '^- ' && isdirectory(line[2:])
execute l1
redraw!
let answer = force ? 1 : s:ask('Delete '.line[2:].'?', 1)
let force = force || answer > 1
if answer
call s:rm_rf(line[2:])
setlocal modifiable
call setline(l1, '~'.line[1:])
let s:clean_count += 1
call setline(4, printf('Removed %d directories.', s:clean_count))
setlocal nomodifiable
endif
endif
let l1 += 1
endwhile
endfunction endfunction
function! s:upgrade() function! s:upgrade()
@@ -2099,11 +2181,15 @@ function! s:preview_commit()
return return
endif endif
if exists('g:plug_pwindow') && !s:is_preview_window_open()
execute g:plug_pwindow
execute 'e' sha
else
execute 'pedit' sha execute 'pedit' sha
wincmd P wincmd P
setlocal filetype=git buftype=nofile nobuflisted modifiable endif
execute 'silent read !cd' s:shellesc(g:plugs[name].dir) '&& git show --no-color --pretty=medium' sha setlocal previewwindow filetype=git buftype=nofile nobuflisted modifiable
normal! gg"_dd execute 'silent %!cd' s:shellesc(g:plugs[name].dir) '&& git show --no-color --pretty=medium' sha
setlocal nomodifiable setlocal nomodifiable
nnoremap <silent> <buffer> q :q<cr> nnoremap <silent> <buffer> q :q<cr>
wincmd p wincmd p
@@ -2189,7 +2275,7 @@ function! s:revert()
setlocal modifiable setlocal modifiable
normal! "_dap normal! "_dap
setlocal nomodifiable setlocal nomodifiable
echo 'Reverted.' echo 'Reverted'
endfunction endfunction
function! s:snapshot(force, ...) abort function! s:snapshot(force, ...) abort

View File

@@ -7,19 +7,19 @@ Execute (#112 On-demand loading should not suppress messages from ftplugin):
redir => out redir => out
tabnew a.c tabnew a.c
redir END redir END
Assert stridx(out, 'ftplugin') >= 0 Assert stridx(out, 'ftplugin-c') >= 0
* The same applies to plug#load()) * The same applies to plug#load())
redir => out redir => out
call plug#load('ftplugin-msg') call plug#load('ftplugin-msg')
redir END redir END
Assert stridx(out, 'ftplugin') >= 0 Assert stridx(out, 'ftplugin-c') >= 0
q q
********************************************************************** **********************************************************************
Execute (#114 Should not contain empty path in &rtp): Execute (#114 Should not contain empty path in &rtp):
call plug#begin('/tmp/plugged') call plug#begin('/tmp/vim-plug-test/plugged')
call plug#end() call plug#end()
Log &rtp Log &rtp
@@ -35,7 +35,7 @@ Execute (#130 Proper cleanup of on-demand loading triggers):
" Cleared on command " Cleared on command
call ReloadPlug() call ReloadPlug()
call plug#begin('/tmp/plugged') call plug#begin('/tmp/vim-plug-test/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
@@ -52,7 +52,7 @@ Execute (#130 Proper cleanup of on-demand loading triggers):
" Cleared on FileType " Cleared on FileType
call ReloadPlug() call ReloadPlug()
call plug#begin('/tmp/plugged') call plug#begin('/tmp/vim-plug-test/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()
@@ -78,13 +78,13 @@ Execute (#131 Syntax error):
********************************************************************** **********************************************************************
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('/tmp/plugged') call plug#begin('/tmp/vim-plug-test/plugged')
call plug#end() call plug#end()
PlugClean! PlugClean!
" Install master branch " Install master branch
call plug#begin('/tmp/plugged') call plug#begin('/tmp/vim-plug-test/plugged')
Plug expand('file:////tmp/new-branch') Plug expand('file:////tmp/vim-plug-test/new-branch')
call plug#end() call plug#end()
PlugUpdate PlugUpdate
@@ -95,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 /tmp/new-branch && git checkout -b new &&' call system('cd /tmp/vim-plug-test/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('/tmp/plugged') call plug#begin('/tmp/vim-plug-test/plugged')
Plug 'junegunn/seoul256.vim' Plug 'junegunn/seoul256.vim'
Plug expand('file:////tmp/new-branch'), { 'branch': 'new' } Plug expand('file:////tmp/vim-plug-test/new-branch'), { 'branch': 'new' }
call plug#end() call plug#end()
PlugUpdate PlugUpdate
silent %y silent %y
@@ -125,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 /tmp/new-branch && git checkout master &&' call system('cd /tmp/vim-plug-test/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('/tmp/plugged') call plug#begin('/tmp/vim-plug-test/plugged')
Plug expand('file:////tmp/new-branch'), { 'branch': 'brand-new' } Plug expand('file:////tmp/vim-plug-test/new-branch'), { 'branch': 'brand-new' }
call plug#end() call plug#end()
PlugUpdate PlugUpdate
silent %y silent %y
@@ -154,19 +154,19 @@ 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 /tmp/plugged/new-branch && git checkout master &&' call system('cd /tmp/vim-plug-test/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 /tmp/new-branch && git checkout master &&' call system('cd /tmp/vim-plug-test/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('/tmp/plugged') call plug#begin('/tmp/vim-plug-test/plugged')
if multi if multi
Plug 'junegunn/seoul256.vim' Plug 'junegunn/seoul256.vim'
endif endif
Plug expand('file:////tmp/new-branch') Plug expand('file:////tmp/vim-plug-test/new-branch')
call plug#end() call plug#end()
PlugUpdate PlugUpdate
silent %y silent %y
@@ -210,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('/tmp/plugged') call plug#begin('/tmp/vim-plug-test/plugged')
Plug 'junegunn/seoul256.vim' Plug 'junegunn/seoul256.vim'
call plug#end() call plug#end()
@@ -224,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('/tmp/plug it') call plug#begin('/tmp/vim-plug-test/plug it')
Plug 'seoul256 vim' Plug 'seoul256 vim'
call plug#end() call plug#end()
Log &rtp Log &rtp
@@ -232,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('/tmp/plugged') call plug#begin('/tmp/vim-plug-test/plugged')
Plug 'plugin1' Plug 'plugin1'
\| Plug 'plugin0' \| Plug 'plugin0'
@@ -250,7 +250,7 @@ Execute (#236: Plugin removed from &rtp when .vimrc is reloaded):
silent! delc EasyAlign silent! delc EasyAlign
call ReloadPlug() call ReloadPlug()
call plug#begin('/tmp/plugged') call plug#begin('/tmp/vim-plug-test/plugged')
Plug 'junegunn/vim-easy-align', { 'on': 'EasyAlign' } Plug 'junegunn/vim-easy-align', { 'on': 'EasyAlign' }
call plug#end() call plug#end()
PlugInstall | q PlugInstall | q
@@ -259,19 +259,19 @@ Execute (#236: Plugin removed from &rtp when .vimrc is reloaded):
%EasyAlign= %EasyAlign=
Assert &rtp =~ '/vim-easy-align', 'Plugin should be in &rtp' Assert &rtp =~ '/vim-easy-align', 'Plugin should be in &rtp'
call plug#begin('/tmp/plugged') call plug#begin('/tmp/vim-plug-test/plugged')
Plug 'junegunn/vim-easy-align', { 'on': 'EasyAlign' } Plug 'junegunn/vim-easy-align', { 'on': 'EasyAlign' }
call plug#end() call plug#end()
Assert &rtp =~ '/vim-easy-align', 'Plugin should still be in &rtp' Assert &rtp =~ '/vim-easy-align', 'Plugin should still be in &rtp'
********************************************************************** **********************************************************************
Execute (#350: Ruby installer failed to unshallow tagged plugin on update): Execute (#350: Ruby installer failed to unshallow tagged plugin on update):
call plug#begin('/tmp/plugged') call plug#begin('/tmp/vim-plug-test/plugged')
call plug#end() call plug#end()
PlugClean! PlugClean!
" Shallow clone. We should have at least 2 plugins to enable parallel installer. " Shallow clone. We should have at least 2 plugins to enable parallel installer.
call plug#begin('/tmp/plugged') call plug#begin('/tmp/vim-plug-test/plugged')
Plug 'junegunn/vim-easy-align' Plug 'junegunn/vim-easy-align'
Plug 'junegunn/seoul256.vim' Plug 'junegunn/seoul256.vim'
call plug#end() call plug#end()
@@ -279,7 +279,7 @@ Execute (#350: Ruby installer failed to unshallow tagged plugin on update):
Assert filereadable(g:plugs['vim-easy-align'].dir.'/.git/shallow') Assert filereadable(g:plugs['vim-easy-align'].dir.'/.git/shallow')
" Now unshallowed " Now unshallowed
call plug#begin('/tmp/plugged') call plug#begin('/tmp/vim-plug-test/plugged')
Plug 'junegunn/vim-easy-align', { 'tag': '2.9.0' } Plug 'junegunn/vim-easy-align', { 'tag': '2.9.0' }
Plug 'junegunn/seoul256.vim' Plug 'junegunn/seoul256.vim'
call plug#end() call plug#end()
@@ -289,16 +289,44 @@ Execute (#350: Ruby installer failed to unshallow tagged plugin on update):
********************************************************************** **********************************************************************
Execute (#474: Load ftdetect files in filetypedetect augroup): Execute (#474: Load ftdetect files in filetypedetect augroup):
call plug#begin('/tmp/plugged') call plug#begin('/tmp/vim-plug-test/plugged')
Plug 'junegunn/rust.vim', { 'for': 'rust', 'commit': '115d321d383eb96d438466c56cc871fcc1bd0faa' } Plug 'junegunn/rust.vim', { 'for': 'rust', 'commit': '115d321d383eb96d438466c56cc871fcc1bd0faa' }
call plug#end() call plug#end()
PlugInstall! PlugInstall!
q q
tabnew /tmp/any.rs tabnew /tmp/vim-plug-test/any.rs
AssertEqual 'rust', &filetype AssertEqual 'rust', &filetype
Log &filetype Log &filetype
filetype detect filetype detect
AssertEqual 'rust', &filetype AssertEqual 'rust', &filetype
Log &filetype Log &filetype
bd bd
**********************************************************************
Execute (#489 On-demand loading with 'on' option should trigger BufRead autocmd):
call plug#begin('$PLUG_FIXTURES')
Plug 'ftplugin-msg', { 'on': 'XXX' }
call plug#end()
tabnew a.java
redir => out
silent! XXX
redir END
Assert stridx(out, 'ftplugin-java') >= 0
q
**********************************************************************
Execute (Cursor moved to another window during post-update hook):
function! DoSplit(...)
new
call setline(1, 'empty')
endfunction
call plug#begin('/tmp/vim-plug-test/plugged')
Plug 'junegunn/rust.vim', { 'do': function('DoSplit') }
call plug#end()
PlugInstall!
AssertEqual 1, line('$')
AssertEqual 'empty', getline(1)
q!
q

View File

@@ -6,9 +6,12 @@ export BASE="$PWD"
export PLUG_SRC="$PWD/../plug.vim" export PLUG_SRC="$PWD/../plug.vim"
export PLUG_FIXTURES="$PWD/fixtures" export PLUG_FIXTURES="$PWD/fixtures"
mkdir -p "$PLUG_FIXTURES" mkdir -p "$PLUG_FIXTURES"
export TEMP=/tmp/vim-plug-test
rm -rf "$TEMP"
mkdir -p "$TEMP"
cat > /tmp/mini-vimrc << VIMRC cat > $TEMP/mini-vimrc << VIMRC
set rtp+=/tmp/junegunn/vader.vim set rtp+=$TEMP/junegunn/vader.vim
set shell=/bin/bash set shell=/bin/bash
VIMRC VIMRC
@@ -19,7 +22,7 @@ clone() {
} }
clone_repos() ( clone_repos() (
cd /tmp cd $TEMP
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 \
vim-oblique vim-pseudocl vim-redis vim-emoji; do vim-oblique vim-pseudocl vim-redis vim-emoji; do
@@ -77,10 +80,11 @@ DOC
rm -rf "$PLUG_FIXTURES/ftplugin-msg" rm -rf "$PLUG_FIXTURES/ftplugin-msg"
mkdir -p "$PLUG_FIXTURES/ftplugin-msg/ftplugin" mkdir -p "$PLUG_FIXTURES/ftplugin-msg/ftplugin"
echo "echomsg 'ftplugin'" > "$PLUG_FIXTURES/ftplugin-msg/ftplugin/c.vim" echo "echomsg 'ftplugin-c'" > "$PLUG_FIXTURES/ftplugin-msg/ftplugin/c.vim"
echo "echomsg 'ftplugin-java'" > "$PLUG_FIXTURES/ftplugin-msg/ftplugin/java.vim"
rm -rf /tmp/new-branch rm -rf $TEMP/new-branch
cd /tmp cd $TEMP
git init new-branch git init new-branch
cd new-branch cd new-branch
mkdir plugin mkdir plugin
@@ -108,10 +112,10 @@ git --version
VIM=$(select_vim) VIM=$(select_vim)
echo "Selected Vim: $VIM" echo "Selected Vim: $VIM"
if [ "$1" = '!' ]; then if [ "$1" = '!' ]; then
$VIM -Nu /tmp/mini-vimrc -c 'Vader! test.vader' > /dev/null && $VIM -Nu $TEMP/mini-vimrc -c 'Vader! test.vader' > /dev/null &&
prepare && prepare &&
$VIM -Nu /tmp/mini-vimrc -c 'let g:plug_threads = 1 | Vader! test.vader' > /dev/null $VIM -Nu $TEMP/mini-vimrc -c 'let g:plug_threads = 1 | Vader! test.vader' > /dev/null
else else
$VIM -Nu /tmp/mini-vimrc -c 'Vader test.vader' $VIM -Nu $TEMP/mini-vimrc -c 'Vader test.vader'
fi fi

View File

@@ -2,7 +2,7 @@ Execute (Initialize test environment):
Save &rtp, g:plugs, g:plug_home, g:plug_window Save &rtp, g:plugs, g:plug_home, g:plug_window
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/vim-plug-test/%s'
let g:base_rtp = &rtp let g:base_rtp = &rtp
let g:first_rtp = split(&rtp, ',')[0] let g:first_rtp = split(&rtp, ',')[0]
let g:last_rtp = split(&rtp, ',')[-1] let g:last_rtp = split(&rtp, ',')[-1]

View File

@@ -34,7 +34,7 @@ Execute (Subsequent plug#begin() calls will reuse 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/vim-plug-test/junegunn/seoul256.vim', g:plugs['seoul256.vim'].uri
AssertEqual join([g: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
@@ -43,7 +43,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/vim-plug-test/junegunn/goyo.vim', g:plugs['goyo.vim'].uri
AssertEqual join([g: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
@@ -51,14 +51,14 @@ Execute (Test Plug command):
AssertEqual '1.5.3', g:plugs['goyo.vim'].tag AssertEqual '1.5.3', g:plugs['goyo.vim'].tag
" Git URI " Git URI
Plug 'file:///tmp/jg/vim-emoji' Plug 'file:///tmp/vim-plug-test/jg/vim-emoji'
AssertEqual 'file:///tmp/jg/vim-emoji', g:plugs['vim-emoji'].uri AssertEqual 'file:///tmp/vim-plug-test/jg/vim-emoji', g:plugs['vim-emoji'].uri
AssertEqual 'master', g:plugs['vim-emoji'].branch AssertEqual 'master', g:plugs['vim-emoji'].branch
AssertEqual join([g: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'
AssertEqual 'file:///tmp/vim-scripts/beauty256', g:plugs.beauty256.uri AssertEqual 'file:///tmp/vim-plug-test/vim-scripts/beauty256', g:plugs.beauty256.uri
AssertEqual 'master', g:plugs.beauty256.branch AssertEqual 'master', g:plugs.beauty256.branch
AssertEqual 4, len(g:plugs) AssertEqual 4, len(g:plugs)
@@ -84,7 +84,7 @@ Execute (PlugClean before installation):
Execute (plug#end() updates &rtp): Execute (plug#end() updates &rtp):
" Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' } " Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' }
" Plug 'file:///tmp/jg/vim-emoji' " Plug 'file:///tmp/vim-plug-test/jg/vim-emoji'
" Plug 'beauty256' " Plug 'beauty256'
" Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co', 'rtp': '././' } " Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co', 'rtp': '././' }
call plug#end() call plug#end()
@@ -159,7 +159,7 @@ Expect:
Execute (Change branch of seoul256.vim): Execute (Change branch of seoul256.vim):
call plug#begin() call plug#begin()
Plug 'junegunn/seoul256.vim' Plug 'junegunn/seoul256.vim'
Plug 'file:///tmp/jg/vim-emoji' Plug 'file:///tmp/vim-plug-test/jg/vim-emoji'
call plug#end() call plug#end()
Execute (PlugStatus): Execute (PlugStatus):
@@ -197,15 +197,15 @@ Expect:
Execute (Change URI of seoul256.vim): Execute (Change URI of seoul256.vim):
call plug#begin() call plug#begin()
Plug 'junegunn.choi/seoul256.vim' Plug 'junegunn.choi/seoul256.vim'
Plug 'file:///tmp/jg/vim-emoji' Plug 'file:///tmp/vim-plug-test/jg/vim-emoji'
call plug#end() call plug#end()
Execute (PlugStatus): Execute (PlugStatus):
call PlugStatusSorted() call PlugStatusSorted()
Expect: Expect:
Expected: file:///tmp/junegunn.choi/seoul256.vim Expected: file:///tmp/vim-plug-test/junegunn.choi/seoul256.vim
Invalid URI: file:///tmp/junegunn/seoul256.vim Invalid URI: file:///tmp/vim-plug-test/junegunn/seoul256.vim
PlugClean required. PlugClean required.
- vim-emoji: OK - vim-emoji: OK
Finished. 1 error(s). Finished. 1 error(s).
@@ -215,7 +215,7 @@ Expect:
Execute (Corrected the URI but diverged from master): Execute (Corrected the URI but diverged from master):
call plug#begin() call plug#begin()
Plug 'junegunn/seoul256.vim' Plug 'junegunn/seoul256.vim'
Plug 'file:///tmp/jg/vim-emoji' Plug 'file:///tmp/vim-plug-test/jg/vim-emoji'
call plug#end() call plug#end()
for _ in range(3) for _ in range(3)
call system(printf('cd "%s" && git commit --allow-empty -m "dummy"', g:plugs['seoul256.vim'].dir)) call system(printf('cd "%s" && git commit --allow-empty -m "dummy"', g:plugs['seoul256.vim'].dir))
@@ -240,8 +240,8 @@ Expect:
Execute (PlugClean! to remove seoul256.vim): Execute (PlugClean! to remove seoul256.vim):
PlugClean! PlugClean!
" Three removed, emoji left " Three removed, emoji left
AssertEqual 'Removed.', getline(4) AssertEqual 'Removed 3 directories.', getline(4)
AssertExpect '^- ', 3 AssertExpect '^\~ ', 3
AssertExpect 'Diverged', 1 AssertExpect 'Diverged', 1
Assert empty(globpath(&rtp, 'colors/seoul256.vim')) Assert empty(globpath(&rtp, 'colors/seoul256.vim'))
Assert !empty(globpath(&rtp, 'autoload/emoji.vim')) Assert !empty(globpath(&rtp, 'autoload/emoji.vim'))
@@ -257,8 +257,8 @@ Execute (PlugStatus):
call PlugStatusSorted() call PlugStatusSorted()
Expect: Expect:
Expected: file:///tmp/junegunn/vim-emoji Expected: file:///tmp/vim-plug-test/junegunn/vim-emoji
Invalid URI: file:///tmp/jg/vim-emoji Invalid URI: file:///tmp/vim-plug-test/jg/vim-emoji
Not found. Try PlugInstall. Not found. Try PlugInstall.
PlugClean required. PlugClean required.
Finished. 2 error(s). Finished. 2 error(s).
@@ -268,8 +268,8 @@ Expect:
Execute (PlugClean! to remove vim-emoji): Execute (PlugClean! to remove vim-emoji):
PlugClean! PlugClean!
AssertExpect '^- ', 1 AssertExpect '^\~ ', 1
AssertEqual 'Removed.', getline(4) AssertEqual 'Removed 1 directories.', getline(4)
Assert empty(globpath(&rtp, 'colors/seoul256.vim')) Assert empty(globpath(&rtp, 'colors/seoul256.vim'))
Assert empty(globpath(&rtp, 'autoload/emoji.vim')) Assert empty(globpath(&rtp, 'autoload/emoji.vim'))
q q
@@ -300,7 +300,7 @@ Execute (PlugDiff - 'No updates.'):
Execute (New commits on remote, 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']
for _ in range(2) for _ in range(2)
call system(printf('cd /tmp/junegunn/%s && git commit --allow-empty -m "update"', repo)) call system(printf('cd /tmp/vim-plug-test/junegunn/%s && git commit --allow-empty -m "update"', repo))
endfor endfor
endfor endfor
unlet repo unlet repo
@@ -365,6 +365,22 @@ Execute (New commits on remote, PlugUpdate, then PlugDiff):
AssertEqual 1, &previewwindow AssertEqual 1, &previewwindow
pclose pclose
Execute (Test g:plug_pwindow):
let g:plug_pwindow = 'below 5new'
PlugDiff
AssertExpect '^- ', 1
execute "normal ]]jo"
AssertEqual 0, &previewwindow
AssertEqual 1, winnr()
wincmd P
AssertEqual 1, &previewwindow
AssertEqual 2, winnr()
AssertEqual 5, winheight('.')
wincmd p
normal q
unlet g:plug_pwindow
Execute (Reuse Plug window in another tab): Execute (Reuse Plug window in another tab):
let tabnr = tabpagenr() let tabnr = tabpagenr()
PlugDiff PlugDiff
@@ -596,7 +612,7 @@ 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 RmRf(fzf) call RmRf(fzf)
Log system(printf('cp -r "/tmp/fzf" "%s"', fzf)) Log system(printf('cp -r "/tmp/vim-plug-test/fzf" "%s"', fzf))
Execute (PlugUpdate still should not care): Execute (PlugUpdate still should not care):
PlugUpdate PlugUpdate
@@ -769,7 +785,7 @@ Execute (On update):
call plug#end() call plug#end()
" New commits on remote " New commits on remote
call system('cd /tmp/junegunn/vim-pseudocl && git commit --allow-empty -m "update"') call system('cd /tmp/vim-plug-test/junegunn/vim-pseudocl && git commit --allow-empty -m "update"')
silent PlugUpdate silent PlugUpdate
Log getline(1, '$') Log getline(1, '$')
@@ -841,7 +857,12 @@ Execute (PlugUpdate!):
Execute (When submodules are not initialized): Execute (When submodules are not initialized):
call system(printf('cd %s && git submodule deinit subsubmodule', g:plugs['subsubmodule'].dir)) call system(printf('cd %s && git submodule deinit subsubmodule', g:plugs['subsubmodule'].dir))
^ #481 submodule update should use standard shell
let sh = &shell
set sh=/bin/echo
silent PlugUpdate! silent PlugUpdate!
let &shell = sh
unlet sh
q q
AssertEqual ' ', system(printf('cd %s && git submodule status', g:plugs['subsubmodule'].dir))[0], AssertEqual ' ', system(printf('cd %s && git submodule status', g:plugs['subsubmodule'].dir))[0],
\ 'subsubmodule/subsubmodule should be initialized' \ 'subsubmodule/subsubmodule should be initialized'
@@ -856,7 +877,7 @@ 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 /tmp/vim-plug-test/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 RmRf(g:plugs['vim-pseudocl'].dir) call RmRf(g:plugs['vim-pseudocl'].dir)
@@ -916,8 +937,8 @@ Execute (Should not run when failed to update):
call system(printf('cd %s && git remote set-url origin xxx', g:plugs['vim-easy-align'].dir)) call system(printf('cd %s && git remote set-url origin xxx', g:plugs['vim-easy-align'].dir))
" New commits on remote " New commits on remote
call system('cd /tmp/junegunn/vim-easy-align && git commit --allow-empty -m "update"') call system('cd /tmp/vim-plug-test/junegunn/vim-easy-align && git commit --allow-empty -m "update"')
call system('cd /tmp/junegunn/vim-pseudocl && git commit --allow-empty -m "update"') call system('cd /tmp/vim-plug-test/junegunn/vim-pseudocl && git commit --allow-empty -m "update"')
silent PlugUpdate silent PlugUpdate
Log getline(1, '$') Log getline(1, '$')
@@ -928,18 +949,31 @@ Execute (Should not run when failed to update):
Assert filereadable(g:plugs['vim-pseudocl'].dir.'/not-failed'), Assert filereadable(g:plugs['vim-pseudocl'].dir.'/not-failed'),
\ 'vim-pseudocl/not-failed should exist' \ 'vim-pseudocl/not-failed should exist'
Execute (Vim command with : prefix):
call plug#begin()
Plug 'junegunn/vim-pseudocl', { 'do': ':call setline(2, 12345)' }
call plug#end()
PlugInstall!
Log getline(1, '$')
AssertEqual '12345', getline(2)
q
********************************************************************** **********************************************************************
~ Overriding `dir` ~ Overriding `dir`
********************************************************************** **********************************************************************
Execute (Using custom dir): Execute (Using custom dir):
call plug#begin()
Plug 'junegunn/vim-easy-align'
call plug#end()
Assert isdirectory(g:plugs['vim-easy-align'].dir) Assert isdirectory(g:plugs['vim-easy-align'].dir)
call RmRf('/tmp/easy-align') call RmRf('/tmp/vim-plug-test/easy-align')
call plug#begin() call plug#begin()
Plug 'junegunn/vim-easy-align', { 'dir': '/tmp/easy-align' } Plug 'junegunn/vim-easy-align', { 'dir': '/tmp/vim-plug-test/easy-align' }
call plug#end() call plug#end()
AssertEqual '/tmp/easy-align/', g:plugs['vim-easy-align'].dir AssertEqual '/tmp/vim-plug-test/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)
@@ -1255,11 +1289,11 @@ Execute (PlugClean should not try to remove unmanaged plugins inside g:plug_home
" Remove z1, z2 " Remove z1, z2
PlugClean! PlugClean!
AssertExpect '^- ', 2 AssertExpect '^\~ ', 2
AssertExpect 'Already clean', 0 AssertExpect 'Already clean', 0
PlugClean! PlugClean!
AssertExpect '^- ', 0 AssertExpect '^\~ ', 0
AssertExpect 'Already clean', 1 AssertExpect 'Already clean', 1
q q
@@ -1419,10 +1453,10 @@ Execute (#371 - 'as' option):
Assert g:plugs.yogo.dir =~# '/yogo/$' Assert g:plugs.yogo.dir =~# '/yogo/$'
call plug#begin() call plug#begin()
Plug 'junegunn/goyo.vim', {'as': 'yogo', 'dir': '/tmp/gogo'} Plug 'junegunn/goyo.vim', {'as': 'yogo', 'dir': '/tmp/vim-plug-test/gogo'}
call plug#end() call plug#end()
AssertEqual ['yogo'], sort(keys(g:plugs)) AssertEqual ['yogo'], sort(keys(g:plugs))
AssertEqual '/tmp/gogo/', g:plugs.yogo.dir AssertEqual '/tmp/vim-plug-test/gogo/', g:plugs.yogo.dir
Execute (#427 - Tag option with wildcard (requires git 1.9.2 or above)): Execute (#427 - Tag option with wildcard (requires git 1.9.2 or above)):
if str2nr(split(split(system('git --version'))[-1], '\.')[0]) < 2 if str2nr(split(split(system('git --version'))[-1], '\.')[0]) < 2