1 Commits

Author SHA1 Message Date
Junegunn Choi
d7f1846932 Deferred loading on autocmd (#event[#pattern])
e.g.
    Plug 'SirVer/ultisnips',  { 'on': '#InsertEnter' }
    Plug 'junegunn/goyo.vim', { 'on': ['Goyo', '#BufEnter#README'] }
2016-10-29 18:00:58 +09:00
14 changed files with 320 additions and 1621 deletions

1
.github/FUNDING.yml vendored
View File

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

View File

@@ -10,12 +10,7 @@ Explain the problem here ...
------------------------------ ------------------------------
<!-- Paste your Plug block (from `call plug#begin()` to `call plug#end()`) --> <!-- Put the contents of `:version` below -->
```
```
<!-- Paste the contents of `:version` below -->
``` ```
``` ```
@@ -29,7 +24,7 @@ Explain the problem here ...
- OS: - OS:
- [ ] All/Other - [ ] All/Other
- [ ] Linux - [ ] Linux
- [ ] macOS - [ ] OS X
- [ ] Windows - [ ] Windows
- Vim: - Vim:
- [ ] Terminal Vim - [ ] Terminal Vim

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,60 @@
language: minimal language: ruby
sudo: required
env: env:
global: global:
- DEPS=$HOME/deps - DEPS=$HOME/deps
- PATH=$DEPS/bin:$PATH - PATH=$DEPS/bin:$PATH
jobs: matrix:
include: include:
- env: ENV=vim80-bionic - env: ENV=vim72
dist: bionic rvm: 1.8.7
stage: vim8 addons: { apt: { packages: [vim-nox] } }
- env: ENV=vim-nightly - env: ENV=python
dist: trusty rvm: 1.8.7
stage: vim8 addons: { apt: { packages: [python2.7-dev] } }
- env: ENV=neovim-stable - env: ENV=python3
dist: bionic rvm: 1.8.7
addons: {apt: {packages: [neovim], sources: [{sourceline: 'ppa:neovim-ppa/stable'}]}} addons: { apt: { packages: [python3-dev] } }
stage: neovim - env: ENV=ruby18
- env: ENV=neovim-nightly rvm: 1.8.7
dist: bionic - env: ENV=ruby20
addons: {apt: {packages: [neovim], sources: [{sourceline: 'ppa:neovim-ppa/unstable'}]}} rvm: 2.0.0
stage: neovim - env: ENV=neovim
- env: ENV=vim74-trusty-python - env: ENV=vim8
dist: trusty
stage: vim74
- env: ENV=vim74-xenial-python3
dist: xenial
stage: vim74
- env: ENV=vim74-trusty-ruby
dist: trusty
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
install: | install: |
git config --global user.email "you@example.com" git config --global user.email "you@example.com"
git config --global user.name "Your Name" git config --global user.name "Your Name"
if [ "$ENV" == "vim72" ]; then
mkdir -p ${DEPS}/bin
ln -s /usr/bin/vim.nox ${DEPS}/bin/vim
return
elif [ "$ENV" == "neovim" ]; then
# https://github.com/neovim/neovim/wiki/Installing-Neovim
sudo apt-get install -y software-properties-common
sudo add-apt-repository -y ppa:neovim-ppa/unstable
sudo apt-get update -y
sudo apt-get install -y neovim
mkdir -p ${DEPS}/bin
ln -s /usr/bin/nvim ${DEPS}/bin/vim
return
fi
C_OPTS="--prefix=$DEPS --with-features=huge --disable-gui " C_OPTS="--prefix=$DEPS --with-features=huge --disable-gui "
case "$ENV" in case "$ENV" in
vim-*) python)
C_OPTS+=--enable-pythoninterp
;; ;;
neovim-*) python3)
mkdir -p ${DEPS}/bin C_OPTS+=--enable-python3interp
ln -s /usr/bin/nvim ${DEPS}/bin/vim
export VADER_OUTPUT_FILE=/dev/stderr
return
;; ;;
vim74-* | vim80-*) ruby*)
mkdir -p ${DEPS}/bin C_OPTS+=--enable-rubyinterp
ln -s /usr/bin/vim.nox ${DEPS}/bin/vim
return
;;
*)
return
;; ;;
esac esac
git clone --depth 1 https://github.com/vim/vim git clone --depth 1 https://github.com/vim/vim
cd vim cd vim
export PATH=/usr/bin:$PATH
./configure $C_OPTS ./configure $C_OPTS
make make
make install 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.

207
README.md
View File

