Compare commits

..

No commits in common. "master" and "0.8.0" have entirely different histories.

16 changed files with 652 additions and 2801 deletions

1
.github/FUNDING.yml vendored
View File

@ -1 +0,0 @@
github: junegunn

View File

@ -1,37 +0,0 @@
<!--
### Before Submitting
- You checked the [faq](https://github.com/junegunn/vim-plug/wiki/faq) for common problems.
- Check your [requirements](https://github.com/junegunn/vim-plug/wiki/requirements) are satisfied.
- You are not going to suggest vim-plug manage itself like Vundle, see #240, #364, #367 ...
-->
Explain the problem here ...
------------------------------
<!-- Paste your Plug block (from `call plug#begin()` to `call plug#end()`) -->
```
```
<!-- Paste the contents of `:version` below -->
```
```
<!-- Check all that apply. -->
- Type:
- [ ] Bug
- [ ] Enhancement
- [ ] Feature Request
- [ ] Question
- OS:
- [ ] All/Other
- [ ] Linux
- [ ] macOS
- [ ] Windows
- Vim:
- [ ] Terminal Vim
- [ ] GVim
- [ ] Neovim

View File

@ -1,8 +0,0 @@
<!-- ## Before Submitting
- You made sure the existing tests/travis build works.
- You made sure any new features were tested where appropriate.
- You checked a similar feature wasn't already turned down by searching issues & PRs.
-->
Describe the details of your PR ...

View File

@ -1,52 +0,0 @@
---
name: Test vim-plug
on:
push:
branches: [master, devel]
pull_request:
branches: [master]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
vim:
- vim
# FIXME: (core dumped) https://github.com/junegunn/vim-plug/runs/4422576984?check_suite_focus=true#step:3:238
# - neovim-stable
# - neovim-unstable
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install packages and test
env:
ENV: ${{ matrix.vim }}
run: |
export DEPS=~/deps
export PATH=~/deps/bin:$PATH
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
case "$ENV" in
vim)
sudo apt-get install vim
;;
neovim-*)
sudo add-apt-repository ppa:neovim-ppa/${ENV/neovim-/}
sudo apt-get update
sudo apt-get install neovim
mkdir -p $DEPS/bin
echo 'nvim "$@"' > $DEPS/bin/vim
chmod +x $DEPS/bin/vim
export VADER_OUTPUT_FILE=/dev/stderr
;;
esac
test/run !

1
.gitignore vendored
View File

@ -1 +0,0 @@
doc/tags

View File

@ -1,69 +1,49 @@
language: minimal
language: ruby
sudo: false
env:
global:
- DEPS=$HOME/deps
- PATH=$DEPS/bin:$PATH
jobs:
matrix:
include:
- env: ENV=vim80-bionic
dist: bionic
stage: vim8
- env: ENV=vim-nightly
dist: trusty
stage: vim8
- env: ENV=neovim-stable
dist: bionic
addons: {apt: {packages: [neovim], sources: [{sourceline: 'ppa:neovim-ppa/stable'}]}}
stage: neovim
- env: ENV=neovim-nightly
dist: bionic
addons: {apt: {packages: [neovim], sources: [{sourceline: 'ppa:neovim-ppa/unstable'}]}}
stage: neovim
- env: ENV=vim74-trusty-python
dist: trusty
stage: vim74
- env: ENV=vim74-xenial-python3
dist: xenial
stage: vim74
- env: ENV=vim74-trusty-ruby
dist: trusty
- env: ENV=nox
rvm: 1.8.7
addons: { apt: { packages: [vim-nox] } }
stage: vim74
- env: ENV=vim74-xenial-ruby
dist: xenial
addons: {apt: {packages: [vim-nox]}}
stage: vim74
- env: ENV=osx-highsierra
os: osx
osx_image: xcode9.4
stage: vim8
- env: ENV=python
rvm: 1.8.7
addons: { apt: { packages: [python2.7-dev] } }
- env: ENV=python3
rvm: 1.8.7
addons: { apt: { packages: [python3-dev] } }
- env: ENV=ruby
rvm: 1.8.7
- env: ENV=ruby
rvm: 2.0.0
install: |
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
C_OPTS="--prefix=$DEPS --with-features=huge --disable-gui "
case "$ENV" in
vim-*)
;;
neovim-*)
mkdir -p ${DEPS}/bin
ln -s /usr/bin/nvim ${DEPS}/bin/vim
export VADER_OUTPUT_FILE=/dev/stderr
return
;;
vim74-* | vim80-*)
if [ "$ENV" == "nox" ]; then
mkdir -p ${DEPS}/bin
ln -s /usr/bin/vim.nox ${DEPS}/bin/vim
return
fi
C_OPTS="--prefix=$DEPS --with-features=huge --disable-gui "
case "$ENV" in
python)
C_OPTS+=--enable-pythoninterp
;;
*)
return
python3)
C_OPTS+=--enable-python3interp
;;
ruby)
C_OPTS+=--enable-rubyinterp
;;
esac
git clone --depth 1 https://github.com/vim/vim
cd vim
export PATH=/usr/bin:$PATH
./configure $C_OPTS
make
make install

21
LICENSE
View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2017 Junegunn Choi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

463
README.md
View File