@@ -1,22 +1,4 @@
<div align="center"> <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)
<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>
<img src="https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.png" height="75" alt="vim-plug">[![build](https://img.shields.io/github/actions/workflow/status/junegunn/vim-plug/test.yml?branch=master)](https://github.com/junegunn/vim-plug/actions/workflows/test.yml?query=branch%3Amaster)
=== ===
A minimalist Vim plugin manager. A minimalist Vim plugin manager.
@@ -25,8 +7,8 @@ A minimalist Vim plugin manager.
### Pros. ### Pros.
- Easy to set up: Single file. No boilerplate code required. - Easier to setup: Single file. No boilerplate code required.
- Easy to use: Concise, intuitive syntax - Easier to use: Concise, intuitive syntax
- [Super-fast][40/4] parallel installation/update - [Super-fast][40/4] parallel installation/update
(with any of `+job`, `+python`, `+python3`, `+ruby`, or [Neovim][nv]) (with any of `+job`, `+python`, `+python3`, `+ruby`, or [Neovim][nv])
- Creates shallow clones to minimize disk space usage and download time - Creates shallow clones to minimize disk space usage and download time
@@ -38,15 +20,13 @@ A minimalist Vim plugin manager.
[40/4]: https://raw.githubusercontent.com/junegunn/i/master/vim-plug/40-in-4.gif [40/4]: https://raw.githubusercontent.com/junegunn/i/master/vim-plug/40-in-4.gif
[nv]: http://neovim.org/ [nv]: http://neovim.org/
[startup-time]: https://github.com/junegunn/vim-startuptime-benchmark#result [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) [Download plug.vim](https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim)
and put it in the "autoload" directory. and put it in the "autoload" directory.
#### Vim
###### Unix ###### Unix
```sh ```sh
@@ -54,74 +34,42 @@ curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
``` ```
You can automate the process by putting the command in your Vim configuration ###### Neovim
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
```sh ```sh
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/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'
```
###### Linux (Flatpak)
```sh
curl -fLo ~/.var/app/io.neovim.nvim/data/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
``` ```
###### Windows (PowerShell) ###### Windows (PowerShell)
```powershell ```powershell
iwr -useb https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |` md ~\vimfiles\autoload
ni "$(@($env:XDG_DATA_HOME, $env:LOCALAPPDATA)[$null -eq $env:XDG_DATA_HOME])/nvim-data/site/autoload/plug.vim" -Force $uri = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
(New-Object Net.WebClient).DownloadFile($uri, $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("~\vimfiles\autoload\plug.vim"))
``` ```
### Getting Help ### Getting Help
- See [tutorial] page to learn the basics of vim-plug - See the [requirements] page for debugging information & tested configurations.
- See [tips] and [FAQ] pages for common problems and questions - See the [FAQ] for common problems and questions.
- See [requirements] page for debugging information & tested configurations - Create an [issue](https://github.com/junegunn/vim-plug/issues/new).
- Create an [issue](https://github.com/junegunn/vim-plug/issues/new)
[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 [FAQ]: https://github.com/junegunn/vim-plug/wiki/faq
[requirements]: https://github.com/junegunn/vim-plug/wiki/requirements [requirements]: https://github.com/junegunn/vim-plug/wiki/requirements
### Usage ### Usage
Add a vim-plug section to your `~/.vimrc` (or `stdpath('config') . '/init.vim'` for Neovim) Add a vim-plug section to your `~/.vimrc` (or `~/.config/nvim/init.vim` for Neovim):
1. Begin the section with `call plug#begin([PLUGIN_DIR])` 1. Begin the section with `call plug#begin()`
1. List the plugins with `Plug` commands 1. List the plugins with `Plug` commands
1. `call plug#end()` to update `&runtimepath` and initialize plugin system 1. `call plug#end()` to update `&runtimepath` and initialize plugin system
- Automatically executes `filetype plugin indent on` and `syntax enable`.
You can revert the settings after the call. e.g. `filetype indent off`, `syntax off`, etc.
#### Example #### Example
```vim ```vim
call plug#begin() call plug#begin('~/.vim/plugged')
" 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 " Make sure you use single quotes
@@ -131,14 +79,14 @@ Plug 'junegunn/vim-easy-align'
" Any valid git URL is allowed " Any valid git URL is allowed
Plug 'https://github.com/junegunn/vim-github-dashboard.git' Plug 'https://github.com/junegunn/vim-github-dashboard.git'
" Multiple Plug commands can be written in a single line using | separators " Group dependencies, vim-snippets depends on ultisnips
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets' Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
" On-demand loading " On-demand loading
Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' } Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' } Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
" Using a non-default branch " Using a non-master branch
Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' } Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }
" Using a tagged release; wildcard allowed (requires git 1.9.2 or above) " Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
@@ -153,70 +101,19 @@ Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
" Unmanaged plugin (manually installed and updated) " Unmanaged plugin (manually installed and updated)
Plug '~/my-prototype-plugin' Plug '~/my-prototype-plugin'
" Initialize plugin system " Add plugins to &runtimepath
" - Automatically executes `filetype plugin indent on` and `syntax enable`.
call plug#end() 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
``` ```
Reload .vimrc and `:PlugInstall` to install plugins. Reload .vimrc and `:PlugInstall` to install plugins.
#### Example (Lua configuration 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 VimScript
example above.
```lua
local vim = vim
local Plug = vim.fn['plug#']
vim.call('plug#begin')
-- Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug('junegunn/vim-easy-align')
-- Any valid git URL is allowed
Plug('https://github.com/junegunn/vim-github-dashboard.git')
-- Multiple Plug commands can be written in a single line using ; separators
Plug('SirVer/ultisnips'); Plug('honza/vim-snippets')
-- On-demand loading
Plug('preservim/nerdtree', { ['on'] = 'NERDTreeToggle' })
Plug('tpope/vim-fireplace', { ['for'] = 'clojure' })
-- Using a non-default branch
Plug('rdnetto/YCM-Generator', { ['branch'] = 'stable' })
-- Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
Plug('fatih/vim-go', { ['tag'] = '*' })
-- 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')
vim.call('plug#end')
```
More examples can be found in:
* https://gitlab.com/sultanahamer/dotfiles/-/blob/master/nvim/lua/plugins.lua?ref_type=heads
### Commands ### Commands
| Command | Description | | Command | Description |
| ----------------------------------- | ------------------------------------------------------------------ | | ----------------------------------- | ------------------------------------------------------------------ |
| `PlugInstall [name ...] [#threads]` | Install plugins | | `PlugInstall [name ...] [#threads]` | Install plugins |
| `PlugUpdate [name ...] [#threads]` | Install or update 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 | | `PlugUpgrade` | Upgrade vim-plug itself |
| `PlugStatus` | Check the status of plugins | | `PlugStatus` | Check the status of plugins |
| `PlugDiff` | Examine changes from the previous update and the pending changes | | `PlugDiff` | Examine changes from the previous update and the pending changes |
@@ -224,16 +121,16 @@ More examples can be found in:
### `Plug` options ### `Plug` options
| Option | Description | | Option | Description |
| ----------------------- | ------------------------------------------------ | | ----------------------- | ----------------------------------------------------------- |
| `branch`/`tag`/`commit` | Branch/tag/commit of the repository to use | | `branch`/`tag`/`commit` | Branch/tag/commit of the repository to use |
| `rtp` | Subdirectory that contains Vim plugin | | `rtp` | Subdirectory that contains Vim plugin |
| `dir` | Custom directory for the plugin | | `dir` | Custom directory for the plugin |
| `as` | Use different name for the plugin | | `as` | Use different name for the plugin |
| `do` | Post-update hook (string or funcref) | | `do` | Post-update hook (string or funcref) |
| `on` | On-demand loading: Commands or `<Plug>`-mappings | | `on` | On-demand loading: Commands, `<Plug>`-mappings, or #autocmds |
| `for` | On-demand loading: File types | | `for` | On-demand loading: File types |
| `frozen` | Do not update unless explicitly specified | | `frozen` | Do not update unless explicitly specified |
### Global options ### Global options
@@ -272,7 +169,7 @@ call plug#end()
```vim ```vim
" NERD tree will be loaded on the first invocation of NERDTreeToggle command " NERD tree will be loaded on the first invocation of NERDTreeToggle command
Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' } Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
" Multiple commands " Multiple commands
Plug 'junegunn/vim-github-dashboard', { 'on': ['GHDashboard', 'GHActivity'] } Plug 'junegunn/vim-github-dashboard', { 'on': ['GHDashboard', 'GHActivity'] }
@@ -283,6 +180,9 @@ Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
" Multiple file types " Multiple file types
Plug 'kovisoft/paredit', { 'for': ['clojure', 'scheme'] } Plug 'kovisoft/paredit', { 'for': ['clojure', 'scheme'] }
" On autocmd
Plug 'SirVer/ultisnips', { 'on': '#InsertEnter' }
" 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' }
@@ -291,18 +191,18 @@ Plug 'junegunn/goyo.vim', { 'for': 'markdown' }
autocmd! User goyo.vim echom 'Goyo is now loaded!' autocmd! User goyo.vim echom 'Goyo is now loaded!'
``` ```
The `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
usually don't have too much code in the `plugin` directory. You might want to usually don't have too much code in `plugin` directory. You might want to
examine the output of `vim --startuptime` before applying the option. examine the output of `vim --startuptime` before applying the option.
### Post-update hooks ### Post-update hooks
There are some plugins that require extra steps after installation or update. 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. In that case, use `do` option to describe the task to be performed.
```vim ```vim
Plug 'Shougo/vimproc.vim', { 'do': 'make' } Plug 'Shougo/vimproc.vim', { 'do': 'make' }
Plug 'ycm-core/YouCompleteMe', { 'do': './install.py' } Plug 'Valloric/YouCompleteMe', { 'do': './install.py' }
``` ```
If the value starts with `:`, it will be recognized as a Vim command. If the value starts with `:`, it will be recognized as a Vim command.
@@ -311,14 +211,8 @@ If the value starts with `:`, it will be recognized as a Vim command.
Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' } 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 If you need more control, you can pass a reference to a Vim function that
takes a dictionary argument. takes a single argument.
```vim ```vim
function! BuildYCM(info) function! BuildYCM(info)
@@ -331,16 +225,17 @@ function! BuildYCM(info)
endif endif
endfunction endfunction
Plug 'ycm-core/YouCompleteMe', { 'do': function('BuildYCM') } Plug 'Valloric/YouCompleteMe', { 'do': function('BuildYCM') }
``` ```
A post-update hook is executed inside the directory of the plugin and only run Both forms of post-update hook are executed inside the directory of the plugin
when the repository has changed, but you can force it to run unconditionally and only run when the repository has changed, but you can force it to run
with the bang-versions of the commands: `PlugInstall!` and `PlugUpdate!`. unconditionally with the bang-versions of the commands: `PlugInstall!` and
`PlugUpdate!`.
Make sure to escape BARs and double-quotes when you write the `do` option Make sure to escape BARs and double-quotes when you write `do` option inline
inline as they are mistakenly recognized as command separator or the start of as they are mistakenly recognized as command separator or the start of the
the trailing comment. trailing comment.
```vim ```vim
Plug 'junegunn/fzf', { 'do': 'yes \| ./install' } Plug 'junegunn/fzf', { 'do': 'yes \| ./install' }
@@ -364,7 +259,7 @@ The installer takes the following steps when installing/updating a plugin:
1. Update submodules 1. Update submodules
2. Execute post-update hooks 2. Execute post-update hooks
The commands with the `!` suffix ensure that all steps are run unconditionally. The commands with `!` suffix ensure that all steps are run unconditionally.
### Articles ### Articles
@@ -373,11 +268,7 @@ The commands with the `!` suffix ensure that all steps are run unconditionally.
- ~~[Thoughts on Vim plugin dependency](http://junegunn.kr/2013/09/thoughts-on-vim-plugin-dependency)~~ - ~~[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* - *Support for Plugfile has been removed since 0.5.0*
### Collaborators
- [Jan Edmund Lazo](https://github.com/janlazo) - Windows support
- [Jeremy Pallats](https://github.com/starcraftman) - Python installer
### License ### License
MIT MIT

View File

@@ -1,386 +0,0 @@
plug.txt plug Last change: February 23 2024
PLUG - TABLE OF CONTENTS *plug* *plug-toc*
==============================================================================
vim-plug
Pros.
Installation
Vim
Unix
Windows (PowerShell)
Neovim
Unix
Windows (PowerShell)
Getting Help
Usage
Example
Commands
Plug options
Global options
Keybindings
Example: A small sensible Vim configuration
On-demand loading of plugins
Post-update hooks
PlugInstall! and PlugUpdate!
Articles
Collaborators
License
VIM-PLUG *vim-plug*
==============================================================================
A minimalist Vim plugin manager.
https://raw.githubusercontent.com/junegunn/i/master/vim-plug/installer.gif
< Pros. >_____________________________________________________________________~
*plug-pros*
- Easy to set up: Single file. No boilerplate code required.
- Easy to use: Concise, intuitive syntax
- {Super-fast}{1} parallel installation/update (with any of `+job`, `+python`,
`+python3`, `+ruby`, or {Neovim}{2})
- Creates shallow clones to minimize disk space usage and download time
- On-demand loading for {faster startup time}{3}
- 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} http://neovim.org/
{3} https://github.com/junegunn/vim-startuptime-benchmark#result
< Installation >______________________________________________________________~
*plug-installation*
{Download plug.vim}{4} and put it in the "autoload" directory.
{4} https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
Vim~
*plug-vim*
>> Unix~
>
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}{5}.
{5} https://github.com/junegunn/vim-plug/wiki/tips#automatic-installation
>> Windows (PowerShell)~
>
iwr -useb https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |`
ni $HOME/vimfiles/autoload/plug.vim -Force
<
Neovim~
*plug-neovim*
>> Unix~
>
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'
<
>> 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
<
< Getting Help >______________________________________________________________~
*plug-getting-help*
- See {tutorial}{6} page to learn the basics of vim-plug
- See {tips}{7} and {FAQ}{8} pages for common problems and questions
- See {requirements}{9} page for debugging information & tested configurations
- Create an {issue}{10}
{6} https://github.com/junegunn/vim-plug/wiki/tutorial
{7} https://github.com/junegunn/vim-plug/wiki/tips
{8} https://github.com/junegunn/vim-plug/wiki/faq
{9} https://github.com/junegunn/vim-plug/wiki/requirements
{10} https://github.com/junegunn/vim-plug/issues/new
< Usage >_____________________________________________________________________~
*plug-usage*
Add a vim-plug section to your `~/.vimrc` (or `stdpath('config').'/init.vim'` for
Neovim)
*plug#begin* *plug#end*
1. Begin the section with `callplug#begin([PLUGIN_DIR])`
2. List the plugins with `Plug` commands
3. `callplug#end()` to update 'runtimepath' and initialize plugin system
- Automatically executes `filetypepluginindenton` and `syntaxenable`.
You can revert the settings after the call. e.g. `filetypeindentoff`,
`syntaxoff`, etc.
Example~
*plug-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; fetches https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'
" Any valid git URL is allowed
Plug 'https://github.com/junegunn/vim-github-dashboard.git'
" Multiple Plug commands can be written in a single line using | separators
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
" On-demand loading
Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
" Using a non-default branch
Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }
" Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
Plug 'fatih/vim-go', { 'tag': '*' }
" 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'
" Initialize plugin system
" - 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
<
*:PlugInstall*
Reload .vimrc and `:PlugInstall` to install plugins.
< 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[!][outputpath]` | Generate script for restoring the current snapshot of the plugins
------------------------------------+-------------------------------------------------------------------
< Plug options >______________________________________________________________~
*plug-options*
*:Plug*
------------------------+-----------------------------------------------
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 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` | `verticaltopleftnew` | Command to open plug window
`g:plug_pwindow` | `above12new` | 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*
*:PlugStatus* *:PlugDiff*
- `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
< Example: A small sensible Vim configuration >_______________________________~
*plug-example-a-small-sensible-vim-configuration*
>
call plug#begin()
Plug 'tpope/vim-sensible'
call plug#end()
<
< 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!'
<
The `for` option is generally not needed as most plugins for specific file
types usually don't have too much code in the `plugin` directory. You might
want to examine the output of `vim--startuptime` before applying the option.
< 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!`.
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 Vimscript expression) as follows:
*g:fzf_install*
>
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. `gitclone` or `gitfetch` from its origin
2. Check out branch, tag, or commit and optionally `gitmerge` 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.
< Articles >__________________________________________________________________~
*plug-articles*
- {Writing my own Vim plugin manager}{11}
- {Vim plugins and startup time}{12}
- ~~{Thoughts on Vim plugin dependency}{13}~~
- Support for Plugfile has been removed since 0.5.0
{11} http://junegunn.kr/2013/09/writing-my-own-vim-plugin-manager
{12} http://junegunn.kr/2014/07/vim-plugins-and-startup-time
{13} http://junegunn.kr/2013/09/thoughts-on-vim-plugin-dependency
< Collaborators >_____________________________________________________________~
*plug-collaborators*
- {Jan Edmund Lazo}{14} - Windows support
- {Jeremy Pallats}{15} - Python installer
{14} https://github.com/janlazo
{15} https://github.com/starcraftman
< License >___________________________________________________________________~
*plug-license*
MIT
==============================================================================
vim:tw=78:sw=2:ts=2:ft=help:norl:nowrap:

715
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): Execute (#112 On-demand loading should not suppress messages from ftplugin):
call ResetPlug()
call plug#begin('$PLUG_FIXTURES') call plug#begin('$PLUG_FIXTURES')
Plug '$PLUG_FIXTURES/ftplugin-msg', { 'for': 'c' } Plug '$PLUG_FIXTURES/ftplugin-msg', { 'for': 'c' }
call plug#end() call plug#end()
@@ -8,14 +7,13 @@ 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-c') >= 0, 'Unexpected output (1): '.out Assert stridx(out, 'ftplugin-c') >= 0
* The same applies to plug#load()) * The same applies to plug#load())
call ResetPlug()
redir => out redir => out
call plug#load('ftplugin-msg') call plug#load('ftplugin-msg')
redir END redir END
Assert stridx(out, 'ftplugin-c') >= 0, 'Unexpected output (2): '.out Assert stridx(out, 'ftplugin-c') >= 0
q q
@@ -41,7 +39,6 @@ Execute (#130 Proper cleanup of on-demand loading triggers):
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
call mkdir(g:plugs['vim-emoji'].dir.'/after/plugin', 'p')
Assert exists(':EmojiCommand'), 'EmojiCommand not defined' Assert exists(':EmojiCommand'), 'EmojiCommand not defined'
Assert exists(':EmojiCommand2'), 'EmojiCommand2 not defined' Assert exists(':EmojiCommand2'), 'EmojiCommand2 not defined'
@@ -92,11 +89,10 @@ Execute (#139-1 Using new remote branch):
PlugUpdate PlugUpdate
unlet! g:foo g:bar g:baz unlet! g:foo g:bar g:baz
call ResetPlug()
call plug#load('new-branch') call plug#load('new-branch')
Assert exists('g:foo'), 'g:foo should be found (1)' Assert exists('g:foo'), 'g:foo should be found'
Assert !exists('g:bar'), 'g:bar should not be found (1)' Assert !exists('g:bar'), 'g:bar should not be found'
Assert !exists('g:baz'), 'g:baz should not be found (1)' 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/vim-plug-test/new-branch && git checkout -b new &&' call system('cd /tmp/vim-plug-test/new-branch && git checkout -b new &&'
@@ -114,11 +110,10 @@ Execute (#139-1 Using new remote branch):
Assert @" !~? 'error', 'Should be able to use new remote branch: ' . @" Assert @" !~? 'error', 'Should be able to use new remote branch: ' . @"
unlet! g:foo g:bar g:baz unlet! g:foo g:bar g:baz
call ResetPlug()
call plug#load('new-branch') call plug#load('new-branch')
Assert exists('g:foo'), 'g:foo should be found (2)' Assert exists('g:foo'), 'g:foo should be found'
Assert exists('g:bar'), 'g:bar should be found (2)' Assert exists('g:bar'), 'g:bar should be found'
Assert !exists('g:baz'), 'g:baz should not be found (2)' Assert !exists('g:baz'), 'g:baz should not be found'
call PlugStatusSorted() call PlugStatusSorted()
@@ -145,7 +140,6 @@ Execute (#139-2 Using yet another new remote branch):
Assert @" !~? 'error', 'Should be able to use new remote branch: ' . @" Assert @" !~? 'error', 'Should be able to use new remote branch: ' . @"
unlet! g:foo g:bar g:baz unlet! g:foo g:bar g:baz
call ResetPlug()
call plug#load('new-branch') call plug#load('new-branch')
Assert exists('g:foo'), 'g:foo should be found' Assert exists('g:foo'), 'g:foo should be found'
Assert !exists('g:bar'), 'g:bar should not be found' Assert !exists('g:bar'), 'g:bar should not be found'
@@ -231,7 +225,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/vim-plug-test/plug it') call plug#begin('/tmp/vim-plug-test/plug it')
Plug 'foo/seoul256 vim' Plug 'seoul256 vim'
call plug#end() call plug#end()
Log &rtp Log &rtp
Assert stridx(&rtp, 'plug it/seoul256 vim') >= 0 Assert stridx(&rtp, 'plug it/seoul256 vim') >= 0
@@ -239,12 +233,12 @@ 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/vim-plug-test/plugged') call plug#begin('/tmp/vim-plug-test/plugged')
Plug 'foo/plugin1' Plug 'plugin1'
\| Plug 'foo/plugin0' \| Plug 'plugin0'
Plug 'foo/plugin2' Plug 'plugin2'
\| Plug 'foo/plugin0' \| Plug 'plugin0'
\| Plug 'foo/plugin1' \| Plug 'plugin1'
call plug#end() call plug#end()
Log &rtp Log &rtp
@@ -310,19 +304,17 @@ Execute (#474: Load ftdetect files in filetypedetect augroup):
bd bd
********************************************************************** **********************************************************************
Execute (#489/#587 On-demand loading with 'on' option should trigger BufRead autocmd w/o nomodeline): Execute (#489 On-demand loading with 'on' option should trigger BufRead autocmd):
call plug#begin('$PLUG_FIXTURES') call plug#begin('$PLUG_FIXTURES')
Plug 'foo/ftplugin-msg', { 'on': 'XXX' } Plug 'ftplugin-msg', { 'on': 'XXX' }
call plug#end() call plug#end()
tabnew a.java tabnew a.java
call setline(1, '// vim: set filetype=lava:')
redir => out redir => out
silent! XXX silent! XXX
redir END redir END
Assert stridx(out, 'ftplugin-java') >= 0 Assert stridx(out, 'ftplugin-java') >= 0
AssertEqual 'lava', &filetype q
q!
********************************************************************** **********************************************************************
Execute (Cursor moved to another window during post-update hook): Execute (Cursor moved to another window during post-update hook):
@@ -338,38 +330,3 @@ Execute (Cursor moved to another window during post-update hook):
AssertEqual 'empty', getline(1) AssertEqual 'empty', getline(1)
q! q!
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,10 +1,6 @@
#!/bin/bash #!/bin/bash
# Privileged mode, ignores $CDPATH etc. cd $(dirname "${BASH_SOURCE[0]}")
set -p
set -eu
cd "$(dirname "${BASH_SOURCE[0]}")"
export BASE="$PWD" export BASE="$PWD"
export PLUG_SRC="$PWD/../plug.vim" export PLUG_SRC="$PWD/../plug.vim"
@@ -20,8 +16,8 @@ set shell=/bin/bash
VIMRC VIMRC
clone() { clone() {
if [ ! -d "$2" ]; then if [ ! -d $2 ]; then
git clone "$1" "$2" git clone $1 $2
fi fi
} }
@@ -48,8 +44,8 @@ make_dirs() (
cd "$PLUG_FIXTURES/$1" cd "$PLUG_FIXTURES/$1"
mkdir -p autoload colors ftdetect ftplugin indent plugin syntax mkdir -p autoload colors ftdetect ftplugin indent plugin syntax
for d in *; do for d in *; do
[ -d "$d" ] || continue [ -d $d ] || continue
cat > "$d/xxx.vim" << EOF cat > $d/xxx.vim << EOF
" echom expand('<sfile>') " echom expand('<sfile>')
let g:total_order = get(g:, 'total_order', []) let g:total_order = get(g:, 'total_order', [])
let g:$2 = get(g:, '$2', []) let g:$2 = get(g:, '$2', [])
@@ -62,7 +58,7 @@ EOF
gitinit() ( gitinit() (
cd "$PLUG_FIXTURES/$1" cd "$PLUG_FIXTURES/$1"
git init -b master git init
git commit -m 'commit' --allow-empty git commit -m 'commit' --allow-empty
) )
@@ -77,42 +73,31 @@ DOC
make_dirs yyy/ yyy make_dirs yyy/ yyy
make_dirs yyy/after 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 gitinit yyy
make_dirs z1/ z1 make_dirs z1/ z1
make_dirs z2/ z2 make_dirs z2/ z2
rm -rf "$PLUG_FIXTURES/ftplugin-msg" rm -rf "$PLUG_FIXTURES/ftplugin-msg"
mkdir -p "$PLUG_FIXTURES"/ftplugin-msg/{plugin,ftplugin} mkdir -p "$PLUG_FIXTURES/ftplugin-msg/ftplugin"
echo "echomsg 'ftplugin-c'" > "$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" echo "echomsg 'ftplugin-java'" > "$PLUG_FIXTURES/ftplugin-msg/ftplugin/java.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 rm -rf $TEMP/new-branch
cd $TEMP cd $TEMP
git init new-branch -b master git init new-branch
cd new-branch cd new-branch
mkdir plugin mkdir plugin
echo 'let g:foo = 1' > plugin/foo.vim echo 'let g:foo = 1' > plugin/foo.vim
git add plugin/foo.vim git add plugin/foo.vim
git commit -m initial git commit -m initial
git checkout -b plugin
git checkout master
cd "$BASE" cd "$BASE"
} }
select_vim() { select_vim() {
local vim=/usr/bin/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" vim="${DEPS}/bin/vim"
elif [ -e "/usr/local/bin/vim" ]; then elif [ -e "/usr/local/bin/vim" ]; then
vim=/usr/local/bin/vim vim=/usr/local/bin/vim
@@ -124,14 +109,13 @@ clone_repos
prepare prepare
git --version git --version
vim=$(select_vim) VIM=$(select_vim)
echo "Selected Vim: $vim" echo "Selected Vim: $VIM"
if [ "${1:-}" = '!' ]; then if [ "$1" = '!' ]; then
FAIL=0 $VIM -Nu $TEMP/mini-vimrc -c 'Vader! test.vader' > /dev/null &&
$vim -Nu $TEMP/mini-vimrc -c 'Vader! test.vader' > /dev/null || FAIL=1 prepare &&
prepare $VIM -Nu $TEMP/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 || FAIL=1
test $FAIL -eq 0
else else
$vim -Nu $TEMP/mini-vimrc -c 'Vader test.vader' $VIM -Nu $TEMP/mini-vimrc -c 'Vader test.vader'
fi fi

View File

@@ -18,6 +18,10 @@ Execute (Initialize test environment):
\ ['function! ResetPlug()', 'let s:loaded = {}', 'endfunction', \ ['function! ResetPlug()', 'let s:loaded = {}', 'endfunction',
\ 'function! CompareURI(a, b)', 'return s:compare_git_uri(a:a, a:b)', 'endfunction'] \ 'function! CompareURI(a, b)', 'return s:compare_git_uri(a:a, a:b)', 'endfunction']
if $ENV != 'vim8'
call add(patch, 'let s:vim8 = 0')
endif
call writefile(extend(readfile($PLUG_TMP), patch), $PLUG_TMP) call writefile(extend(readfile($PLUG_TMP), patch), $PLUG_TMP)
set t_Co=256 set t_Co=256
@@ -33,10 +37,9 @@ Execute (Initialize test environment):
g/^$/d g/^$/d
endfunction endfunction
function! AssertExpect(bang, pat, cnt, ...) function! AssertExpect(bang, pat, cnt)
let op = a:bang ? '==#' : '=~#' let op = a:bang ? '==#' : '=~#'
let args = [a:cnt, len(filter(getline(1, '$'), "v:val ".op." '".a:pat."'"))] + a:000 AssertEqual a:cnt, len(filter(getline(1, '$'), "v:val ".op." '".a:pat."'"))
call call('vader#assert#equal', args)
endfunction endfunction
command! -nargs=+ -bang AssertExpect call AssertExpect('<bang>' == '!', <args>) command! -nargs=+ -bang AssertExpect call AssertExpect('<bang>' == '!', <args>)
@@ -86,7 +89,6 @@ Execute (Print Interpreter Version):
Include: workflow.vader Include: workflow.vader
Include: regressions.vader Include: regressions.vader
Include: functional.vader
Execute (Cleanup): Execute (Cleanup):
silent! call RmRf(g:temp_plugged) silent! call RmRf(g:temp_plugged)

View File

@@ -2,7 +2,7 @@ Execute (plug#end() before plug#begin() should fail):
redir => out redir => out
silent! AssertEqual 0, plug#end() silent! AssertEqual 0, plug#end()
redir 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): Execute (plug#begin() without path argument):
call plug#begin() call plug#begin()
@@ -19,13 +19,6 @@ Execute (plug#begin() without path argument with empty &rtp):
let &rtp = save_rtp let &rtp = save_rtp
unlet 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)): Execute (plug#begin(path)):
call plug#begin(g:temp_plugged.'/') call plug#begin(g:temp_plugged.'/')
Assert g:plug_home !~ '[/\\]$', 'Trailing / should be stripped from g:plug_home' Assert g:plug_home !~ '[/\\]$', 'Trailing / should be stripped from g:plug_home'
@@ -49,62 +42,29 @@ Execute (Test Plug command):
AssertEqual 'no-t_co', g:plugs['seoul256.vim'].branch AssertEqual 'no-t_co', g:plugs['seoul256.vim'].branch
^ Git repo with tag (DEPRECATED. USE TAG OPTION) ^ 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' Plug 'junegunn/goyo.vim', '1.5.2'
AssertEqual 'file:///tmp/vim-plug-test/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
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 Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' } " Using tag option
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/vim-plug-test/jg/vim-emoji' Plug 'file:///tmp/vim-plug-test/jg/vim-emoji'
AssertEqual 'file:///tmp/vim-plug-test/jg/vim-emoji', g:plugs['vim-emoji'].uri AssertEqual 'file:///tmp/vim-plug-test/jg/vim-emoji', g:plugs['vim-emoji'].uri
AssertEqual '', 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 'vim-scripts/beauty256' Plug 'beauty256'
AssertEqual 'file:///tmp/vim-plug-test/vim-scripts/beauty256', g:plugs.beauty256.uri AssertEqual 'file:///tmp/vim-plug-test/vim-scripts/beauty256', g:plugs.beauty256.uri
AssertEqual '', g:plugs.beauty256.branch AssertEqual 'master', g:plugs.beauty256.branch
AssertEqual 4, len(g:plugs) AssertEqual 4, len(g:plugs)
redir => out
Plug 'beauty256'
redir END
Assert out =~ 'Invalid argument: beauty256'
Execute (Plug command with dictionary option): Execute (Plug command with dictionary option):
Log string(g:plugs) 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': '././' } Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co', 'rtp': '././' }
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 '././', g:plugs['seoul256.vim'].rtp AssertEqual '././', g:plugs['seoul256.vim'].rtp
@@ -252,7 +212,7 @@ Expect:
[==] [==]
x seoul256.vim: x seoul256.vim:
Execute (Corrected the URI but ahead of upstream): 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/vim-plug-test/jg/vim-emoji' Plug 'file:///tmp/vim-plug-test/jg/vim-emoji'
@@ -263,8 +223,8 @@ Execute (Corrected the URI but ahead of upstream):
call PlugStatusSorted() call PlugStatusSorted()
Expect: Expect:
Ahead of origin/master by 3 commit(s). Diverged from origin/master by 3 commit(s).
Cannot update until local changes are pushed. Reinstall after PlugClean.
- vim-emoji: OK - vim-emoji: OK
Finished. 1 error(s). Finished. 1 error(s).
[==] [==]
@@ -277,44 +237,11 @@ Expect:
# q # q
# PGdd # PGdd
Execute (PlugClean! keeps seoul256.vim): Execute (PlugClean! to remove seoul256.vim):
PlugClean! PlugClean!
" Two removed, emoji and seoul256 left " Three removed, emoji left
AssertEqual 'Removed 2 directories.', getline(4) AssertEqual 'Removed 3 directories.', getline(4)
AssertExpect '^\~ ', 2 AssertExpect '^\~ ', 3
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 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'))
@@ -343,8 +270,8 @@ Execute (PlugClean! to remove vim-emoji):
PlugClean! PlugClean!
AssertExpect '^\~ ', 1 AssertExpect '^\~ ', 1
AssertEqual 'Removed 1 directories.', getline(4) AssertEqual 'Removed 1 directories.', getline(4)
Assert empty(globpath(&rtp, 'colors/seoul256.vim')), 'seoul256.vim was removed' Assert empty(globpath(&rtp, 'colors/seoul256.vim'))
Assert empty(globpath(&rtp, 'autoload/emoji.vim')), 'emoji was removed' Assert empty(globpath(&rtp, 'autoload/emoji.vim'))
q q
Execute (PlugUpdate to install both again): Execute (PlugUpdate to install both again):
@@ -356,7 +283,7 @@ Execute (PlugUpdate to install both again):
Execute (PlugUpdate only to find out plugins are up-to-date, D key to check): Execute (PlugUpdate only to find out plugins are up-to-date, D key to check):
PlugUpdate 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 normal D
AssertEqual '0 plugin(s) updated.', getline(1) AssertEqual '0 plugin(s) updated.', getline(1)
q q
@@ -382,7 +309,6 @@ Execute (New commits on remote, PlugUpdate, then PlugDiff):
" Now we have updates " Now we have updates
normal D normal D
AssertEqual '2 plugin(s) updated.', getline(1) AssertEqual '2 plugin(s) updated.', getline(1)
AssertThrows execute('/gpg')
" Preview commit " Preview commit
silent! wincmd P silent! wincmd P
@@ -393,29 +319,14 @@ Execute (New commits on remote, PlugUpdate, then PlugDiff):
let lnum = line('.') let lnum = line('.')
AssertEqual 3, col('.') 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 " Open commit preview
execute "normal j\<cr>" execute "normal j\<cr>"
wincmd P wincmd P
AssertEqual 1, &previewwindow AssertEqual 1, &previewwindow
AssertEqual 'git', &filetype AssertEqual 'git', &filetype
" Close preview window " Back to plug window
pclose wincmd p
" 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'
" ]] motion " ]] motion
execute 'normal $]]' execute 'normal $]]'
@@ -436,17 +347,13 @@ Execute (New commits on remote, PlugUpdate, then PlugDiff):
execute "normal Xy\<cr>" execute "normal Xy\<cr>"
AssertExpect '^- ', 1 AssertExpect '^- ', 1
" q will only close preview window " q will close preview window as well
normal q normal q
" We no longer have preview window " We no longer have preview window
silent! wincmd P silent! wincmd P
AssertEqual 0, &previewwindow 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 " q should not close preview window if it's already open
pedit pedit
PlugDiff PlugDiff
@@ -471,35 +378,9 @@ Execute (Test g:plug_pwindow):
AssertEqual 2, winnr() AssertEqual 2, winnr()
AssertEqual 5, winheight('.') AssertEqual 5, winheight('.')
wincmd p wincmd p
" Close preview window
normal q
" Close main window
normal q normal q
unlet g:plug_pwindow 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): Execute (Reuse Plug window in another tab):
let tabnr = tabpagenr() let tabnr = tabpagenr()
PlugDiff PlugDiff
@@ -583,51 +464,6 @@ Execute (PlugDiff):
Assert !empty(mapcheck("\<cr>")) Assert !empty(mapcheck("\<cr>"))
q 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 ~ ~ On-demand loading / Partial installation/update ~
********************************************************************** **********************************************************************
@@ -635,7 +471,7 @@ Execute (Do not show diff for commits outside of rtp):
Execute (Trying to execute on-demand commands when plugin is not installed): Execute (Trying to execute on-demand commands when plugin is not installed):
call ReloadPlug() call ReloadPlug()
call plug#begin() call plug#begin()
Plug 'junegunn/vim-easy-align', { 'on': ['EasyAlign', 'LiveEasyAlign!'] } Plug 'junegunn/vim-easy-align', { 'on': ['EasyAlign', 'LiveEasyAlign'] }
call plug#end() call plug#end()
Assert exists(':EasyAlign') Assert exists(':EasyAlign')
@@ -1082,10 +918,9 @@ Execute (Post-update hook output; success and failure):
Execute (Post-update hook output; invalid type or funcref): Execute (Post-update hook output; invalid type or funcref):
call plug#begin() 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') } Plug 'junegunn/vim-pseudocl', { 'do': function('call') }
call plug#end() call plug#end()
let g:plugs['vim-easy-align'].do = 1
silent PlugInstall! 1 silent PlugInstall! 1
AssertEqual 'x Post-update hook for vim-pseudocl ... Vim(call):E119: Not enough arguments for function: call', getline(5) AssertEqual 'x Post-update hook for vim-pseudocl ... Vim(call):E119: Not enough arguments for function: call', getline(5)
@@ -1229,28 +1064,16 @@ Before:
********************************************************************** **********************************************************************
Execute (plug#helptags): 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/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/xxx/doc/tags'))
Assert !filereadable(expand('$PLUG_FIXTURES/yyy/rtp/doc/tags'))
AssertEqual 1, plug#helptags() AssertEqual 1, plug#helptags()
Assert filereadable(expand('$PLUG_FIXTURES/xxx/doc/tags')) Assert filereadable(expand('$PLUG_FIXTURES/xxx/doc/tags'))
Assert filereadable(expand('$PLUG_FIXTURES/yyy/rtp/doc/tags'))
********************************************************************** **********************************************************************
~ Manual loading ~ Manual loading
********************************************************************** **********************************************************************
Execute (plug#load - invalid arguments): 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()
AssertEqual 0, plug#load('non-existent-plugin') AssertEqual 0, plug#load('non-existent-plugin')
AssertEqual 0, plug#load('non-existent-plugin', 'another-non-existent-plugin') AssertEqual 0, plug#load('non-existent-plugin', 'another-non-existent-plugin')
@@ -1258,12 +1081,6 @@ Execute (plug#load - invalid arguments):
AssertEqual 0, plug#load('xxx', 'non-existent-plugin') AssertEqual 0, plug#load('xxx', 'non-existent-plugin')
AssertEqual 0, plug#load('non-existent-plugin', 'xxx') 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: []): Execute (on: []):
call plug#begin() call plug#begin()
Plug 'junegunn/rust.vim', { 'on': [] } Plug 'junegunn/rust.vim', { 'on': [] }
@@ -1358,7 +1175,7 @@ Execute (Using g:plug_url_format):
let g:plug_url_format = 'git@bitbucket.org:%s.git' let g:plug_url_format = 'git@bitbucket.org:%s.git'
Plug 'junegunn/seoul256.vim' Plug 'junegunn/seoul256.vim'
let g:plug_url_format = 'git@bitsocket.org:%s.git' 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@bitbucket.org:junegunn/seoul256.vim.git', g:plugs['seoul256.vim'].uri
AssertEqual 'git@bitsocket.org:vim-scripts/beauty256.git', g:plugs['beauty256'].uri AssertEqual 'git@bitsocket.org:vim-scripts/beauty256.git', g:plugs['beauty256'].uri
let g:plug_url_format = prev_plug_url_format let g:plug_url_format = prev_plug_url_format
@@ -1489,7 +1306,6 @@ Execute (PlugClean should not try to remove unmanaged plugins inside g:plug_home
Plug '$PLUG_FIXTURES/fzf' Plug '$PLUG_FIXTURES/fzf'
Plug '$PLUG_FIXTURES/xxx' Plug '$PLUG_FIXTURES/xxx'
Plug '$PLUG_FIXTURES/yyy' Plug '$PLUG_FIXTURES/yyy'
Plug '$PLUG_FIXTURES/cant-delete'
call plug#end() call plug#end()
" Remove z1, z2 " Remove z1, z2
@@ -1603,8 +1419,8 @@ Execute (Commit hash support):
PlugUpdate PlugUpdate
Log getline(1, '$') Log getline(1, '$')
AssertEqual 'x goyo.vim:', getline(5) AssertEqual 'x goyo.vim:', getline(5)
AssertEqual ' fatal: invalid reference: ffffffff', getline(6) AssertEqual ' error: pathspec ''ffffffff'' did not match any file(s) known to git.', getline(6)
AssertEqual 0, stridx(getline(7), '- vim-emoji: HEAD is now at 9db7fcf') AssertEqual 0, stridx(getline(7), '- vim-emoji: HEAD is now at 9db7fcf...')
let hash = system(printf('cd %s && git rev-parse HEAD', g:plugs['vim-emoji'].dir))[:-2] let hash = system(printf('cd %s && git rev-parse HEAD', g:plugs['vim-emoji'].dir))[:-2]
AssertEqual '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a', hash AssertEqual '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a', hash
@@ -1628,12 +1444,10 @@ Execute (Commit hash support):
Assert empty(mapcheck('X')) Assert empty(mapcheck('X'))
Assert !empty(mapcheck("\<cr>")) Assert !empty(mapcheck("\<cr>"))
" The exact hash values in PlugSnapshot output " Nor in PlugSnapshot output
PlugSnapshot PlugSnapshot
Log getline(1, '$') Log getline(1, '$')
AssertEqual "silent! let g:plugs['goyo.vim'].commit = 'ffffffff'", getline(6) AssertEqual 8, line('$')
AssertEqual "silent! let g:plugs['vim-emoji'].commit = '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a'", getline(7)
AssertEqual 10, line('$')
q q
Execute (Commit hash support - cleared): Execute (Commit hash support - cleared):
@@ -1715,55 +1529,21 @@ Execute (#532 - Reuse plug window):
call system(printf('cd "%s" && git commit --allow-empty -m "dummy"', g:plugs['goyo.vim'].dir)) call system(printf('cd "%s" && git commit --allow-empty -m "dummy"', g:plugs['goyo.vim'].dir))
PlugDiff PlugDiff
AssertEqual 1, winnr(), 'Current window is #1 after PlugDiff (but is '.winnr().')' AssertEqual 1, winnr()
AssertEqual 2, winnr('$'), 'Two windows after PlugDiff (but got '.winnr('$').')' AssertEqual 2, winnr('$')
" Open preview window " Open preview window
execute "normal ]]jo" execute "normal ]]jo"
AssertEqual 2, winnr(), 'Current window is #2 after opening preview (but is '.winnr().')' AssertEqual 2, winnr()
AssertEqual 3, winnr('$'), 'Three windows with preview (but got '.winnr('$').')' AssertEqual 3, winnr('$')
" Move plug window to the right " Move plug window to the right
wincmd L wincmd L
AssertEqual 3, winnr(), 'Current window is #3 after moving window (but is '.winnr().')' AssertEqual 3, winnr()
AssertEqual 3, winnr('$'), 'Three windows after moving window (but got '.winnr('$').')' AssertEqual 3, winnr('$')
" Reuse plug window. Preview window is closed. " Reuse plug window. Preview window is closed.
PlugStatus PlugStatus
AssertEqual 2, winnr(), 'Current window is #2 after PlugStatus (but is '.winnr().')' AssertEqual 2, winnr()
AssertEqual 2, winnr('$'), 'Three windows after PlugStatus (but got '.winnr('$').')' AssertEqual 2, winnr('$')
q
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 q