@ -1,44 +1,16 @@
<div align="center">
<sup>Special thanks to:</sup>
<br>
<br>
<a href="https://warp.dev/?utm_source=github&utm_medium=referral&utm_campaign=vimplug_20240209">
<div>
<img src="https://raw.githubusercontent.com/junegunn/i/master/warp.png" width="300" alt="Warp">
</div>
<b>Warp is a modern, Rust-based terminal with AI built in so you and your team can build great software, faster.</b>
<div>
<sup>Visit warp.dev to learn more.</sup>
</div>
</a>
<br>
<hr>
</div>
<br>
<h1 title="vim-plug">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="./plug-dark.png">
<img src="./plug.png" height="75" alt="vim-plug">
</picture>
<a href="https://github.com/junegunn/vim-plug/actions/workflows/test.yml?query=branch%3Amaster">
<img src="https://img.shields.io/github/actions/workflow/status/junegunn/vim-plug/test.yml?branch=master">
</a>
</h1>
<img src="https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.png" height="75" alt="vim-plug">[![travis-ci](https://travis-ci.org/junegunn/vim-plug.svg?branch=master)](https://travis-ci.org/junegunn/vim-plug)
===
A minimalist Vim plugin manager.
<img src="https://raw.githubusercontent.com/junegunn/i/master/vim-plug/installer.gif" height="450">
## Pros.
### Pros.
- Minimalist design
- Just one file with no dependencies. Super easy to set up.
- Concise, intuitive syntax that you can learn within minutes. No boilerplate code required.
- No feature bloat
- Extremely stable with flawless backward compatibility
- Works perfectly with all versions of Vim since 2006 and all versions of Neovim ever released
- Easier to setup: Single file. No boilerplate code required.
- Easier to use: Concise, intuitive syntax
- [Super-fast][40/4] parallel installation/update
(with any of `+python`, `+python3`, `+ruby`, or [Neovim][nv])
- Creates shallow clones to minimize disk space usage and download time
- On-demand loading for [faster startup time][startup-time]
- Can review and rollback updates
@ -47,256 +19,107 @@ A minimalist Vim plugin manager.
- Support for externally managed plugins
[40/4]: https://raw.githubusercontent.com/junegunn/i/master/vim-plug/40-in-4.gif
[startup-time]: https://github.com/junegunn/vim-startuptime-benchmark#result
[nv]: http://neovim.org/
[startup-time]: http://junegunn.kr/images/vim-startup-time.png
## Installation
### Installation
[Download plug.vim](https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim)
and put it in the "autoload" directory.
<details>
<summary>Click to see the instructions</summary>
### Vim
#### Unix
###### Unix
```sh
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
```
You can automate the process by putting the command in your Vim configuration
file as suggested [here][auto].
[auto]: https://github.com/junegunn/vim-plug/wiki/tips#automatic-installation
#### Windows (PowerShell)
```powershell
iwr -useb https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |`
ni $HOME/vimfiles/autoload/plug.vim -Force
```
### Neovim
#### Unix, Linux
###### Neovim
```sh
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
```
#### Linux (Flatpak)
```sh
curl -fLo ~/.var/app/io.neovim.nvim/data/nvim/site/autoload/plug.vim --create-dirs \
curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
```
#### Windows (PowerShell)
###### Windows
```powershell
iwr -useb https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |`
ni "$(@($env:XDG_DATA_HOME, $env:LOCALAPPDATA)[$null -eq $env:XDG_DATA_HOME])/nvim-data/site/autoload/plug.vim" -Force
md ~\vimfiles\autoload
$uri = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
(New-Object Net.WebClient).DownloadFile($uri, (Resolve-Path ~\vimfiles\autoload\plug.vim))
```
</details>
### Usage
## Usage
Add a vim-plug section to your .vimrc:
Add a vim-plug section to your `~/.vimrc` (or `~/.config/nvim/init.vim` for Neovim)
1. Begin the section with `call plug#begin()`
1. Begin the section with `plug#begin()`
1. List the plugins with `Plug` commands
1. End the section with `call plug#end()`
1. `plug#end()` to add the plugins to `&runtimepath`
For example,
#### Example
```vim
call plug#begin()
" List your plugins here
Plug 'tpope/vim-sensible'
call plug#end()
```
Reload the file or restart Vim, then you can,
* `:PlugInstall` to install the plugins
* `:PlugUpdate` to install or update the plugins
* `:PlugDiff` to review the changes from the last update
* `:PlugClean` to remove plugins no longer in the list
> [!NOTE]
> That's basically all you need to know to get started. The rest of the
> document is for advanced users who want to know more about the features and
> options.
> [!TIP]
> `plug#end()` automatically executes `filetype plugin indent on` and `syntax
> enable`. We believe this is a good default for most users, but if you don't
> want this behavior, you can revert the settings after the call.
>
> ```vim
> call plug#end()
> filetype indent off " Disable file-type-specific indentation
> syntax off " Disable syntax highlighting
> ```
### Getting Help
- See [tutorial] page to learn more about the basics of vim-plug
- See [tips] and [FAQ] pages for common problems and questions
[tutorial]: https://github.com/junegunn/vim-plug/wiki/tutorial
[tips]: https://github.com/junegunn/vim-plug/wiki/tips
[FAQ]: https://github.com/junegunn/vim-plug/wiki/faq
## Examples
The following examples demonstrate the additional features of vim-plug.
### Vim script example
```vim
call plug#begin()
" The default plugin directory will be as follows:
" - Vim (Linux/macOS): '~/.vim/plugged'
" - Vim (Windows): '~/vimfiles/plugged'
" - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged'
" You can specify a custom plugin directory by passing it as the argument
" - e.g. `call plug#begin('~/.vim/plugged')`
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')
" Make sure you use single quotes
" Shorthand notation for GitHub; translates to https://github.com/junegunn/seoul256.vim.git
Plug 'junegunn/seoul256.vim'
Plug 'junegunn/vim-easy-align'
" Any valid git URL is allowed
Plug 'https://github.com/junegunn/vim-easy-align.git'
" Group dependencies, vim-snippets depends on ultisnips
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
" Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
Plug 'fatih/vim-go', { 'tag': '*' }
" Using a non-default branch
Plug 'neoclide/coc.nvim', { 'branch': 'release' }
" Use 'dir' option to install plugin in a non-default directory
Plug 'junegunn/fzf', { 'dir': '~/.fzf' }
" Post-update hook: run a shell command after installing or updating the plugin
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
" Post-update hook can be a lambda expression
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
" If the vim plugin is in a subdirectory, use 'rtp' option to specify its path
Plug 'nsf/gocode', { 'rtp': 'vim' }
" On-demand loading: loaded when the specified command is executed
Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
" On-demand loading: loaded when a file with a specific file type is opened
" On-demand loading
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
" Using git URL
Plug 'https://github.com/junegunn/vim-github-dashboard.git'
" Using a non-master branch
Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }
" Plugin options
Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }
" Plugin outside ~/.vim/plugged with post-update hook
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
" Unmanaged plugin (manually installed and updated)
Plug '~/my-prototype-plugin'
" Call plug#end to update &runtimepath and initialize the plugin system.
" - It automatically executes `filetype plugin indent on` and `syntax enable`
" Add plugins to &runtimepath
call plug#end()
" You can revert the settings after the call like so:
" filetype indent off " Disable file-type-specific indentation
" syntax off " Disable syntax highlighting
" Color schemes should be loaded after plug#end().
" We prepend it with 'silent!' to ignore errors when it's not yet installed.
silent! colorscheme seoul256
```
### Lua example for Neovim
Reload .vimrc and `:PlugInstall` to install plugins.
In Neovim, you can write your configuration in a Lua script file named
`init.lua`. The following code is the Lua script equivalent to the Vim script
example above.
```lua
local vim = vim
local Plug = vim.fn['plug#']
vim.call('plug#begin')
-- Shorthand notation for GitHub; translates to https://github.com/junegunn/seoul256.vim.git
Plug('junegunn/seoul256.vim')
-- Any valid git URL is allowed
Plug('https://github.com/junegunn/vim-easy-align.git')
-- Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
Plug('fatih/vim-go', { ['tag'] = '*' })
-- Using a non-default branch
Plug('neoclide/coc.nvim', { ['branch'] = 'release' })
-- Use 'dir' option to install plugin in a non-default directory
Plug('junegunn/fzf', { ['dir'] = '~/.fzf' })
-- Post-update hook: run a shell command after installing or updating the plugin
Plug('junegunn/fzf', { ['dir'] = '~/.fzf', ['do'] = './install --all' })
-- Post-update hook can be a lambda expression
Plug('junegunn/fzf', { ['do'] = function()
vim.fn['fzf#install']()
end })
-- If the vim plugin is in a subdirectory, use 'rtp' option to specify its path
Plug('nsf/gocode', { ['rtp'] = 'vim' })
-- On-demand loading: loaded when the specified command is executed
Plug('preservim/nerdtree', { ['on'] = 'NERDTreeToggle' })
-- On-demand loading: loaded when a file with a specific file type is opened
Plug('tpope/vim-fireplace', { ['for'] = 'clojure' })
-- Unmanaged plugin (manually installed and updated)
Plug('~/my-prototype-plugin')
vim.call('plug#end')
-- Color schemes should be loaded after plug#end().
-- We prepend it with 'silent!' to ignore errors when it's not yet installed.
vim.cmd('silent! colorscheme seoul256')
```
## Commands
### Commands
| Command | Description |
| ----------------------------------- | ------------------------------------------------------------------ |
| `PlugInstall [name ...] [#threads]` | Install plugins |
| `PlugUpdate [name ...] [#threads]` | Install or update plugins |
| `PlugClean[!]` | Remove unlisted plugins (bang version will clean without prompt) |
| `PlugClean[!]` | Remove unused directories (bang version will clean without prompt) |
| `PlugUpgrade` | Upgrade vim-plug itself |
| `PlugStatus` | Check the status of plugins |
| `PlugDiff` | Examine changes from the previous update and the pending changes |
| `PlugSnapshot[!] [output path]` | Generate script for restoring the current snapshot of the plugins |
## `Plug` options
### `Plug` options
| Option | Description |
| ----------------------- | ----------------------------------------------------------- |
| ----------------------- | ------------------------------------------------ |
| `branch`/`tag`/`commit` | Branch/tag/commit of the repository to use |
| `rtp` | Subdirectory that contains Vim plugin |
| `dir` | Custom directory for the plugin |
| `as` | Use different name for the plugin |
| `do` | Post-update hook (string or funcref) |
| `on` | On-demand loading: Commands or `<Plug>`-mappings |
| `for` | On-demand loading: File types |
| `frozen` | Do not remove and do not update unless explicitly specified |
| `frozen` | Do not update unless explicitly specified |
## Global options
### Global options
| Flag | Default | Description |
| ------------------- | --------------------------------- | ------------------------------------------------------ |
@ -304,100 +127,34 @@ vim.cmd('silent! colorscheme seoul256')
| `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_shallow` | 1 | Use shallow clone |
| `g:plug_window` | `-tabnew` | Command to open plug window |
| `g:plug_pwindow` | `vertical rightbelow new` | 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_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
### Keybindings
- `D` - `PlugDiff`
- `S` - `PlugStatus`
- `R` - Retry failed update or installation tasks
- `U` - Update plugins in the selected range
- `q` - Abort the running tasks or close the window
- `q` - Close the window
- `:PlugStatus`
- `L` - Load plugin
- `:PlugDiff`
- `X` - Revert the update
## Post-update hooks
There are some plugins that require extra steps after installation or update.
In that case, use the `do` option to describe the task to be performed.
### Example: A small [sensible](https://github.com/tpope/vim-sensible) Vim configuration
```vim
Plug 'Shougo/vimproc.vim', { 'do': 'make' }
Plug 'ycm-core/YouCompleteMe', { 'do': './install.py' }
call plug#begin()
Plug 'tpope/vim-sensible'
call plug#end()
```
If the value starts with `:`, it will be recognized as a Vim command.
```vim
Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
```
To call a Vim function, you can pass a lambda expression like so:
```vim
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
```
If you need more control, you can pass a reference to a Vim function that
takes a dictionary argument.
```vim
function! BuildYCM(info)
" info is a dictionary with 3 fields
" - name: name of the plugin
" - status: 'installed', 'updated', or 'unchanged'
" - force: set on PlugInstall! or PlugUpdate!
if a:info.status == 'installed' || a:info.force
!./install.py
endif
endfunction
Plug 'ycm-core/YouCompleteMe', { 'do': function('BuildYCM') }
```
A post-update hook is executed inside the directory of the plugin and only run
when the repository has changed, but you can force it to run unconditionally
with the bang-versions of the commands: `PlugInstall!` and `PlugUpdate!`.
> [!TIP]
> Make sure to escape BARs and double-quotes when you write the `do` option
> inline as they are mistakenly recognized as command separator or the start of
> the trailing comment.
>
> ```vim
> Plug 'junegunn/fzf', { 'do': 'yes \| ./install' }
> ```
>
> But you can avoid the escaping if you extract the inline specification using a
> variable (or any Vim script expression) as follows:
>
> ```vim
> let g:fzf_install = 'yes | ./install'
> Plug 'junegunn/fzf', { 'do': g:fzf_install }
> ```
### `PlugInstall!` and `PlugUpdate!`
The installer takes the following steps when installing/updating a plugin:
1. `git clone` or `git fetch` from its origin
2. Check out branch, tag, or commit and optionally `git merge` remote branch
3. If the plugin was updated (or installed for the first time)
1. Update submodules
2. Execute post-update hooks
The commands with the `!` suffix ensure that all steps are run unconditionally.
## On-demand loading of plugins
### On-demand loading of plugins
```vim
" NERD tree will be loaded on the first invocation of NERDTreeToggle command
Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
" Multiple commands
Plug 'junegunn/vim-github-dashboard', { 'on': ['GHDashboard', 'GHActivity'] }
@ -411,53 +168,75 @@ Plug 'kovisoft/paredit', { 'for': ['clojure', 'scheme'] }
" On-demand loading on both conditions
Plug 'junegunn/vader.vim', { 'on': 'Vader', 'for': 'vader' }
" Code to execute when the plugin is lazily loaded on demand
Plug 'junegunn/goyo.vim', { 'for': 'markdown' }
autocmd! User goyo.vim echom 'Goyo is now loaded!'
" Code to execute when the plugin is loaded on demand
Plug 'Valloric/YouCompleteMe', { 'for': 'cpp' }
autocmd! User YouCompleteMe call youcompleteme#Enable()
```
> [!NOTE]
> #### Should I set up on-demand loading?
>
> You probably don't need to.
>
> A properly implemented Vim plugin should already load lazily without any
> help from a plugin manager (`:help autoload`). So there are few cases where
> these options actually make much sense. Making a plugin load faster is
> the responsibility of the plugin developer, not the user. If you find
> a plugin that takes too long to load, consider opening an issue on the
> plugin's issue tracker.
>
> Let me give you a perspective. The time it takes to load a plugin is usually
> less than 2 or 3ms on modern computers. So unless you use a very large
> number of plugins, you are unlikely to save more than 50ms. If you have
> spent an hour carefully setting up the options to shave off 50ms, you
> will have to start Vim 72,000 times just to break even. You should ask
> yourself if that's a good investment of your time.
>
> Make sure that you're tackling the right problem by breaking down the
> startup time of Vim using `--startuptime`.
>
> ```sh
> vim --startuptime /tmp/log
> ```
>
> On-demand loading should only be used as a last resort. It is basically
> a hacky workaround and is not always guaranteed to work.
`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.
> [!TIP]
> You can pass an empty list to `on` or `for` option to disable the loading
> of the plugin. You can manually load the plugin using `plug#load(NAMES...)`
> function.
>
> See https://github.com/junegunn/vim-plug/wiki/tips#loading-plugins-manually
### Post-update hooks
There are some plugins that require extra steps after installation or update.
In that case, use `do` option to describe the task to be performed.
## Collaborators
```vim
Plug 'Shougo/vimproc.vim', { 'do': 'make' }
Plug 'Valloric/YouCompleteMe', { 'do': './install.py' }
```
- [Jan Edmund Lazo](https://github.com/janlazo) - Windows support
- [Jeremy Pallats](https://github.com/starcraftman) - Python installer
If you need more control, you can pass a reference to a Vim function that
takes a single argument.
## License
```vim
function! BuildYCM(info)
" info is a dictionary with 3 fields
" - name: name of the plugin
" - status: 'installed', 'updated', or 'unchanged'
" - force: set on PlugInstall! or PlugUpdate!
if a:info.status == 'installed' || a:info.force
!./install.py
endif
endfunction
Plug 'Valloric/YouCompleteMe', { 'do': function('BuildYCM') }
```
Both forms of post-update hook are executed inside the directory of the plugin
and only run when the repository has changed, but you can force it to run
unconditionally with the bang-versions of the commands: `PlugInstall!` and
`PlugUpdate!`.
Make sure to escape BARs and double-quotes when you write `do` option inline
as they are mistakenly recognized as command separator or the start of the
trailing comment.
```vim
Plug 'junegunn/fzf', { 'do': 'yes \| ./install' }
```
But you can avoid the escaping if you extract the inline specification using a
variable (or any Vimscript expression) as follows:
```vim
let g:fzf_install = 'yes | ./install'
Plug 'junegunn/fzf', { 'do': g:fzf_install }
```
### FAQ/Troubleshooting
See [FAQ/Troubleshooting](https://github.com/junegunn/vim-plug/wiki/faq).
### Articles
- [Writing my own Vim plugin manager](http://junegunn.kr/2013/09/writing-my-own-vim-plugin-manager)
- [Vim plugins and startup time](http://junegunn.kr/2014/07/vim-plugins-and-startup-time)
- ~~[Thoughts on Vim plugin dependency](http://junegunn.kr/2013/09/thoughts-on-vim-plugin-dependency)~~
- *Support for Plugfile has been removed since 0.5.0*
### License
MIT

View File

@ -1,428 +0,0 @@
plug.txt plug Last change: Jun 1 2024
PLUG - TABLE OF CONTENTS *plug* *plug-toc*
==============================================================================
vim-plug |vim-plug|
Pros. |plug-pros|
Installation |plug-installation|
Usage |plug-usage|
Getting Help |plug-getting-help|
Examples |plug-examples|
Vim script example |plug-vim-script-example|
Lua example for Neovim |plug-lua-example-for-neovim|
Commands |plug-commands|
Plug options |plug-options|
Global options |plug-global-options|
Keybindings |plug-keybindings|
Post-update hooks |plug-post-update-hooks|
PlugInstall! and PlugUpdate! |pluginstall-and-plugupdate|
On-demand loading of plugins |plug-on-demand-loading-of-plugins|
Collaborators |plug-collaborators|
License |plug-license|
VIM-PLUG *vim-plug*
==============================================================================
A minimalist Vim plugin manager.
PROS. *plug-pros*
==============================================================================
- Minimalist design
- Just one file with no dependencies. Super easy to set up.
- Concise, intuitive syntax that you can learn within minutes. No
boilerplate code required.
- No feature bloat
- Extremely stable with flawless backward compatibility
- Works perfectly with all versions of Vim since 2006 and all versions of
Neovim ever released
- {Super-fast}{1} parallel installation/update
- Creates shallow clones to minimize disk space usage and download time
- On-demand loading for {faster startup time}{2}
- Can review and rollback updates
- Branch/tag/commit support
- Post-update hooks
- Support for externally managed plugins
{1} https://raw.githubusercontent.com/junegunn/i/master/vim-plug/40-in-4.gif
{2} https://github.com/junegunn/vim-startuptime-benchmark#result
INSTALLATION *plug-installation*
==============================================================================
{Download plug.vim}{3} and put it in the "autoload" directory.
{3} https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
USAGE *plug-usage*
==============================================================================
Add a vim-plug section to your `~/.vimrc` (or `init.vim` for Neovim)
*plug#begin* *plug#end*
1. Begin the section with `callplug#begin()`
2. List the plugins with `Plug` commands
3. End the section with `callplug#end()`
For example,
>
call plug#begin()
" List your plugins here
Plug 'tpope/vim-sensible'
call plug#end()
<
Reload the file or restart Vim, then you can,
*:PlugInstall* *:PlugUpdate* *:PlugDiff*
- `:PlugInstall` to install the plugins
- `:PlugUpdate` to install or update the plugins
- `:PlugDiff` to review the changes from the last update
[!NOTE] That's basically all you need to know to get started. The rest of the
document is for advanced users who want to know more about the features and
options.
< Getting Help >______________________________________________________________~
*plug-getting-help*
- See {tutorial}{4} page to learn more about the basics of vim-plug
- See {tips}{5} and {FAQ}{6} pages for common problems and questions
{4} https://github.com/junegunn/vim-plug/wiki/tutorial
{5} https://github.com/junegunn/vim-plug/wiki/tips
{6} https://github.com/junegunn/vim-plug/wiki/faq
EXAMPLES *plug-examples*
==============================================================================
The following examples demonstrate the additional features of vim-plug.
< Vim script example >________________________________________________________~
*plug-vim-script-example*
>
call plug#begin()
" The default plugin directory will be as follows:
" - Vim (Linux/macOS): '~/.vim/plugged'
" - Vim (Windows): '~/vimfiles/plugged'
" - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged'
" You can specify a custom plugin directory by passing it as the argument
" - e.g. `call plug#begin('~/.vim/plugged')`
" - Avoid using standard Vim directory names like 'plugin'
" Make sure you use single quotes
" Shorthand notation for GitHub; translates to https://github.com/junegunn/seoul256.vim.git
Plug 'junegunn/seoul256.vim'
" Any valid git URL is allowed
Plug 'https://github.com/junegunn/vim-easy-align.git'
" Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
Plug 'fatih/vim-go', { 'tag': '*' }
" Using a non-default branch
Plug 'neoclide/coc.nvim', { 'branch': 'release' }
" Use 'dir' option to install plugin in a non-default directory
Plug 'junegunn/fzf', { 'dir': '~/.fzf' }
" Post-update hook: run a shell command after installing or updating the plugin
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
" Post-update hook can be a lambda expression
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
" If the vim plugin is in a subdirectory, use 'rtp' option to specify its path
Plug 'nsf/gocode', { 'rtp': 'vim' }
" On-demand loading: loaded when the specified command is executed
Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
" On-demand loading: loaded when a file with a specific file type is opened
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
" Unmanaged plugin (manually installed and updated)
Plug '~/my-prototype-plugin'
" Call plug#end to update &runtimepath and initialize the plugin system.
" - It automatically executes `filetype plugin indent on` and `syntax enable`
call plug#end()
" You can revert the settings after the call like so:
" filetype indent off " Disable file-type-specific indentation
" syntax off " Disable syntax highlighting
" Color schemes should be loaded after plug#end().
" We prepend it with 'silent!' to ignore errors when it's not yet installed.
silent! colorscheme seoul256
<
< Lua example for Neovim >____________________________________________________~
*plug-lua-example-for-neovim*
In Neovim, you can write your configuration in a Lua script file named
`init.lua`. The following code is the Lua script equivalent to the Vim script
example above.
>
local vim = vim
local Plug = vim.fn['plug#']
vim.call('plug#begin')
-- Shorthand notation for GitHub; translates to https://github.com/junegunn/seoul256.vim.git
Plug('junegunn/seoul256.vim')
-- Any valid git URL is allowed
Plug('https://github.com/junegunn/vim-easy-align.git')
-- Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
Plug('fatih/vim-go', { ['tag'] = '*' })
-- Using a non-default branch
Plug('neoclide/coc.nvim', { ['branch'] = 'release' })
-- Use 'dir' option to install plugin in a non-default directory
Plug('junegunn/fzf', { ['dir'] = '~/.fzf' })
-- Post-update hook: run a shell command after installing or updating the plugin
Plug('junegunn/fzf', { ['dir'] = '~/.fzf', ['do'] = './install --all' })
-- Post-update hook can be a lambda expression
Plug('junegunn/fzf', { ['do'] = function()
vim.fn['fzf#install']()
end })
-- If the vim plugin is in a subdirectory, use 'rtp' option to specify its path
Plug('nsf/gocode', { ['rtp'] = 'vim' })
-- On-demand loading: loaded when the specified command is executed
Plug('preservim/nerdtree', { ['on'] = 'NERDTreeToggle' })
-- On-demand loading: loaded when a file with a specific file type is opened
Plug('tpope/vim-fireplace', { ['for'] = 'clojure' })
-- Unmanaged plugin (manually installed and updated)
Plug('~/my-prototype-plugin')
vim.call('plug#end')
-- Color schemes should be loaded after plug#end().
-- We prepend it with 'silent!' to ignore errors when it's not yet installed.
vim.cmd('silent! colorscheme seoul256')
<
COMMANDS *plug-commands*
==============================================================================
-------------------------------------+------------------------------------------------------------------
Command | Description ~
-------------------------------------+------------------------------------------------------------------
`PlugInstall [name ...] [#threads]` | Install plugins
`PlugUpdate [name ...] [#threads]` | Install or update plugins
`PlugClean[!]` | Remove unlisted plugins (bang version will clean without prompt)
`PlugUpgrade` | Upgrade vim-plug itself
`PlugStatus` | Check the status of plugins
`PlugDiff` | Examine changes from the previous update and the pending changes
`PlugSnapshot[!] [output path]` | Generate script for restoring the current snapshot of the plugins
-------------------------------------+------------------------------------------------------------------
PLUG OPTIONS *plug-options*
==============================================================================
*<Plug>-mappings*
------------------------+------------------------------------------------------------
Option | Description ~
------------------------+------------------------------------------------------------
`branch` / `tag` / `commit` | Branch/tag/commit of the repository to use
`rtp` | Subdirectory that contains Vim plugin
`dir` | Custom directory for the plugin
`as` | Use different name for the plugin
`do` | Post-update hook (string or funcref)
`on` | On-demand loading: Commands or <Plug>-mappings
`for` | On-demand loading: File types
`frozen` | Do not remove and do not update unless explicitly specified
------------------------+------------------------------------------------------------
GLOBAL OPTIONS *plug-global-options*
==============================================================================
*g:plug_threads* *g:plug_timeout* *g:plug_retries* *g:plug_shallow* *g:plug_window*
*g:plug_pwindow* *g:plug_url_format*
--------------------+-----------------------------------+-----------------------------------------------------------------------------------
Flag | Default | Description ~
--------------------+-----------------------------------+-----------------------------------------------------------------------------------
`g:plug_threads` | 16 | Default number of threads to use
`g:plug_timeout` | 60 | Time limit of each task in seconds (Ruby & Python)
`g:plug_retries` | 2 | Number of retries in case of timeout (Ruby & Python)
`g:plug_shallow` | 1 | Use shallow clone
`g:plug_window` | `-tabnew` | Command to open plug window
`g:plug_pwindow` | `vertical rightbelow new` | 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)
--------------------+-----------------------------------+-----------------------------------------------------------------------------------
KEYBINDINGS *plug-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
- `:PlugDiff`
- `X` - Revert the update
POST-UPDATE HOOKS *plug-post-update-hooks*
==============================================================================
There are some plugins that require extra steps after installation or update.
In that case, use the `do` option to describe the task to be performed.
>
Plug 'Shougo/vimproc.vim', { 'do': 'make' }
Plug 'ycm-core/YouCompleteMe', { 'do': './install.py' }
<
If the value starts with `:`, it will be recognized as a Vim command.
>
Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
<
To call a Vim function, you can pass a lambda expression like so:
>
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
<
If you need more control, you can pass a reference to a Vim function that
takes a dictionary argument.
>
function! BuildYCM(info)
" info is a dictionary with 3 fields
" - name: name of the plugin
" - status: 'installed', 'updated', or 'unchanged'
" - force: set on PlugInstall! or PlugUpdate!
if a:info.status == 'installed' || a:info.force
!./install.py
endif
endfunction
Plug 'ycm-core/YouCompleteMe', { 'do': function('BuildYCM') }
<
A post-update hook is executed inside the directory of the plugin and only run
when the repository has changed, but you can force it to run unconditionally
with the bang-versions of the commands: `PlugInstall!` and `PlugUpdate!`.
[!TIP] Make sure to escape BARs and double-quotes when you write the `do`
option inline as they are mistakenly recognized as command separator or the
start of the trailing comment.
>
Plug 'junegunn/fzf', { 'do': 'yes \| ./install' }
<
But you can avoid the escaping if you extract the inline specification using a
variable (or any Vim script expression) as follows:
>
let g:fzf_install = 'yes | ./install'
Plug 'junegunn/fzf', { 'do': g:fzf_install }
<
< PlugInstall! and PlugUpdate! >______________________________________________~
*pluginstall-and-plugupdate*
The installer takes the following steps when installing/updating a plugin:
1. `git clone` or `git fetch` from its origin
2. Check out branch, tag, or commit and optionally `git merge` remote branch
3. If the plugin was updated (or installed for the first time)
1. Update submodules
2. Execute post-update hooks
The commands with the `!` suffix ensure that all steps are run
unconditionally.
ON-DEMAND LOADING OF PLUGINS *plug-on-demand-loading-of-plugins*
==============================================================================
>
" NERD tree will be loaded on the first invocation of NERDTreeToggle command
Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
" Multiple commands
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' }
" Code to execute when the plugin is lazily loaded on demand
Plug 'junegunn/goyo.vim', { 'for': 'markdown' }
autocmd! User goyo.vim echom 'Goyo is now loaded!'
<
[!NOTE] #### Should I set up on-demand loading?
You probably don't need to.
A properly implemented Vim plugin should already load lazily without any help
from a plugin manager (`:helpautoload`). So there are few cases where these
options actually make much sense. Making a plugin load faster is the
responsibility of the plugin developer, not the user. If you find a plugin
that takes too long to load, consider opening an issue on the plugin's issue
tracker.
Let me give you a perspective. The time it takes to load a plugin is usually
less than 2 or 3ms on modern computers. So unless you use a very large number
of plugins, you are unlikely to save more than 50ms. If you have spent an hour
carefully setting up the options to shave off 50ms, you will have to start Vim
72,000 times just to break even. You should ask yourself if that's a good
investment of your time.
Make sure that you're tackling the right problem by breaking down the startup
time of Vim using `--startuptime`.
>
vim --startuptime /tmp/log
<
On-demand loading should only be used as a last resort. It is basically a
hacky workaround and is not always guaranteed to work.
*plug#load*
[!TIP] You can pass an empty list to `on` or `for` option to disable the
loading of the plugin. You can manually load the plugin using
`plug#load(NAMES...)` function.
See https://github.com/junegunn/vim-plug/wiki/tips#loading-plugins-manually
COLLABORATORS *plug-collaborators*
==============================================================================
- {Jan Edmund Lazo}{7} - Windows support
- {Jeremy Pallats}{8} - Python installer
{7} https://github.com/janlazo
{8} https://github.com/starcraftman
LICENSE *plug-license*
==============================================================================
MIT
==============================================================================
vim:tw=78:sw=2:ts=2:ft=help:norl:nowrap:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

1395
plug.vim

File diff suppressed because it is too large Load Diff

View File

@ -1,41 +0,0 @@
Execute (plug#shellescape() works without optional arguments):
if has('unix')
AssertEqual "''", plug#shellescape("")
AssertEqual "'foo'\\'''", plug#shellescape("foo'")
endif
Execute (plug#shellescape() ignores invalid optional argument):
if has('unix')
AssertEqual "''", plug#shellescape("", '')
AssertEqual "'foo'\\'''", plug#shellescape("foo'", [])
endif
Execute (plug#shellescape() depends on the shell):
AssertEqual "'foo'\\'''", plug#shellescape("foo'", {'shell': 'sh'})
AssertEqual '^"foo''^"', plug#shellescape("foo'", {'shell': 'cmd.exe'})
AssertEqual "'foo'''", plug#shellescape("foo'", {'shell': 'powershell'})
AssertEqual "'foo'''", plug#shellescape("foo'", {'shell': 'powershell.exe'})
AssertEqual "'foo'''", plug#shellescape("foo'", {'shell': 'pwsh'})
Execute (plug#shellescape() supports non-trivial cmd.exe escaping):
" batchfile
AssertEqual '^"^^%%PATH^^%%^"', plug#shellescape("^%PATH^%", {
\ 'shell': 'cmd.exe',
\ })
AssertEqual '^"^^%%PATH^^%%^"', plug#shellescape("^%PATH^%", {
\ 'shell': 'cmd.exe',
\ 'script': 1,
\ })
" command prompt
AssertEqual '^"^^^%PATH^^^%^"', plug#shellescape("^%PATH^%", {
\ 'shell': 'cmd.exe',
\ 'script': 0,
\ }),
Execute (plug#shellescape() supports non-trivial powershell.exe escaping):
AssertEqual '''\"Foo\\''''\\Bar\"''', plug#shellescape('"Foo\''\Bar"', {
\ 'shell': 'powershell',
\ }),
AssertEqual '''\"Foo\\''''\\Bar\"''', plug#shellescape('"Foo\''\Bar"', {
\ 'shell': 'powershell.exe',
\ }),

View File

@ -1,6 +1,5 @@
**********************************************************************
Execute (#112 On-demand loading should not suppress messages from ftplugin):
call ResetPlug()
call plug#begin('$PLUG_FIXTURES')
Plug '$PLUG_FIXTURES/ftplugin-msg', { 'for': 'c' }
call plug#end()
@ -8,20 +7,19 @@ Execute (#112 On-demand loading should not suppress messages from ftplugin):
redir => out
tabnew a.c
redir END
Assert stridx(out, 'ftplugin-c') >= 0, 'Unexpected output (1): '.out
Assert stridx(out, 'ftplugin') >= 0
* The same applies to plug#load())
call ResetPlug()
redir => out
call plug#load('ftplugin-msg')
redir END
Assert stridx(out, 'ftplugin-c') >= 0, 'Unexpected output (2): '.out
Assert stridx(out, 'ftplugin') >= 0
q
**********************************************************************
Execute (#114 Should not contain empty path in &rtp):
call plug#begin('/tmp/vim-plug-test/plugged')
call plug#begin('/tmp/plugged')
call plug#end()
Log &rtp
@ -37,11 +35,10 @@ Execute (#130 Proper cleanup of on-demand loading triggers):
" Cleared on command
call ReloadPlug()
call plug#begin('/tmp/vim-plug-test/plugged')
call plug#begin('/tmp/plugged')
Plug 'junegunn/vim-emoji', { 'on': ['EmojiCommand', 'EmojiCommand2', '<Plug>(EmojiMapping)'] }
call plug#end()
PlugInstall | q
call mkdir(g:plugs['vim-emoji'].dir.'/after/plugin', 'p')
Assert exists(':EmojiCommand'), 'EmojiCommand not defined'
Assert exists(':EmojiCommand2'), 'EmojiCommand2 not defined'
@ -55,7 +52,7 @@ Execute (#130 Proper cleanup of on-demand loading triggers):
" Cleared on FileType
call ReloadPlug()
call plug#begin('/tmp/vim-plug-test/plugged')
call plug#begin('/tmp/plugged')
Plug 'junegunn/vim-emoji', { 'on': ['EmojiCommandExtra', '<Plug>(EmojiMappingExtra)'], 'for': ['emoji'] }
call plug#end()
@ -81,32 +78,31 @@ Execute (#131 Syntax error):
**********************************************************************
Execute (#139-1 Using new remote branch):
" Make sure to remove the clone
call plug#begin('/tmp/vim-plug-test/plugged')
call plug#begin('/tmp/plugged')
call plug#end()
PlugClean!
" Install master branch
call plug#begin('/tmp/vim-plug-test/plugged')
Plug expand('file:////tmp/vim-plug-test/new-branch')
call plug#begin('/tmp/plugged')
Plug expand('file:////tmp/new-branch')
call plug#end()
PlugUpdate
unlet! g:foo g:bar g:baz
call ResetPlug()
call plug#load('new-branch')
Assert exists('g:foo'), 'g:foo should be found (1)'
Assert !exists('g:bar'), 'g:bar should not be found (1)'
Assert !exists('g:baz'), 'g:baz should not be found (1)'
Assert exists('g:foo'), 'g:foo should be found'
Assert !exists('g:bar'), 'g:bar should not be found'
Assert !exists('g:baz'), 'g:baz should not be found'
" Create a new branch on origin
call system('cd /tmp/vim-plug-test/new-branch && git checkout -b new &&'
call system('cd /tmp/new-branch && git checkout -b new &&'
\. 'echo "let g:bar = 1" > plugin/bar.vim && git add plugin/bar.vim &&'
\. 'git commit -m second')
" We're setting up two plugins so that parallel installer is used
call plug#begin('/tmp/vim-plug-test/plugged')
call plug#begin('/tmp/plugged')
Plug 'junegunn/seoul256.vim'
Plug expand('file:////tmp/vim-plug-test/new-branch'), { 'branch': 'new' }
Plug expand('file:////tmp/new-branch'), { 'branch': 'new' }
call plug#end()
PlugUpdate
silent %y
@ -114,11 +110,10 @@ Execute (#139-1 Using new remote branch):
Assert @" !~? 'error', 'Should be able to use new remote branch: ' . @"
unlet! g:foo g:bar g:baz
call ResetPlug()
call plug#load('new-branch')
Assert exists('g:foo'), 'g:foo should be found (2)'
Assert exists('g:bar'), 'g:bar should be found (2)'
Assert !exists('g:baz'), 'g:baz should not be found (2)'
Assert exists('g:foo'), 'g:foo should be found'
Assert exists('g:bar'), 'g:bar should be found'
Assert !exists('g:baz'), 'g:baz should not be found'
call PlugStatusSorted()
@ -130,14 +125,14 @@ Expect:
Execute (#139-2 Using yet another new remote branch):
" Create another branch on origin
call system('cd /tmp/vim-plug-test/new-branch && git checkout master &&'
call system('cd /tmp/new-branch && git checkout master &&'
\. 'git checkout -b brand-new &&'
\. 'echo "let g:baz = 1" > plugin/baz.vim && git add plugin/baz.vim &&'
\. 'git commit -m third')
" Test Vim installer here
call plug#begin('/tmp/vim-plug-test/plugged')
Plug expand('file:////tmp/vim-plug-test/new-branch'), { 'branch': 'brand-new' }
call plug#begin('/tmp/plugged')
Plug expand('file:////tmp/new-branch'), { 'branch': 'brand-new' }
call plug#end()
PlugUpdate
silent %y
@ -145,7 +140,6 @@ Execute (#139-2 Using yet another new remote branch):
Assert @" !~? 'error', 'Should be able to use new remote branch: ' . @"
unlet! g:foo g:bar g:baz
call ResetPlug()
call plug#load('new-branch')
Assert exists('g:foo'), 'g:foo should be found'
Assert !exists('g:bar'), 'g:bar should not be found'
@ -160,19 +154,19 @@ Expect:
Execute (#139-3 Should fail when not possible to fast-forward):
" Commit on cloned repo
call system('cd /tmp/vim-plug-test/plugged/new-branch && git checkout master &&'
call system('cd /tmp/plugged/new-branch && git checkout master &&'
\. 'touch foobar && git add foobar && git commit -m foobar')
" Different commit on remote
call system('cd /tmp/vim-plug-test/new-branch && git checkout master &&'
call system('cd /tmp/new-branch && git checkout master &&'
\. 'touch foobaz && git add foobaz && git commit -m foobaz')
for multi in [0, 1]
call plug#begin('/tmp/vim-plug-test/plugged')
call plug#begin('/tmp/plugged')
if multi
Plug 'junegunn/seoul256.vim'
endif
Plug expand('file:////tmp/vim-plug-test/new-branch')
Plug expand('file:////tmp/new-branch')
call plug#end()
PlugUpdate
silent %y
@ -216,7 +210,7 @@ Execute (#159: shell=/bin/tcsh):
let org = &shell
try
set shell=/bin/tcsh
call plug#begin('/tmp/vim-plug-test/plugged')
call plug#begin('/tmp/plugged')
Plug 'junegunn/seoul256.vim'
call plug#end()
@ -230,21 +224,21 @@ Execute (#159: shell=/bin/tcsh):
**********************************************************************
Execute (#154: Spaces in &rtp should not be escaped):
call plug#begin('/tmp/vim-plug-test/plug it')
Plug 'foo/seoul256 vim'
call plug#begin('/tmp/plug it')
Plug 'seoul256 vim'
call plug#end()
Log &rtp
Assert stridx(&rtp, 'plug it/seoul256 vim') >= 0
**********************************************************************
Execute (#184: Duplicate entries in &rtp):
call plug#begin('/tmp/vim-plug-test/plugged')
Plug 'foo/plugin1'
\| Plug 'foo/plugin0'
call plug#begin('/tmp/plugged')
Plug 'plugin1'
\| Plug 'plugin0'
Plug 'foo/plugin2'
\| Plug 'foo/plugin0'
\| Plug 'foo/plugin1'
Plug 'plugin2'
\| Plug 'plugin0'
\| Plug 'plugin1'
call plug#end()
Log &rtp
@ -256,7 +250,7 @@ Execute (#236: Plugin removed from &rtp when .vimrc is reloaded):
silent! delc EasyAlign
call ReloadPlug()
call plug#begin('/tmp/vim-plug-test/plugged')
call plug#begin('/tmp/plugged')
Plug 'junegunn/vim-easy-align', { 'on': 'EasyAlign' }
call plug#end()
PlugInstall | q
@ -265,19 +259,19 @@ Execute (#236: Plugin removed from &rtp when .vimrc is reloaded):
%EasyAlign=
Assert &rtp =~ '/vim-easy-align', 'Plugin should be in &rtp'
call plug#begin('/tmp/vim-plug-test/plugged')
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'
**********************************************************************
Execute (#350: Ruby installer failed to unshallow tagged plugin on update):
call plug#begin('/tmp/vim-plug-test/plugged')
call plug#begin('/tmp/plugged')
call plug#end()
PlugClean!
" Shallow clone. We should have at least 2 plugins to enable parallel installer.
call plug#begin('/tmp/vim-plug-test/plugged')
call plug#begin('/tmp/plugged')
Plug 'junegunn/vim-easy-align'
Plug 'junegunn/seoul256.vim'
call plug#end()
@ -285,91 +279,10 @@ Execute (#350: Ruby installer failed to unshallow tagged plugin on update):
Assert filereadable(g:plugs['vim-easy-align'].dir.'/.git/shallow')
" Now unshallowed
call plug#begin('/tmp/vim-plug-test/plugged')
call plug#begin('/tmp/plugged')
Plug 'junegunn/vim-easy-align', { 'tag': '2.9.0' }
Plug 'junegunn/seoul256.vim'
call plug#end()
PlugUpdate
Assert !filereadable(g:plugs['vim-easy-align'].dir.'/.git/shallow')
q
**********************************************************************
Execute (#474: Load ftdetect files in filetypedetect augroup):
call plug#begin('/tmp/vim-plug-test/plugged')
Plug 'junegunn/rust.vim', { 'for': 'rust', 'commit': '115d321d383eb96d438466c56cc871fcc1bd0faa' }
call plug#end()
PlugInstall!
q
tabnew /tmp/vim-plug-test/any.rs
AssertEqual 'rust', &filetype
Log &filetype
filetype detect
AssertEqual 'rust', &filetype
Log &filetype
bd
**********************************************************************
Execute (#489/#587 On-demand loading with 'on' option should trigger BufRead autocmd w/o nomodeline):
call plug#begin('$PLUG_FIXTURES')
Plug 'foo/ftplugin-msg', { 'on': 'XXX' }
call plug#end()
tabnew a.java
call setline(1, '// vim: set filetype=lava:')
redir => out
silent! XXX
redir END
Assert stridx(out, 'ftplugin-java') >= 0
AssertEqual 'lava', &filetype
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
**********************************************************************
Execute (#593 Add plugin to &rtp before running post-update hook with : prefix):
call ReloadPlug()
call plug#begin()
Plug 'junegunn/vim-pseudocl', { 'on': 'XXX', 'do': ':let g:bar = pseudocl#complete#extract_words(''a b'')' }
call plug#end()
PlugInstall!
AssertEqual ['a', 'b'], g:bar
**********************************************************************
Execute (#602 Confusion with branch name and path name):
call plug#begin()
Plug expand('file:////tmp/vim-plug-test/new-branch'), { 'branch': 'plugin' }
call plug#end()
PlugUpdate
call PlugStatusSorted()
Expect:
- new-branch: OK
Finished. 0 error(s).
[=]
**********************************************************************
Execute (PlugStatus showed error with wildcard tag):
call plug#begin()
Plug 'junegunn/vim-easy-align', { 'tag': '*' }
call plug#end()
PlugUpdate
call PlugStatusSorted()
Expect:
- vim-easy-align: OK
Finished. 0 error(s).
[=]

View File

@ -1,32 +1,25 @@
#!/bin/bash
# Privileged mode, ignores $CDPATH etc.
set -p
set -eu
cd "$(dirname "${BASH_SOURCE[0]}")"
cd $(dirname "${BASH_SOURCE[0]}")
export BASE="$PWD"
export PLUG_SRC="$PWD/../plug.vim"
export PLUG_FIXTURES="$PWD/fixtures"
mkdir -p "$PLUG_FIXTURES"
export TEMP=/tmp/vim-plug-test
rm -rf "$TEMP"
mkdir -p "$TEMP"
cat > $TEMP/mini-vimrc << VIMRC
set rtp+=$TEMP/junegunn/vader.vim
cat > /tmp/mini-vimrc << VIMRC
set rtp+=/tmp/junegunn/vader.vim
set shell=/bin/bash
VIMRC
clone() {
if [ ! -d "$2" ]; then
git clone "$1" "$2"
if [ ! -d $2 ]; then
git clone $1 $2
fi
}
clone_repos() (
cd $TEMP
cd /tmp
mkdir -p junegunn vim-scripts jg
for repo in vader.vim goyo.vim rust.vim seoul256.vim vim-easy-align vim-fnr \
vim-oblique vim-pseudocl vim-redis vim-emoji; do
@ -34,8 +27,6 @@ clone_repos() (
done
clone https://github.com/vim-scripts/beauty256.git vim-scripts/beauty256 &
clone https://github.com/junegunn/fzf.git fzf &
clone https://github.com/yous/subsubmodule.git yous/subsubmodule && \
(cd yous/subsubmodule && git submodule update --init --recursive &) &
wait
clone junegunn/vim-emoji jg/vim-emoji
@ -48,8 +39,8 @@ make_dirs() (
cd "$PLUG_FIXTURES/$1"
mkdir -p autoload colors ftdetect ftplugin indent plugin syntax
for d in *; do
[ -d "$d" ] || continue
cat > "$d/xxx.vim" << EOF
[ -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', [])
@ -62,7 +53,7 @@ EOF
gitinit() (
cd "$PLUG_FIXTURES/$1"
git init -b master
git init
git commit -m 'commit' --allow-empty
)
@ -77,42 +68,30 @@ DOC
make_dirs yyy/ yyy
make_dirs yyy/after yyy
mkdir -p "$PLUG_FIXTURES/yyy/rtp/doc"
cat > "$PLUG_FIXTURES/yyy/rtp/doc/yyy.txt" << DOC
hello *yyy*
DOC
gitinit yyy
make_dirs z1/ z1
make_dirs z2/ z2
rm -rf "$PLUG_FIXTURES/ftplugin-msg"
mkdir -p "$PLUG_FIXTURES"/ftplugin-msg/{plugin,ftplugin}
echo "echomsg 'ftplugin-c'" > "$PLUG_FIXTURES/ftplugin-msg/ftplugin/c.vim"
echo "echomsg 'ftplugin-java'" > "$PLUG_FIXTURES/ftplugin-msg/ftplugin/java.vim"
mkdir -p "$PLUG_FIXTURES/ftplugin-msg/ftplugin"
echo "echomsg 'ftplugin'" > "$PLUG_FIXTURES/ftplugin-msg/ftplugin/c.vim"
chmod +w "$PLUG_FIXTURES/cant-delete/autoload" || rm -rf "$PLUG_FIXTURES/cant-delete"
mkdir -p "$PLUG_FIXTURES/cant-delete/autoload"
touch "$PLUG_FIXTURES/cant-delete/autoload/cant-delete.vim"
chmod -w "$PLUG_FIXTURES/cant-delete/autoload"
rm -rf $TEMP/new-branch
cd $TEMP
git init new-branch -b master
rm -rf /tmp/new-branch
cd /tmp
git init new-branch
cd new-branch
mkdir plugin
echo 'let g:foo = 1' > plugin/foo.vim
git add plugin/foo.vim
git commit -m initial
git checkout -b plugin
git checkout master
cd "$BASE"
}
select_vim() {
local vim=/usr/bin/vim
if [ -n "${DEPS:-}" ] && [ -e "${DEPS}/bin/vim" ]; then
if [ -n "$DEPS" ] && [ -e "${DEPS}/bin/vim" ]; then
vim="${DEPS}/bin/vim"
elif [ -e "/usr/local/bin/vim" ]; then
vim=/usr/local/bin/vim
@ -123,15 +102,13 @@ select_vim() {
clone_repos
prepare
git --version
vim=$(select_vim)
echo "Selected Vim: $vim"
if [ "${1:-}" = '!' ]; then
FAIL=0
$vim -Nu $TEMP/mini-vimrc -c 'Vader! test.vader' > /dev/null || FAIL=1
prepare
$vim -Nu $TEMP/mini-vimrc -c 'let g:plug_threads = 1 | Vader! test.vader' > /dev/null || FAIL=1
test $FAIL -eq 0
VIM=$(select_vim)
echo "Selected Vim: $VIM"
if [ "$1" = '!' ]; then
$VIM -Nu /tmp/mini-vimrc -c 'Vader! test.vader' > /dev/null &&
prepare &&
$VIM -Nu /tmp/mini-vimrc -c 'let g:plug_threads = 1 | Vader! test.vader' > /dev/null
else
$vim -Nu $TEMP/mini-vimrc -c 'Vader test.vader'
$VIM -Nu /tmp/mini-vimrc -c 'Vader test.vader'
fi

View File

@ -2,7 +2,7 @@ Execute (Initialize test environment):
Save &rtp, g:plugs, g:plug_home, g:plug_window
unlet! g:plugs g:plug_home g:plug_window
let g:plug_url_format = 'file:///tmp/vim-plug-test/%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]
@ -10,15 +10,11 @@ Execute (Initialize test environment):
if !exists('$PLUG_SRC')
let $PLUG_SRC = globpath(&rtp, 'autoload/plug.vim')
endif
let $PLUG_TMP = fnamemodify(tempname(), ':h').'/plug.vim'
" Temporarily patch plug.vim
call system('cp "$PLUG_SRC" "$PLUG_TMP"')
let patch =
\ ['function! ResetPlug()', 'let s:loaded = {}', 'endfunction',
\ 'function! CompareURI(a, b)', 'return s:compare_git_uri(a:a, a:b)', 'endfunction']
call writefile(extend(readfile($PLUG_TMP), patch), $PLUG_TMP)
call system('cp $PLUG_SRC $PLUG_SRC.org')
call writefile(extend(readfile($PLUG_SRC),
\ ['function! ResetPlug()', 'let s:loaded = {}', 'endfunction']), $PLUG_SRC)
set t_Co=256
colo default
@ -33,10 +29,9 @@ Execute (Initialize test environment):
g/^$/d
endfunction
function! AssertExpect(bang, pat, cnt, ...)
function! AssertExpect(bang, pat, cnt)
let op = a:bang ? '==#' : '=~#'
let args = [a:cnt, len(filter(getline(1, '$'), "v:val ".op." '".a:pat."'"))] + a:000
call call('vader#assert#equal', args)
AssertEqual a:cnt, len(filter(getline(1, '$'), "v:val ".op." '".a:pat."'"))
endfunction
command! -nargs=+ -bang AssertExpect call AssertExpect('<bang>' == '!', <args>)
@ -52,41 +47,26 @@ Execute (Initialize test environment):
function! ReloadPlug()
call ResetPlug()
source $PLUG_TMP
source $PLUG_SRC
let &rtp = g:base_rtp
endfunction
function! GitBranch(repo)
return system(printf('cd %s && git rev-parse --abbrev-ref HEAD', g:plugs[a:repo].dir))[:-2]
endfunction
function! GitTag(repo)
return system(printf('cd %s && git describe --tags', g:plugs[a:repo].dir))[:-2]
endfunction
function! GitCommit(repo)
return system(printf('cd %s && git rev-parse HEAD', g:plugs[a:repo].dir))[:-2]
endfunction
source $PLUG_TMP
source $PLUG_SRC
Execute (Print Interpreter Version):
redir => out
if has('ruby')
silent! ruby puts 'Ruby: ' + RUBY_VERSION
endif
if has('python')
silent! python import sys; svi = sys.version_info; print 'Python: {}.{}.{}'.format(svi[0], svi[1], svi[2])
endif
if has('python3')
silent! python3 import sys; svi = sys.version_info; print('Python: {}.{}.{}'.format(svi[0], svi[1], svi[2]))
silent ruby puts 'Ruby: ' + RUBY_VERSION
elseif has('python')
silent python import sys; svi = sys.version_info; print 'Python: {}.{}.{}'.format(svi[0], svi[1], svi[2])
elseif has('python3')
silent python3 import sys; svi = sys.version_info; print('Python: {}.{}.{}'.format(svi[0], svi[1], svi[2]))
endif
redir END
Log split(out, '\n')
Log substitute(out, '\n', '', 'g')
Include: workflow.vader
Include: regressions.vader
Include: functional.vader
Execute (Cleanup):
silent! call RmRf(g:temp_plugged)
@ -100,7 +80,7 @@ Execute (Cleanup):
silent! delc AssertExpect
silent! unmap /
silent! unmap ?
call delete($PLUG_TMP)
call system('mv $PLUG_SRC.org $PLUG_SRC')
Restore

View File

@ -2,7 +2,7 @@ Execute (plug#end() before plug#begin() should fail):
redir => out
silent! AssertEqual 0, plug#end()
redir END
Assert stridx(out, 'plug#end() called without calling plug#begin() first') >= 0
Assert stridx(out, 'Call plug#begin() first') >= 0
Execute (plug#begin() without path argument):
call plug#begin()
@ -19,13 +19,6 @@ Execute (plug#begin() without path argument with empty &rtp):
let &rtp = save_rtp
unlet save_rtp
Execute (Standard runtime path is not allowed):
redir => out
silent! AssertEqual 0, plug#begin(split(&rtp, ',')[0].'/plugin')
redir END
Log out
Assert stridx(out, 'Invalid plug home') >= 0
Execute (plug#begin(path)):
call plug#begin(g:temp_plugged.'/')
Assert g:plug_home !~ '[/\\]$', 'Trailing / should be stripped from g:plug_home'
@ -41,7 +34,7 @@ Execute (Subsequent plug#begin() calls will reuse g:plug_home):
Execute (Test Plug command):
^ Git repo with branch (DEPRECATED. USE BRANCH OPTION)
Plug 'junegunn/seoul256.vim', { 'branch': 'yes-t_co' }
AssertEqual 'file:///tmp/vim-plug-test/junegunn/seoul256.vim', g:plugs['seoul256.vim'].uri
AssertEqual 'file:///tmp/junegunn/seoul256.vim', g:plugs['seoul256.vim'].uri
AssertEqual join([g:temp_plugged, 'seoul256.vim/'], '/'), g:plugs['seoul256.vim'].dir
AssertEqual 'yes-t_co', g:plugs['seoul256.vim'].branch
@ -49,62 +42,29 @@ Execute (Test Plug command):
AssertEqual 'no-t_co', g:plugs['seoul256.vim'].branch
^ Git repo with tag (DEPRECATED. USE TAG OPTION)
redir => out
silent Plug 'foo/bar.vim', ''
redir END
Assert out =~ 'Invalid argument for "tag" option of :Plug (expected: string)'
Plug 'junegunn/goyo.vim', '1.5.2'
AssertEqual 'file:///tmp/vim-plug-test/junegunn/goyo.vim', g:plugs['goyo.vim'].uri
AssertEqual 'file:///tmp/junegunn/goyo.vim', g:plugs['goyo.vim'].uri
AssertEqual join([g:temp_plugged, 'goyo.vim/'], '/'), g:plugs['goyo.vim'].dir
AssertEqual '1.5.2', g:plugs['goyo.vim'].tag
redir => out
silent Plug 'foo/bar.vim', {'tag': ''}
redir END
Assert out =~ 'Invalid argument for "tag" option of :Plug (expected: string)'
Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' } " Using tag option
AssertEqual '1.5.3', g:plugs['goyo.vim'].tag
" Git URI
Plug 'file:///tmp/vim-plug-test/jg/vim-emoji'
AssertEqual 'file:///tmp/vim-plug-test/jg/vim-emoji', g:plugs['vim-emoji'].uri
AssertEqual '', g:plugs['vim-emoji'].branch
Plug 'file:///tmp/jg/vim-emoji'
AssertEqual 'file:///tmp/jg/vim-emoji', g:plugs['vim-emoji'].uri
AssertEqual 'master', g:plugs['vim-emoji'].branch
AssertEqual join([g:temp_plugged, 'vim-emoji/'], '/'), g:plugs['vim-emoji'].dir
" vim-scripts/
Plug 'vim-scripts/beauty256'
AssertEqual 'file:///tmp/vim-plug-test/vim-scripts/beauty256', g:plugs.beauty256.uri
AssertEqual '', g:plugs.beauty256.branch
Plug 'beauty256'
AssertEqual 'file:///tmp/vim-scripts/beauty256', g:plugs.beauty256.uri
AssertEqual 'master', g:plugs.beauty256.branch
AssertEqual 4, len(g:plugs)
redir => out
Plug 'beauty256'
redir END
Assert out =~ 'Invalid argument: beauty256'
Execute (Plug command with dictionary option):
Log string(g:plugs)
for opt in ['branch', 'tag', 'commit', 'rtp', 'dir', 'as']
let opts = {}
let opts[opt] = ''
redir => out
silent Plug 'foo/bar.vim', opts
redir END
Assert out =~ 'Invalid argument for "'.opt.'" option of :Plug (expected: string)'
endfor
for opt in ['on', 'for']
let opts = {}
let opts[opt] = ''
redir => out
silent Plug 'foo/bar.vim', opts
redir END
Assert out =~ 'Invalid argument for "'.opt.'" option of :Plug (expected: string or list)'
endfor
redir => out
silent Plug 'foo/bar.vim', {'do': ''}
redir END
Assert out =~ 'Invalid argument for "do" option of :Plug (expected: string or funcref)'
Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co', 'rtp': '././' }
AssertEqual join([g:temp_plugged, 'seoul256.vim/'], '/'), g:plugs['seoul256.vim'].dir
AssertEqual '././', g:plugs['seoul256.vim'].rtp
@ -123,10 +83,6 @@ Execute (PlugClean before installation):
q
Execute (plug#end() updates &rtp):
" Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' }
" Plug 'file:///tmp/vim-plug-test/jg/vim-emoji'
" Plug 'beauty256'
" Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co', 'rtp': '././' }
call plug#end()
Assert len(&rtp) > len(g:base_rtp)
AssertEqual g:first_rtp, split(&rtp, ',')[0]
@ -199,7 +155,7 @@ Expect:
Execute (Change branch of seoul256.vim):
call plug#begin()
Plug 'junegunn/seoul256.vim'
Plug 'file:///tmp/vim-plug-test/jg/vim-emoji'
Plug 'file:///tmp/jg/vim-emoji'
call plug#end()
Execute (PlugStatus):
@ -237,39 +193,21 @@ Expect:
Execute (Change URI of seoul256.vim):
call plug#begin()
Plug 'junegunn.choi/seoul256.vim'
Plug 'file:///tmp/vim-plug-test/jg/vim-emoji'
Plug 'file:///tmp/jg/vim-emoji'
call plug#end()
Execute (PlugStatus):
call PlugStatusSorted()
Expect:
Expected: file:///tmp/vim-plug-test/junegunn.choi/seoul256.vim
Invalid URI: file:///tmp/vim-plug-test/junegunn/seoul256.vim
Expected: file:///tmp/junegunn.choi/seoul256.vim
Invalid URI: file:///tmp/junegunn/seoul256.vim
PlugClean required.
- vim-emoji: OK
Finished. 1 error(s).
[==]
x seoul256.vim:
Execute (Corrected the URI but ahead of upstream):
call plug#begin()
Plug 'junegunn/seoul256.vim'
Plug 'file:///tmp/vim-plug-test/jg/vim-emoji'
call plug#end()
for _ in range(3)
call system(printf('cd "%s" && git commit --allow-empty -m "dummy"', g:plugs['seoul256.vim'].dir))
endfor
call PlugStatusSorted()
Expect:
Ahead of origin/master by 3 commit(s).
Cannot update until local changes are pushed.
- vim-emoji: OK
Finished. 1 error(s).
[==]
x seoul256.vim:
# TODO: does not work due to inputsave()
# Do (PlugClean):
# :PlugClean\<Enter>y\<Enter>
@ -277,45 +215,11 @@ Expect:
# q
# PGdd
Execute (PlugClean! keeps seoul256.vim):
Execute (PlugClean! to remove seoul256.vim):
PlugClean!
" Two removed, emoji and seoul256 left
AssertEqual 'Removed 2 directories.', getline(4)
AssertExpect '^\~ ', 2
AssertExpect 'Diverged', 0
Assert !empty(globpath(&rtp, 'colors/seoul256.vim'))
Assert !empty(globpath(&rtp, 'autoload/emoji.vim'))
q
Execute (Make seoul256 to be diverged):
call plug#begin()
Plug 'junegunn/seoul256.vim'
Plug 'file:///tmp/vim-plug-test/jg/vim-emoji'
call plug#end()
call system(printf(join([
\ 'cd "%s"',
\ 'git fetch --unshallow',
\ 'git reset "@{u}~1"',
\ 'git commit --allow-empty -m "diverged1"',
\ 'git commit --allow-empty -m "diverged2"'], ' && '),
\ g:plugs['seoul256.vim'].dir))
Assert empty(v:shell_error), 'Got shell error: '.v:shell_error
call PlugStatusSorted()
Expect:
Backup local changes and run PlugClean and PlugUpdate to reinstall it.
Diverged from origin/master (2 commit(s) ahead and 1 commit(s) behind!
- vim-emoji: OK
Finished. 1 error(s).
[==]
x seoul256.vim:
Execute (PlugClean! removes seoul256.vim):
PlugClean!
" One removed, emoji left
AssertEqual 'Removed 1 directories.', getline(4)
AssertExpect '^\~ ', 1
AssertExpect 'Diverged', 1
" Three removed, emoji left
AssertExpect '^- ', 3
AssertExpect 'Removed', 1
Assert empty(globpath(&rtp, 'colors/seoul256.vim'))
Assert !empty(globpath(&rtp, 'autoload/emoji.vim'))
q
@ -330,8 +234,8 @@ Execute (PlugStatus):
call PlugStatusSorted()
Expect:
Expected: file:///tmp/vim-plug-test/junegunn/vim-emoji
Invalid URI: file:///tmp/vim-plug-test/jg/vim-emoji
Expected: file:///tmp/junegunn/vim-emoji
Invalid URI: file:///tmp/jg/vim-emoji
Not found. Try PlugInstall.
PlugClean required.
Finished. 2 error(s).
@ -341,10 +245,10 @@ Expect:
Execute (PlugClean! to remove vim-emoji):
PlugClean!
AssertExpect '^\~ ', 1
AssertEqual 'Removed 1 directories.', getline(4)
Assert empty(globpath(&rtp, 'colors/seoul256.vim')), 'seoul256.vim was removed'
Assert empty(globpath(&rtp, 'autoload/emoji.vim')), 'emoji was removed'
AssertExpect '^- ', 1
AssertExpect 'Removed', 1
Assert empty(globpath(&rtp, 'colors/seoul256.vim'))
Assert empty(globpath(&rtp, 'autoload/emoji.vim'))
q
Execute (PlugUpdate to install both again):
@ -356,7 +260,7 @@ Execute (PlugUpdate to install both again):
Execute (PlugUpdate only to find out plugins are up-to-date, D key to check):
PlugUpdate
AssertExpect 'Already up.to.date', 2, 'Expected 2 times "Already up-to-date", but got: '.string(getline(1, '$'))
AssertExpect 'Already up-to-date', 2
normal D
AssertEqual '0 plugin(s) updated.', getline(1)
q
@ -371,12 +275,9 @@ Execute (PlugDiff - 'No updates.'):
q
Execute (New commits on remote, PlugUpdate, then PlugDiff):
let g:plug_window = 'vertical topleft new'
let g:plug_pwindow = 'above 12new'
for repo in ['seoul256.vim', 'vim-emoji']
for _ in range(2)
call system(printf('cd /tmp/vim-plug-test/junegunn/%s && git commit --allow-empty -m "update"', repo))
call system(printf('cd /tmp/junegunn/%s && git commit --allow-empty -m "update"', repo))
endfor
endfor
unlet repo
@ -385,7 +286,6 @@ Execute (New commits on remote, PlugUpdate, then PlugDiff):
" Now we have updates
normal D
AssertEqual '2 plugin(s) updated.', getline(1)
AssertThrows execute('/gpg')
" Preview commit
silent! wincmd P
@ -396,29 +296,14 @@ Execute (New commits on remote, PlugUpdate, then PlugDiff):
let lnum = line('.')
AssertEqual 3, col('.')
" Open full diff (empty)
execute "normal \<cr>"
wincmd P
AssertEqual 1, &previewwindow
AssertEqual 'git', &filetype
AssertEqual [''], getline(1, '$')
pclose
" Open commit preview
execute "normal j\<cr>"
wincmd P
AssertEqual 1, &previewwindow
AssertEqual 'git', &filetype
" Close preview window
pclose
" Open and go to preview window with a custom mapping
nmap <buffer> <c-o> <plug>(plug-preview)<c-w>P
execute "normal \<c-o>"
AssertEqual 1, &previewwindow, 'Should be on preview window'
normal q
AssertEqual 0, &previewwindow, 'Should not be on preview window'
" Back to plug window
wincmd p
" ]] motion
execute 'normal $]]'
@ -439,17 +324,13 @@ Execute (New commits on remote, PlugUpdate, then PlugDiff):
execute "normal Xy\<cr>"
AssertExpect '^- ', 1
" q will only close preview window
" q will close preview window as well
normal q
" We no longer have preview window
silent! wincmd P
AssertEqual 0, &previewwindow
" And we're still on main vim-plug window
AssertEqual 'vim-plug', &filetype
normal q
" q should not close preview window if it's already open
pedit
PlugDiff
@ -461,50 +342,6 @@ Execute (New commits on remote, PlugUpdate, then PlugDiff):
AssertEqual 1, &previewwindow
pclose
unlet g:plug_window g:plug_pwindow
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
" Close preview window
normal q
" Close main window
normal q
unlet g:plug_pwindow
Execute (#572 - Commit preview should work with non-POSIX-compliant &shell):
" Invalid shell
let shell = &shell
set shell=shellfish
try
" Preview commit should still work
PlugDiff
execute "normal ]]jo"
wincmd P
Log getline(1, '$')
Assert getline(1) =~ 'commit', 'Preview window is empty'
AssertEqual 'shellfish', &shell
finally
" Restore &shell
let &shell = shell
unlet shell
pclose
q
endtry
Execute (Reuse Plug window in another tab):
let tabnr = tabpagenr()
PlugDiff
@ -588,51 +425,6 @@ Execute (PlugDiff):
Assert !empty(mapcheck("\<cr>"))
q
Execute (Do not show diff for commits outside of rtp):
call plug#begin()
call plug#end()
PlugClean!
call plug#begin()
Plug 'file://'.expand('$PLUG_FIXTURES').'/xxx'
Plug 'file://'.expand('$PLUG_FIXTURES').'/yyy', { 'rtp': 'rtp' }
call plug#end()
PlugInstall
Log getline(1, '$')
call system('cd "$PLUG_FIXTURES/xxx" && git commit --allow-empty -m update-xxx && git tag -f xxx')
call system('cd "$PLUG_FIXTURES/yyy" && git commit --allow-empty -m update-yyy && git tag -f yyy')
let g:plugs.yyy.tag = 'yyy'
PlugUpdate
Log getline(1, '$')
PlugDiff
" 1 plugin(s) updated.
" [==]
"
" Last update:
" ------------
"
" - xxx:
" * 7faa9b2 update-xxx (0 seconds ago)
"
" Pending updates:
" ----------------
"
" N/A
"
Log getline(1, '$')
AssertEqual 14, line('$')
AssertEqual '1 plugin(s) updated.', getline(1)
AssertEqual '[==]', getline(2)
AssertEqual 'Last update:', getline(4)
AssertEqual '- xxx:', getline(7)
Assert !empty(mapcheck('o'))
Assert !empty(mapcheck('X'))
Assert !empty(mapcheck("\<cr>"))
q
**********************************************************************
~ On-demand loading / Partial installation/update ~
**********************************************************************
@ -640,7 +432,7 @@ Execute (Do not show diff for commits outside of rtp):
Execute (Trying to execute on-demand commands when plugin is not installed):
call ReloadPlug()
call plug#begin()
Plug 'junegunn/vim-easy-align', { 'on': ['EasyAlign', 'LiveEasyAlign!'] }
Plug 'junegunn/vim-easy-align', { 'on': ['EasyAlign', 'LiveEasyAlign'] }
call plug#end()
Assert exists(':EasyAlign')
@ -781,7 +573,7 @@ Execute (PlugStatus should point out that the plugin is missing):
Execute (Deploy unmanaged plugin):
Assert !exists(':FZF'), ':FZF command should not exist'
call RmRf(fzf)
Log system(printf('cp -r "/tmp/vim-plug-test/fzf" "%s"', fzf))
Log system(printf('cp -r "/tmp/fzf" "%s"', fzf))
Execute (PlugUpdate still should not care):
PlugUpdate
@ -804,14 +596,6 @@ Execute (Check &rtp after SomeCommand):
AssertEqual g:first_rtp, split(&rtp, ',')[0]
AssertEqual g:last_rtp, split(&rtp, ',')[-1]
Execute (PlugClean should not care about frozen plugins):
call plug#begin()
Plug 'xxx/vim-easy-align', { 'frozen': 1 }
call plug#end()
PlugClean
AssertExpect 'Already clean', 1
q
Execute (Common parent):
call plug#begin()
Plug 'junegunn/vim-pseudocl'
@ -937,9 +721,6 @@ Execute (On install):
call plug#begin()
Plug 'junegunn/vim-easy-align', { 'do': 'touch installed' }
Plug 'junegunn/vim-pseudocl'
Plug 'junegunn/seoul256.vim'
Plug 'junegunn/goyo.vim'
Plug 'yous/subsubmodule'
call plug#end()
silent PlugInstall
@ -949,20 +730,15 @@ Execute (On install):
\ 'vim-easy-align/installed should exist'
Assert !filereadable(g:plugs['vim-pseudocl'].dir.'/installed'),
\ 'vim-pseudocl/installed should not exist'
AssertEqual ' ', system('cd '.g:plugs['subsubmodule'].dir.' && git submodule status')[0],
\ 'subsubmodule/subsubmodule should be initialized'
Execute (On update):
call plug#begin()
Plug 'junegunn/vim-easy-align', { 'do': 'touch updated' }
Plug 'junegunn/vim-pseudocl', { 'do': 'touch updated' }
Plug 'junegunn/seoul256.vim'
Plug 'junegunn/goyo.vim'
Plug 'yous/subsubmodule'
call plug#end()
" New commits on remote
call system('cd /tmp/vim-plug-test/junegunn/vim-pseudocl && git commit --allow-empty -m "update"')
call system('cd /tmp/junegunn/vim-pseudocl && git commit --allow-empty -m "update"')
silent PlugUpdate
Log getline(1, '$')
@ -976,74 +752,44 @@ Execute (On update):
Execute (When already installed):
call plug#begin()
Plug 'junegunn/vim-easy-align', { 'do': 'touch installed2' }
Plug 'junegunn/vim-pseudocl', { 'commit': '7f8cd78' }
Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co' }
Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' }
Plug 'yous/subsubmodule'
Plug 'junegunn/vim-pseudocl', { 'do': 'touch installed2' }
call plug#end()
PlugInstall
q
Assert !filereadable(g:plugs['vim-easy-align'].dir.'/installed2'),
\ 'vim-easy-align/installed2 should not exist'
AssertNotEqual '7f8cd78cb1fe52185b98b16a3749811f0cc508af', GitCommit('vim-pseudocl')
AssertNotEqual 'no-t_co', GitBranch('seoul256.vim')
AssertNotEqual '1.5.3', GitTag('goyo.vim')
Assert !filereadable(g:plugs['vim-pseudocl'].dir.'/installed2'),
\ 'vim-pseudocl/installed2 should not exist'
Execute (PlugInstall!):
silent PlugInstall!
q
Assert filereadable(g:plugs['vim-easy-align'].dir.'/installed2'),
\ 'vim-easy-align/installed2 should exist'
AssertEqual '7f8cd78cb1fe52185b98b16a3749811f0cc508af', GitCommit('vim-pseudocl')
" Was updated to the default branch of origin by previous PlugUpdate
AssertEqual 'master', GitBranch('seoul256.vim')
AssertEqual '1.5.3', GitTag('goyo.vim')
Execute (When submodules are not initialized):
call system(printf('cd %s && git submodule deinit subsubmodule', g:plugs['subsubmodule'].dir))
silent PlugInstall!
q
AssertEqual ' ', system(printf('cd %s && git submodule status', g:plugs['subsubmodule'].dir))[0],
\ 'subsubmodule/subsubmodule should be initialized'
Assert filereadable(g:plugs['vim-pseudocl'].dir.'/installed2'),
\ 'vim-pseudocl/installed2 should exist'
Execute (When already updated):
call plug#begin()
Plug 'junegunn/vim-easy-align', { 'do': 'touch updated2' }
Plug 'junegunn/vim-pseudocl', { 'commit': 'dd507ca' }
Plug 'junegunn/seoul256.vim', { 'branch': 'master' }
Plug 'junegunn/goyo.vim', { 'tag': '1.6.0' }
Plug 'yous/subsubmodule'
Plug 'junegunn/vim-pseudocl', { 'do': 'touch updated2' }
call plug#end()
PlugUpdate
q
Assert !filereadable(g:plugs['vim-easy-align'].dir.'/updated2'),
\ 'vim-easy-align/updated2 should not exist'
AssertEqual 'dd507ca0d5f3fdf0d522558cc5ecffdabf824469', GitCommit('vim-pseudocl')
AssertEqual 'master', GitBranch('seoul256.vim')
AssertEqual '1.6.0', GitTag('goyo.vim')
Assert !filereadable(g:plugs['vim-pseudocl'].dir.'/updated2'),
\ 'vim-pseudocl/updated2 should not exist'
Execute (PlugUpdate!):
silent PlugUpdate!
q
Assert filereadable(g:plugs['vim-easy-align'].dir.'/updated2'),
\ 'vim-easy-align/updated2 should exist'
Execute (When submodules are not initialized):
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!
let &shell = sh
unlet sh
q
AssertEqual ' ', system(printf('cd %s && git submodule status', g:plugs['subsubmodule'].dir))[0],
\ 'subsubmodule/subsubmodule should be initialized'
Assert filereadable(g:plugs['vim-pseudocl'].dir.'/updated2'),
\ 'vim-pseudocl/updated2 should exist'
Execute (Using Funcref):
function! PlugUpdated(info)
@ -1055,7 +801,7 @@ Execute (Using Funcref):
Plug 'junegunn/vim-pseudocl', { 'do': function('PlugUpdated') }
call plug#end()
call system('cd /tmp/vim-plug-test/junegunn/vim-easy-align && git commit --allow-empty -m "update"')
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 RmRf(g:plugs['vim-pseudocl'].dir)
@ -1096,10 +842,9 @@ Execute (Post-update hook output; success and failure):
Execute (Post-update hook output; invalid type or funcref):
call plug#begin()
Plug 'junegunn/vim-easy-align', { 'do': ':echo 1' }
Plug 'junegunn/vim-easy-align', { 'do': 1 }
Plug 'junegunn/vim-pseudocl', { 'do': function('call') }
call plug#end()
let g:plugs['vim-easy-align'].do = 1
silent PlugInstall! 1
AssertEqual 'x Post-update hook for vim-pseudocl ... Vim(call):E119: Not enough arguments for function: call', getline(5)
@ -1116,8 +861,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))
" New commits on remote
call system('cd /tmp/vim-plug-test/junegunn/vim-easy-align && git commit --allow-empty -m "update"')
call system('cd /tmp/vim-plug-test/junegunn/vim-pseudocl && git commit --allow-empty -m "update"')
call system('cd /tmp/junegunn/vim-easy-align && git commit --allow-empty -m "update"')
call system('cd /tmp/junegunn/vim-pseudocl && git commit --allow-empty -m "update"')
silent PlugUpdate
Log getline(1, '$')
@ -1128,52 +873,18 @@ Execute (Should not run when failed to update):
Assert filereadable(g:plugs['vim-pseudocl'].dir.'/not-failed'),
\ '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
Execute (Vim command with : prefix closing the window):
call plug#begin()
Plug 'junegunn/vim-pseudocl', { 'do': ':close' }
call plug#end()
redir => out
PlugInstall!
redir END
Assert out =~ 'vim-plug was terminated'
Assert out =~ 'of vim-pseudocl'
Execute (Invalid vim command in post-update hook):
call plug#begin()
Plug 'junegunn/vim-pseudocl', { 'do': ':nosuchcommand' }
call plug#end()
PlugInstall!
Log getline(1, '$')
AssertExpect! 'x Post-update hook for vim-pseudocl ... Vim:E492: Not an editor command: nosuchcommand', 1
q
**********************************************************************
~ Overriding `dir`
**********************************************************************
Execute (Using custom dir):
call plug#begin()
Plug 'junegunn/vim-easy-align'
call plug#end()
Assert isdirectory(g:plugs['vim-easy-align'].dir)
call RmRf('/tmp/vim-plug-test/easy-align')
call RmRf('/tmp/easy-align')
call plug#begin()
Plug 'junegunn/vim-easy-align', { 'dir': '/tmp/vim-plug-test/easy-align' }
Plug 'junegunn/vim-easy-align', { 'dir': '/tmp/easy-align' }
call plug#end()
AssertEqual '/tmp/vim-plug-test/easy-align/', g:plugs['vim-easy-align'].dir
AssertEqual '/tmp/easy-align/', g:plugs['vim-easy-align'].dir
PlugClean!
Assert !isdirectory(g:plugs['vim-easy-align'].dir)
@ -1224,17 +935,12 @@ Execute (Filetype-based on-demand loading):
call ReloadPlug()
call plug#begin()
Plug '$PLUG_FIXTURES/xxx', { 'for': 'xxx' }
Plug '$PLUG_FIXTURES/yyy', { 'for': 'yyy' }
call plug#end()
AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect'], g:xxx
setf xxx
AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect', 'xxx/plugin', 'xxx/after/plugin', 'xxx/syntax', 'xxx/after/syntax', 'xxx/ftplugin', 'xxx/after/ftplugin', 'xxx/indent', 'xxx/after/indent'], g:xxx
" syntax/xxx.vim and after/syntax/xxx.vim should not be loaded (#410)
setf yyy
AssertEqual ['yyy/ftdetect', 'yyy/after/ftdetect', 'yyy/plugin', 'yyy/after/plugin'], g:yyy
AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect', 'xxx/plugin', 'xxx/after/plugin', 'xxx/syntax', 'xxx/after/syntax', 'xxx/ftplugin', 'xxx/after/ftplugin', 'xxx/indent', 'xxx/after/indent', 'xxx/syntax', 'xxx/after/syntax'], g:xxx
Before:
@ -1243,28 +949,16 @@ Before:
**********************************************************************
Execute (plug#helptags):
call plug#begin()
Plug '$PLUG_FIXTURES/xxx'
Plug '$PLUG_FIXTURES/yyy', { 'rtp': 'rtp' }
call plug#end()
silent! call delete(expand('$PLUG_FIXTURES/xxx/doc/tags'))
silent! call delete(expand('$PLUG_FIXTURES/yyy/rtp/doc/tags'))
Assert !filereadable(expand('$PLUG_FIXTURES/xxx/doc/tags'))
Assert !filereadable(expand('$PLUG_FIXTURES/yyy/rtp/doc/tags'))
AssertEqual 1, plug#helptags()
Assert filereadable(expand('$PLUG_FIXTURES/xxx/doc/tags'))
Assert filereadable(expand('$PLUG_FIXTURES/yyy/rtp/doc/tags'))
**********************************************************************
~ Manual loading
**********************************************************************
Execute (plug#load - invalid arguments):
call ResetPlug()
call plug#begin()
Plug '$PLUG_FIXTURES/xxx', { 'for': 'xxx' }
Plug '$PLUG_FIXTURES/yyy', { 'for': 'yyy' }
call plug#end()
AssertEqual 0, plug#load()
AssertEqual 0, plug#load('non-existent-plugin')
AssertEqual 0, plug#load('non-existent-plugin', 'another-non-existent-plugin')
@ -1272,12 +966,6 @@ Execute (plug#load - invalid arguments):
AssertEqual 0, plug#load('xxx', 'non-existent-plugin')
AssertEqual 0, plug#load('non-existent-plugin', 'xxx')
Execute (plug#load - list argument (#638)):
redir => out
call plug#load(keys(g:plugs))
redir END
AssertEqual '', out
Execute (on: []):
call plug#begin()
Plug 'junegunn/rust.vim', { 'on': [] }
@ -1304,8 +992,6 @@ Execute (PlugStatus should not contain (not loaded)):
q
Execute (Load plugin from PlugStatus screen with L key in normal mode):
call ResetPlug()
unlet! g:yyy
call plug#begin()
Plug '$PLUG_FIXTURES/yyy', { 'on': [] }
call plug#end()
@ -1372,7 +1058,7 @@ Execute (Using g:plug_url_format):
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 'vim-scripts/beauty256'
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
let g:plug_url_format = prev_plug_url_format
@ -1503,16 +1189,15 @@ Execute (PlugClean should not try to remove unmanaged plugins inside g:plug_home
Plug '$PLUG_FIXTURES/fzf'
Plug '$PLUG_FIXTURES/xxx'
Plug '$PLUG_FIXTURES/yyy'
Plug '$PLUG_FIXTURES/cant-delete'
call plug#end()
" Remove z1, z2
PlugClean!
AssertExpect '^\~ ', 2
AssertExpect '^- ', 2
AssertExpect 'Already clean', 0
PlugClean!
AssertExpect '^\~ ', 0
AssertExpect '^- ', 0
AssertExpect 'Already clean', 1
q
@ -1604,21 +1289,15 @@ Execute (#221 Shallow-clone disabled by tag):
cd -
Execute (Commit hash support):
" Get goyo back to master
call plug#begin(g:temp_plugged)
Plug 'junegunn/goyo.vim'
call plug#end()
PlugUpdate
call plug#begin(g:temp_plugged)
Plug 'junegunn/goyo.vim', { 'commit': 'ffffffff' }
Plug 'junegunn/vim-emoji', { 'commit': '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a' }
call plug#end()
PlugUpdate
Log getline(1, '$')
AssertEqual 'x goyo.vim:', getline(5)
AssertEqual ' fatal: invalid reference: ffffffff', getline(6)
AssertEqual 0, stridx(getline(7), '- vim-emoji: HEAD is now at 9db7fcf')
AssertEqual ['x Checking out fffffff of goyo.vim ... Error',
\' error: pathspec ''ffffffff'' did not match any file(s) known to git.',
\'- Checking out 9db7fcf of vim-emoji ... OK'], getline(5, 7)
let hash = system(printf('cd %s && git rev-parse HEAD', g:plugs['vim-emoji'].dir))[:-2]
AssertEqual '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a', hash
@ -1642,12 +1321,10 @@ Execute (Commit hash support):
Assert empty(mapcheck('X'))
Assert !empty(mapcheck("\<cr>"))
" The exact hash values in PlugSnapshot output
" Nor in PlugSnapshot output
PlugSnapshot
Log getline(1, '$')
AssertEqual "silent! let g:plugs['goyo.vim'].commit = 'ffffffff'", getline(6)
AssertEqual "silent! let g:plugs['vim-emoji'].commit = '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a'", getline(7)
AssertEqual 10, line('$')
AssertEqual 8, line('$')
q
Execute (Commit hash support - cleared):
@ -1664,124 +1341,3 @@ Execute (Commit hash support - cleared):
let hash = system(printf('cd %s && git rev-parse HEAD', g:plugs['vim-emoji'].dir))[:-2]
AssertNotEqual '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a', hash
q
Execute (#371 - 'as' option):
call plug#begin()
Plug 'jg/goyo.vim'
Plug 'junegunn/goyo.vim', {'as': 'yogo'}
call plug#end()
AssertEqual ['goyo.vim', 'yogo'], sort(keys(g:plugs))
Log g:plugs
Assert g:plugs.yogo.dir =~# '/yogo/$'
call plug#begin()
Plug 'junegunn/goyo.vim', {'as': 'yogo', 'dir': '/tmp/vim-plug-test/gogo'}
call plug#end()
AssertEqual ['yogo'], sort(keys(g:plugs))
AssertEqual '/tmp/vim-plug-test/gogo/', g:plugs.yogo.dir
Execute (#427 - Tag option with wildcard (requires git 1.9.2 or above)):
if str2nr(split(split(system('git --version'))[-1], '\.')[0]) < 2
Log 'tag with wildcard requires git 1.9.2 or above'
else
call plug#begin()
Plug 'junegunn/vim-easy-align', { 'tag': '2.9.*' }
call plug#end()
PlugInstall!
Log getline(1, '$')
AssertExpect! '- Latest tag for 2.9.* -> 2.9.7 (vim-easy-align)', 1
q
AssertEqual '2.9.7', GitTag('vim-easy-align')
endif
Execute (#530 - Comparison of compatible git URIs):
" .git suffix
Assert CompareURI('https://github.com/junegunn/vim-plug.git', 'https://github.com/junegunn/vim-plug')
" user@
Assert CompareURI('https://github.com/junegunn/vim-plug.git', 'https://user@github.com/junegunn/vim-plug.git')
" git::@
Assert CompareURI('https://github.com/junegunn/vim-plug.git', 'https://git::@github.com/junegunn/vim-plug.git')
" https and ssh
Assert CompareURI('https://github.com/junegunn/vim-plug.git', 'git@github.com:junegunn/vim-plug.git')
" file://
Assert CompareURI('file:///tmp/vim-plug', '/tmp/vim-plug')
Assert CompareURI('file:///tmp/vim-plug', '/tmp/vim-plug/')
Execute (#530 - Comparison of incompatible git URIs):
" Different hostname
Assert !CompareURI('https://github.com/junegunn/vim-plug.git', 'https://bitbucket.com/junegunn/vim-plug.git')
" Different repository
Assert !CompareURI('https://github.com/junegunn/vim-plug.git', 'https://github.com/junegunn/emacs-plug.git')
" Different port
Assert !CompareURI('https://github.com/junegunn/vim-plug.git', 'https://github.com:12345/junegunn/vim-plug.git')
Execute (#532 - Reuse plug window):
let g:plug_window = 'vertical topleft new'
let g:plug_pwindow = 'above 12new'
call plug#begin()
Plug 'junegunn/goyo.vim'
call plug#end()
PlugInstall
call system(printf('cd "%s" && git commit --allow-empty -m "dummy"', g:plugs['goyo.vim'].dir))
PlugDiff
AssertEqual 1, winnr(), 'Current window is #1 after PlugDiff (but is '.winnr().')'
AssertEqual 2, winnr('$'), 'Two windows after PlugDiff (but got '.winnr('$').')'
" Open preview window
execute "normal ]]jo"
AssertEqual 2, winnr(), 'Current window is #2 after opening preview (but is '.winnr().')'
AssertEqual 3, winnr('$'), 'Three windows with preview (but got '.winnr('$').')'
" Move plug window to the right
wincmd L
AssertEqual 3, winnr(), 'Current window is #3 after moving window (but is '.winnr().')'
AssertEqual 3, winnr('$'), 'Three windows after moving window (but got '.winnr('$').')'
" Reuse plug window. Preview window is closed.
PlugStatus
AssertEqual 2, winnr(), 'Current window is #2 after PlugStatus (but is '.winnr().')'
AssertEqual 2, winnr('$'), 'Three windows after PlugStatus (but got '.winnr('$').')'
q
unlet g:plug_window g:plug_pwindow
Execute (#766 - Allow cloning into an empty directory):
let d = '/tmp/vim-plug-test/goyo-already'
call system('rm -rf ' . d)
call mkdir(d)
call plug#begin()
Plug 'junegunn/goyo.vim', { 'dir': d }
call plug#end()
PlugInstall
AssertExpect! '[=]', 1
q
unlet d
Execute (#982 - PlugClean should report when directories cannot be removed):
call plug#begin('$PLUG_FIXTURES')
Plug '$PLUG_FIXTURES/ftplugin-msg', { 'for': [] }
Plug '$PLUG_FIXTURES/fzf'
Plug '$PLUG_FIXTURES/xxx'
Plug '$PLUG_FIXTURES/yyy'
call plug#end()
" Fail to remove cant-delete
PlugClean!
AssertEqual 'Removed 0 directories. Failed to remove 1 directories.', getline(4)
AssertExpect '^x ', 1
q
" Delete tmp but fail to remove cant-delete
call mkdir(expand('$PLUG_FIXTURES/tmp'))
PlugClean!
AssertEqual 'Removed 1 directories. Failed to remove 1 directories.', getline(4)
AssertExpect '^x ', 1
AssertExpect '^\~ ', 1
q