mirror of
https://github.com/junegunn/vim-plug.git
synced 2025-12-07 17:44:25 +08:00
Compare commits
56 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6050d6f03 | ||
|
|
7f8fdd0444 | ||
|
|
8ed2617ba0 | ||
|
|
0a255ee62d | ||
|
|
e0ca037a4f | ||
|
|
f80eed7379 | ||
|
|
fef4e434ba | ||
|
|
e6a775e0df | ||
|
|
96375cb7d3 | ||
|
|
2f4dc4d482 | ||
|
|
9813d5ead5 | ||
|
|
ddc67fc136 | ||
|
|
cd44b03db2 | ||
|
|
4f95bce2f4 | ||
|
|
7f96c98b0a | ||
|
|
05c8983d1a | ||
|
|
b93975f794 | ||
|
|
88cc9d7868 | ||
|
|
cd39fa6133 | ||
|
|
449b4f1ed6 | ||
|
|
802b100415 | ||
|
|
06992bcfb9 | ||
|
|
f7e6a86807 | ||
|
|
61ffb61615 | ||
|
|
9dcab48628 | ||
|
|
1d3c88292b | ||
|
|
580f0a559c | ||
|
|
46ae29985d | ||
|
|
7f4e6cb843 | ||
|
|
769192d3d0 | ||
|
|
e3252aae2c | ||
|
|
f551a71688 | ||
|
|
e80a93d5d0 | ||
|
|
d1ac3cdd1f | ||
|
|
359a65230e | ||
|
|
5e6bd469ac | ||
|
|
8c1aff151d | ||
|
|
d6bda025f1 | ||
|
|
5fc9eab788 | ||
|
|
93ffcb36de | ||
|
|
d5e9f91c7b | ||
|
|
0b1343b582 | ||
|
|
f916aabfbe | ||
|
|
b50f9bb16b | ||
|
|
8180692f81 | ||
|
|
a4aac4cf56 | ||
|
|
5bccd9bc98 | ||
|
|
1540764563 | ||
|
|
b9022d9046 | ||
|
|
c53ecd3acd | ||
|
|
ca0b726f46 | ||
|
|
942f994844 | ||
|
|
6ad18f5fb8 | ||
|
|
46ddb4af2d | ||
|
|
54683aa2c7 | ||
|
|
8f38888fad |
14
.travis.yml
14
.travis.yml
@@ -1,5 +1,6 @@
|
||||
language: ruby
|
||||
sudo: required
|
||||
dist: trusty
|
||||
sudo: false
|
||||
env:
|
||||
global:
|
||||
- DEPS=$HOME/deps
|
||||
@@ -30,13 +31,11 @@ install: |
|
||||
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
|
||||
# https://github.com/neovim/bot-ci#nightly-builds
|
||||
eval "$(curl -Ss https://raw.githubusercontent.com/neovim/bot-ci/master/scripts/travis-setup.sh) nightly-x64"
|
||||
mkdir -p ${DEPS}/bin
|
||||
ln -s /usr/bin/nvim ${DEPS}/bin/vim
|
||||
ln -s $(which nvim) ${DEPS}/bin/vim
|
||||
export VADER_OUTPUT_FILE=/dev/stderr
|
||||
return
|
||||
fi
|
||||
|
||||
@@ -55,6 +54,7 @@ install: |
|
||||
|
||||
git clone --depth 1 https://github.com/vim/vim
|
||||
cd vim
|
||||
export PATH=/usr/bin:$PATH
|
||||
./configure $C_OPTS
|
||||
make
|
||||
make install
|
||||
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
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.
|
||||
82
README.md
82
README.md
@@ -20,13 +20,15 @@ A minimalist Vim plugin manager.
|
||||
|
||||
[40/4]: https://raw.githubusercontent.com/junegunn/i/master/vim-plug/40-in-4.gif
|
||||
[nv]: http://neovim.org/
|
||||
[startup-time]: http://junegunn.kr/images/vim-startup-time.png
|
||||
[startup-time]: https://github.com/junegunn/vim-startuptime-benchmark#result
|
||||
|
||||
### Installation
|
||||
|
||||
[Download plug.vim](https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim)
|
||||
and put it in the "autoload" directory.
|
||||
|
||||
#### Vim
|
||||
|
||||
###### Unix
|
||||
|
||||
```sh
|
||||
@@ -34,27 +36,55 @@ curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
|
||||
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||
```
|
||||
|
||||
###### Neovim
|
||||
You can automate the process by putting the command in your Vim configuration
|
||||
file as suggested [here][auto].
|
||||
|
||||
```sh
|
||||
curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs \
|
||||
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||
```
|
||||
[auto]: https://github.com/junegunn/vim-plug/wiki/tips#automatic-installation
|
||||
|
||||
###### Windows (PowerShell)
|
||||
|
||||
```powershell
|
||||
md ~\vimfiles\autoload
|
||||
$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"))
|
||||
(New-Object Net.WebClient).DownloadFile(
|
||||
$uri,
|
||||
$ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(
|
||||
"~\vimfiles\autoload\plug.vim"
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
#### Neovim
|
||||
|
||||
###### Unix
|
||||
|
||||
```sh
|
||||
curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
|
||||
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||
```
|
||||
|
||||
###### Windows (PowerShell)
|
||||
|
||||
```powershell
|
||||
md ~\AppData\Local\nvim\autoload
|
||||
$uri = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
|
||||
(New-Object Net.WebClient).DownloadFile(
|
||||
$uri,
|
||||
$ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(
|
||||
"~\AppData\Local\nvim\autoload\plug.vim"
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
### Getting Help
|
||||
|
||||
- See the [requirements] page for debugging information & tested configurations.
|
||||
- See the [FAQ] for common problems and questions.
|
||||
- Create an [issue](https://github.com/junegunn/vim-plug/issues/new).
|
||||
- See [tutorial] page to learn the basics of vim-plug
|
||||
- See [tips] and [FAQ] pages for common problems and questions
|
||||
- See [requirements] page for debugging information & tested configurations
|
||||
- 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
|
||||
[requirements]: https://github.com/junegunn/vim-plug/wiki/requirements
|
||||
|
||||
@@ -65,10 +95,15 @@ Add a vim-plug section to your `~/.vimrc` (or `~/.config/nvim/init.vim` for Neov
|
||||
1. Begin the section with `call plug#begin()`
|
||||
1. List the plugins with `Plug` commands
|
||||
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
|
||||
|
||||
```vim
|
||||
" Specify a directory for plugins
|
||||
" - For Neovim: ~/.local/share/nvim/plugged
|
||||
" - Avoid using standard Vim directory names like 'plugin'
|
||||
call plug#begin('~/.vim/plugged')
|
||||
|
||||
" Make sure you use single quotes
|
||||
@@ -79,7 +114,7 @@ Plug 'junegunn/vim-easy-align'
|
||||
" Any valid git URL is allowed
|
||||
Plug 'https://github.com/junegunn/vim-github-dashboard.git'
|
||||
|
||||
" Group dependencies, vim-snippets depends on ultisnips
|
||||
" Multiple Plug commands can be written in a single line using | separators
|
||||
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
|
||||
|
||||
" On-demand loading
|
||||
@@ -101,7 +136,7 @@ Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
|
||||
" Unmanaged plugin (manually installed and updated)
|
||||
Plug '~/my-prototype-plugin'
|
||||
|
||||
" Add plugins to &runtimepath
|
||||
" Initialize plugin system
|
||||
call plug#end()
|
||||
```
|
||||
|
||||
@@ -121,16 +156,16 @@ Reload .vimrc and `:PlugInstall` to install plugins.
|
||||
|
||||
### `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, `<Plug>`-mappings, or #autocmds |
|
||||
| `for` | On-demand loading: File types |
|
||||
| `frozen` | Do not update unless explicitly specified |
|
||||
| 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
|
||||
|
||||
@@ -180,9 +215,6 @@ Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
|
||||
" Multiple file types
|
||||
Plug 'kovisoft/paredit', { 'for': ['clojure', 'scheme'] }
|
||||
|
||||
" On autocmd
|
||||
Plug 'SirVer/ultisnips', { 'on': '#InsertEnter' }
|
||||
|
||||
" On-demand loading on both conditions
|
||||
Plug 'junegunn/vader.vim', { 'on': 'Vader', 'for': 'vader' }
|
||||
|
||||
|
||||
376
doc/plug.txt
Normal file
376
doc/plug.txt
Normal file
@@ -0,0 +1,376 @@
|
||||
plug.txt plug Last change: November 27 2017
|
||||
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
|
||||
License
|
||||
|
||||
VIM-PLUG *vim-plug*
|
||||
==============================================================================
|
||||
|
||||
A minimalist Vim plugin manager.
|
||||
|
||||
https://raw.githubusercontent.com/junegunn/i/master/vim-plug/installer.gif
|
||||
|
||||
|
||||
< Pros. >_____________________________________________________________________~
|
||||
*plug-pros*
|
||||
|
||||
- Easier to setup: Single file. No boilerplate code required.
|
||||
- Easier 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)~
|
||||
>
|
||||
md ~\vimfiles\autoload
|
||||
$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"
|
||||
)
|
||||
)
|
||||
<
|
||||
|
||||
Neovim~
|
||||
*plug-neovim*
|
||||
|
||||
|
||||
>> Unix~
|
||||
>
|
||||
curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
|
||||
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||
<
|
||||
|
||||
>> Windows (PowerShell)~
|
||||
>
|
||||
md ~\AppData\Local\nvim\autoload
|
||||
$uri = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
|
||||
(New-Object Net.WebClient).DownloadFile(
|
||||
$uri,
|
||||
$ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(
|
||||
"~\AppData\Local\nvim\autoload\plug.vim"
|
||||
)
|
||||
)
|
||||
<
|
||||
|
||||
< 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 `~/.config/nvim/init.vim` for
|
||||
Neovim):
|
||||
|
||||
*plug#begin* *plug#end*
|
||||
|
||||
1. Begin the section with `call plug#begin()`
|
||||
2. List the plugins with `Plug` commands
|
||||
3. `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~
|
||||
*plug-example*
|
||||
>
|
||||
" Specify a directory for plugins
|
||||
" - For Neovim: ~/.local/share/nvim/plugged
|
||||
" - Avoid using standard Vim directory names like 'plugin'
|
||||
call plug#begin('~/.vim/plugged')
|
||||
|
||||
" 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 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
|
||||
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
|
||||
|
||||
" Using a non-master 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
|
||||
call plug#end()
|
||||
<
|
||||
*: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 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 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` | `vertical topleft new` | Command to open plug window
|
||||
`g:plug_pwindow` | `above 12new` | Command to open preview window in `PlugDiff`
|
||||
`g:plug_url_format` | `https://git::@github.com/%s.git` | `printf` format to build repo URL (Only applies to the subsequent `Plug` commands)
|
||||
--------------------+-----------------------------------+-----------------------------------------------------------------------------------
|
||||
|
||||
|
||||
< 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 'scrooloose/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!'
|
||||
<
|
||||
`for` option is generally not needed as most plugins for specific file types
|
||||
usually don't have too much code in `plugin` directory. You might want to
|
||||
examine the output of `vim --startuptime` before applying the option.
|
||||
|
||||
|
||||
< Post-update hooks >_________________________________________________________~
|
||||
*plug-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.
|
||||
>
|
||||
Plug 'Shougo/vimproc.vim', { 'do': 'make' }
|
||||
Plug 'Valloric/YouCompleteMe', { 'do': './install.py' }
|
||||
<
|
||||
If the value starts with `:`, it will be recognized as a Vim command.
|
||||
|
||||
*:GoInstallBinaries*
|
||||
>
|
||||
Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
|
||||
<
|
||||
If you need more control, you can pass a reference to a Vim function that
|
||||
takes a single 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 '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.
|
||||
>
|
||||
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. `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 `!` 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
|
||||
|
||||
|
||||
< License >___________________________________________________________________~
|
||||
*plug-license*
|
||||
|
||||
MIT
|
||||
|
||||
|
||||
==============================================================================
|
||||
vim:tw=78:sw=2:ts=2:ft=help:norl:nowrap:
|
||||
245
plug.vim
245
plug.vim
@@ -18,7 +18,7 @@
|
||||
" " Any valid git URL is allowed
|
||||
" Plug 'https://github.com/junegunn/vim-github-dashboard.git'
|
||||
"
|
||||
" " Group dependencies, vim-snippets depends on ultisnips
|
||||
" " Multiple Plug commands can be written in a single line using | separators
|
||||
" Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
|
||||
"
|
||||
" " On-demand loading
|
||||
@@ -40,7 +40,7 @@
|
||||
" " Unmanaged plugin (manually installed and updated)
|
||||
" Plug '~/my-prototype-plugin'
|
||||
"
|
||||
" " Add plugins to &runtimepath
|
||||
" " Initialize plugin system
|
||||
" call plug#end()
|
||||
"
|
||||
" Then reload .vimrc and :PlugInstall to install plugins.
|
||||
@@ -61,7 +61,7 @@
|
||||
" More information: https://github.com/junegunn/vim-plug
|
||||
"
|
||||
"
|
||||
" Copyright (c) 2016 Junegunn Choi
|
||||
" Copyright (c) 2017 Junegunn Choi
|
||||
"
|
||||
" MIT License
|
||||
"
|
||||
@@ -96,8 +96,8 @@ let s:plug_src = 'https://github.com/junegunn/vim-plug.git'
|
||||
let s:plug_tab = get(s:, 'plug_tab', -1)
|
||||
let s:plug_buf = get(s:, 'plug_buf', -1)
|
||||
let s:mac_gui = has('gui_macvim') && has('gui_running')
|
||||
let s:is_win = has('win32') || has('win64')
|
||||
let s:nvim = has('nvim') && exists('*jobwait') && !s:is_win
|
||||
let s:is_win = has('win32')
|
||||
let s:nvim = has('nvim-0.2') || (has('nvim') && exists('*jobwait') && !s:is_win)
|
||||
let s:vim8 = has('patch-8.0.0039') && exists('*job_start')
|
||||
let s:me = resolve(expand('<sfile>:p'))
|
||||
let s:base_spec = { 'branch': 'master', 'frozen': 0 }
|
||||
@@ -121,6 +121,9 @@ function! plug#begin(...)
|
||||
else
|
||||
return s:err('Unable to determine plug home. Try calling plug#begin() with a path argument.')
|
||||
endif
|
||||
if fnamemodify(home, ':t') ==# 'plugin' && fnamemodify(home, ':h') ==# s:first_rtp
|
||||
return s:err('Invalid plug home. '.home.' is a standard Vim runtime path and is not allowed.')
|
||||
endif
|
||||
|
||||
let g:plug_home = home
|
||||
let g:plugs = {}
|
||||
@@ -190,6 +193,14 @@ function! s:ask_no_interrupt(...)
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! s:lazy(plug, opt)
|
||||
return has_key(a:plug, a:opt) &&
|
||||
\ (empty(s:to_a(a:plug[a:opt])) ||
|
||||
\ !isdirectory(a:plug.dir) ||
|
||||
\ len(s:glob(s:rtp(a:plug), 'plugin')) ||
|
||||
\ len(s:glob(s:rtp(a:plug), 'after/plugin')))
|
||||
endfunction
|
||||
|
||||
function! plug#end()
|
||||
if !exists('g:plugs')
|
||||
return s:err('Call plug#begin() first')
|
||||
@@ -211,7 +222,7 @@ function! plug#end()
|
||||
continue
|
||||
endif
|
||||
let plug = g:plugs[name]
|
||||
if get(s:loaded, name, 0) || !has_key(plug, 'on') && !has_key(plug, 'for')
|
||||
if get(s:loaded, name, 0) || !s:lazy(plug, 'on') && !s:lazy(plug, 'for')
|
||||
let s:loaded[name] = 1
|
||||
continue
|
||||
endif
|
||||
@@ -225,20 +236,14 @@ function! plug#end()
|
||||
endif
|
||||
call add(s:triggers[name].map, cmd)
|
||||
elseif cmd =~# '^[A-Z]'
|
||||
let cmd = substitute(cmd, '!*$', '', '')
|
||||
if exists(':'.cmd) != 2
|
||||
call s:assoc(lod.cmd, cmd, name)
|
||||
endif
|
||||
call add(s:triggers[name].cmd, cmd)
|
||||
elseif cmd[0] == '#' && exists('##'.split(cmd, '#')[0])
|
||||
let tokens = split(cmd, '#')
|
||||
let group = 'Plug/'.name
|
||||
execute 'augroup' group
|
||||
autocmd!
|
||||
execute 'autocmd' tokens[0] get(tokens, 1, '*') printf('call s:lod_autocmd(%s)', string(name))
|
||||
execute 'augroup END'
|
||||
else
|
||||
call s:err('Invalid `on` option: '.cmd.
|
||||
\ '. Should start with an uppercase letter, `<Plug>`, or `#`.')
|
||||
\ '. Should start with an uppercase letter or `<Plug>`.')
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
@@ -258,7 +263,7 @@ function! plug#end()
|
||||
|
||||
for [cmd, names] in items(lod.cmd)
|
||||
execute printf(
|
||||
\ 'command! -nargs=* -range -bang %s call s:lod_cmd(%s, "<bang>", <line1>, <line2>, <q-args>, %s)',
|
||||
\ 'command! -nargs=* -range -bang -complete=file %s call s:lod_cmd(%s, "<bang>", <line1>, <line2>, <q-args>, %s)',
|
||||
\ cmd, string(cmd), string(names))
|
||||
endfor
|
||||
|
||||
@@ -319,7 +324,7 @@ endfunction
|
||||
|
||||
function! s:git_version_requirement(...)
|
||||
if !exists('s:git_version')
|
||||
let s:git_version = map(split(split(s:system('git --version'))[-1], '\.'), 'str2nr(v:val)')
|
||||
let s:git_version = map(split(split(s:system('git --version'))[2], '\.'), 'str2nr(v:val)')
|
||||
endif
|
||||
return s:version_requirement(s:git_version, a:000)
|
||||
endfunction
|
||||
@@ -432,7 +437,10 @@ function! s:dobufread(names)
|
||||
let path = s:rtp(g:plugs[name]).'/**'
|
||||
for dir in ['ftdetect', 'ftplugin']
|
||||
if len(finddir(dir, path))
|
||||
return s:doautocmd('BufRead')
|
||||
if exists('#BufRead')
|
||||
doautocmd BufRead
|
||||
endif
|
||||
return
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
@@ -445,14 +453,21 @@ function! plug#load(...)
|
||||
if !exists('g:plugs')
|
||||
return s:err('plug#begin was not called')
|
||||
endif
|
||||
let unknowns = filter(copy(a:000), '!has_key(g:plugs, v:val)')
|
||||
let names = a:0 == 1 && type(a:1) == s:TYPE.list ? a:1 : a:000
|
||||
let unknowns = filter(copy(names), '!has_key(g:plugs, v:val)')
|
||||
if !empty(unknowns)
|
||||
let s = len(unknowns) > 1 ? 's' : ''
|
||||
return s:err(printf('Unknown plugin%s: %s', s, join(unknowns, ', ')))
|
||||
end
|
||||
call s:lod(a:000, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
||||
call s:dobufread(a:000)
|
||||
return 1
|
||||
let unloaded = filter(copy(names), '!get(s:loaded, v:val, 0)')
|
||||
if !empty(unloaded)
|
||||
for name in unloaded
|
||||
call s:lod([name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
||||
endfor
|
||||
call s:dobufread(unloaded)
|
||||
return 1
|
||||
end
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
function! s:remove_triggers(name)
|
||||
@@ -531,14 +546,6 @@ function! s:lod_map(map, names, with_prefix, prefix)
|
||||
call feedkeys(substitute(a:map, '^<Plug>', "\<Plug>", '') . extra)
|
||||
endfunction
|
||||
|
||||
function! s:lod_autocmd(name)
|
||||
call s:lod([a:name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
||||
call s:dobufread([a:name])
|
||||
let group = 'Plug/'.a:name
|
||||
execute 'autocmd!' group
|
||||
execute 'augroup!' group
|
||||
endfunction
|
||||
|
||||
function! plug#(repo, ...)
|
||||
if a:0 > 1
|
||||
return s:err('Invalid number of arguments (1..2)')
|
||||
@@ -584,7 +591,7 @@ function! s:infer_properties(name, repo)
|
||||
let uri = repo
|
||||
else
|
||||
if repo !~ '/'
|
||||
let repo = 'vim-scripts/'. repo
|
||||
throw printf('Invalid argument: %s (implicit `vim-scripts'' expansion is deprecated)', repo)
|
||||
endif
|
||||
let fmt = get(g:, 'plug_url_format', 'https://git::@github.com/%s.git')
|
||||
let uri = printf(fmt, repo)
|
||||
@@ -606,7 +613,7 @@ function! plug#helptags()
|
||||
return s:err('plug#begin was not called')
|
||||
endif
|
||||
for spec in values(g:plugs)
|
||||
let docd = join([spec.dir, 'doc'], '/')
|
||||
let docd = join([s:rtp(spec), 'doc'], '/')
|
||||
if isdirectory(docd)
|
||||
silent! execute 'helptags' s:esc(docd)
|
||||
endif
|
||||
@@ -630,10 +637,10 @@ function! s:syntax()
|
||||
syn match plugTag /(tag: [^)]\+)/
|
||||
syn match plugInstall /\(^+ \)\@<=[^:]*/
|
||||
syn match plugUpdate /\(^* \)\@<=[^:]*/
|
||||
syn match plugCommit /^ \X*[0-9a-f]\{7} .*/ contains=plugRelDate,plugEdge,plugTag
|
||||
syn match plugCommit /^ \X*[0-9a-f]\{7,9} .*/ contains=plugRelDate,plugEdge,plugTag
|
||||
syn match plugEdge /^ \X\+$/
|
||||
syn match plugEdge /^ \X*/ contained nextgroup=plugSha
|
||||
syn match plugSha /[0-9a-f]\{7}/ contained
|
||||
syn match plugSha /[0-9a-f]\{7,9}/ contained
|
||||
syn match plugRelDate /([^)]*)$/ contained
|
||||
syn match plugNotLoaded /(not loaded)$/
|
||||
syn match plugError /^x.*/
|
||||
@@ -763,7 +770,10 @@ function! s:prepare(...)
|
||||
for k in ['<cr>', 'L', 'o', 'X', 'd', 'dd']
|
||||
execute 'silent! unmap <buffer>' k
|
||||
endfor
|
||||
setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline modifiable
|
||||
setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline modifiable nospell
|
||||
if exists('+colorcolumn')
|
||||
setlocal colorcolumn=
|
||||
endif
|
||||
setf vim-plug
|
||||
if exists('g:syntax_on')
|
||||
call s:syntax()
|
||||
@@ -783,8 +793,10 @@ function! s:assign_name()
|
||||
endfunction
|
||||
|
||||
function! s:chsh(swap)
|
||||
let prev = [&shell, &shellredir]
|
||||
if !s:is_win && a:swap
|
||||
let prev = [&shell, &shellcmdflag, &shellredir]
|
||||
if s:is_win
|
||||
set shell=cmd.exe shellcmdflag=/c shellredir=>%s\ 2>&1
|
||||
elseif a:swap
|
||||
set shell=sh shellredir=>%s\ 2>&1
|
||||
endif
|
||||
return prev
|
||||
@@ -792,15 +804,23 @@ endfunction
|
||||
|
||||
function! s:bang(cmd, ...)
|
||||
try
|
||||
let [sh, shrd] = s:chsh(a:0)
|
||||
let [sh, shellcmdflag, shrd] = s:chsh(a:0)
|
||||
" FIXME: Escaping is incomplete. We could use shellescape with eval,
|
||||
" but it won't work on Windows.
|
||||
let cmd = a:0 ? s:with_cd(a:cmd, a:1) : a:cmd
|
||||
let g:_plug_bang = '!'.escape(cmd, '#!%')
|
||||
if s:is_win
|
||||
let batchfile = tempname().'.bat'
|
||||
call writefile(["@echo off\r", cmd . "\r"], batchfile)
|
||||
let cmd = batchfile
|
||||
endif
|
||||
let g:_plug_bang = (s:is_win && has('gui_running') ? 'silent ' : '').'!'.escape(cmd, '#!%')
|
||||
execute "normal! :execute g:_plug_bang\<cr>\<cr>"
|
||||
finally
|
||||
unlet g:_plug_bang
|
||||
let [&shell, &shellredir] = [sh, shrd]
|
||||
let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd]
|
||||
if s:is_win
|
||||
call delete(batchfile)
|
||||
endif
|
||||
endtry
|
||||
return v:shell_error ? 'Exit status: ' . v:shell_error : ''
|
||||
endfunction
|
||||
@@ -829,6 +849,10 @@ function! s:do(pull, force, todo)
|
||||
let type = type(spec.do)
|
||||
if type == s:TYPE.string
|
||||
if spec.do[0] == ':'
|
||||
if !get(s:loaded, name, 0)
|
||||
let s:loaded[name] = 1
|
||||
call s:reorg_rtp()
|
||||
endif
|
||||
call s:load_plugin(spec)
|
||||
try
|
||||
execute spec.do[1:]
|
||||
@@ -873,7 +897,7 @@ function! s:checkout(spec)
|
||||
let output = s:system('git rev-parse HEAD', a:spec.dir)
|
||||
if !v:shell_error && !s:hash_match(sha, s:lines(output)[0])
|
||||
let output = s:system(
|
||||
\ 'git fetch --depth 999999 && git checkout '.s:esc(sha), a:spec.dir)
|
||||
\ 'git fetch --depth 999999 && git checkout '.s:esc(sha).' --', a:spec.dir)
|
||||
endif
|
||||
return output
|
||||
endfunction
|
||||
@@ -895,7 +919,7 @@ function! s:finish(pull)
|
||||
call add(msgs, "Press 'R' to retry.")
|
||||
endif
|
||||
if a:pull && len(s:update.new) < len(filter(getline(5, '$'),
|
||||
\ "v:val =~ '^- ' && stridx(v:val, 'Already up-to-date') < 0"))
|
||||
\ "v:val =~ '^- ' && v:val !~# 'Already up.to.date'"))
|
||||
call add(msgs, "Press 'D' to see the updated changes.")
|
||||
endif
|
||||
echo join(msgs, ' ')
|
||||
@@ -931,7 +955,8 @@ function! s:check_ruby()
|
||||
endfunction
|
||||
|
||||
function! s:update_impl(pull, force, args) abort
|
||||
let args = copy(a:args)
|
||||
let sync = index(a:args, '--sync') >= 0 || has('vim_starting')
|
||||
let args = filter(copy(a:args), 'v:val != "--sync"')
|
||||
let threads = (len(args) > 0 && args[-1] =~ '^[1-9][0-9]*$') ?
|
||||
\ remove(args, -1) : get(g:, 'plug_threads', 16)
|
||||
|
||||
@@ -967,7 +992,7 @@ function! s:update_impl(pull, force, args) abort
|
||||
|
||||
let use_job = s:nvim || s:vim8
|
||||
let python = (has('python') || has('python3')) && !use_job
|
||||
let ruby = has('ruby') && !use_job && (v:version >= 703 || v:version == 702 && has('patch374')) && !(s:is_win && has('gui_running')) && s:check_ruby()
|
||||
let ruby = has('ruby') && !use_job && (v:version >= 703 || v:version == 702 && has('patch374')) && !(s:is_win && has('gui_running')) && threads > 1 && s:check_ruby()
|
||||
|
||||
let s:update = {
|
||||
\ 'start': reltime(),
|
||||
@@ -990,6 +1015,12 @@ function! s:update_impl(pull, force, args) abort
|
||||
let s:clone_opt = get(g:, 'plug_shallow', 1) ?
|
||||
\ '--depth 1' . (s:git_version_requirement(1, 7, 10) ? ' --no-single-branch' : '') : ''
|
||||
|
||||
if has('win32unix')
|
||||
let s:clone_opt .= ' -c core.eol=lf -c core.autocrlf=input'
|
||||
endif
|
||||
|
||||
let s:submodule_opt = s:git_version_requirement(2, 8) ? ' --jobs='.threads : ''
|
||||
|
||||
" Python version requirement (>= 2.7)
|
||||
if python && !has('python3') && !ruby && !use_job && s:update.threads > 1
|
||||
redir => pyv
|
||||
@@ -1032,7 +1063,7 @@ function! s:update_impl(pull, force, args) abort
|
||||
endtry
|
||||
else
|
||||
call s:update_vim()
|
||||
while use_job && has('vim_starting')
|
||||
while use_job && sync
|
||||
sleep 100m
|
||||
if s:update.fin
|
||||
break
|
||||
@@ -1063,7 +1094,7 @@ function! s:update_finish()
|
||||
elseif has_key(spec, 'tag')
|
||||
let tag = spec.tag
|
||||
if tag =~ '\*'
|
||||
let tags = s:lines(s:system('git tag --list '.string(tag).' --sort -version:refname 2>&1', spec.dir))
|
||||
let tags = s:lines(s:system('git tag --list '.s:shellesc(tag).' --sort -version:refname 2>&1', spec.dir))
|
||||
if !v:shell_error && !empty(tags)
|
||||
let tag = tags[0]
|
||||
call s:log4(name, printf('Latest tag for %s -> %s', spec.tag, tag))
|
||||
@@ -1071,17 +1102,17 @@ function! s:update_finish()
|
||||
endif
|
||||
endif
|
||||
call s:log4(name, 'Checking out '.tag)
|
||||
let out = s:system('git checkout -q '.s:esc(tag).' 2>&1', spec.dir)
|
||||
let out = s:system('git checkout -q '.s:esc(tag).' -- 2>&1', spec.dir)
|
||||
else
|
||||
let branch = s:esc(get(spec, 'branch', 'master'))
|
||||
call s:log4(name, 'Merging origin/'.branch)
|
||||
let out = s:system('git checkout -q '.branch.' 2>&1'
|
||||
let out = s:system('git checkout -q '.branch.' -- 2>&1'
|
||||
\. (has_key(s:update.new, name) ? '' : ('&& git merge --ff-only origin/'.branch.' 2>&1')), spec.dir)
|
||||
endif
|
||||
if !v:shell_error && filereadable(spec.dir.'/.gitmodules') &&
|
||||
\ (s:update.force || has_key(s:update.new, name) || s:is_updated(spec.dir))
|
||||
call s:log4(name, 'Updating submodules. This may take a while.')
|
||||
let out .= s:bang('git submodule update --init --recursive 2>&1', spec.dir)
|
||||
let out .= s:bang('git submodule update --init --recursive'.s:submodule_opt.' 2>&1', spec.dir)
|
||||
endif
|
||||
let msg = s:format_message(v:shell_error ? 'x': '-', name, out)
|
||||
if v:shell_error
|
||||
@@ -1165,7 +1196,7 @@ function! s:job_cb(fn, job, ch, data)
|
||||
call call(a:fn, [a:job, a:data])
|
||||
endfunction
|
||||
|
||||
function! s:nvim_cb(job_id, data, event) abort
|
||||
function! s:nvim_cb(job_id, data, event) dict abort
|
||||
return a:event == 'stdout' ?
|
||||
\ s:job_cb('s:job_out_cb', self, 0, join(a:data, "\n")) :
|
||||
\ s:job_cb('s:job_exit_cb', self, 0, a:data)
|
||||
@@ -1173,10 +1204,15 @@ endfunction
|
||||
|
||||
function! s:spawn(name, cmd, opts)
|
||||
let job = { 'name': a:name, 'running': 1, 'error': 0, 'lines': [''],
|
||||
\ 'batchfile': (s:is_win && (s:nvim || s:vim8)) ? tempname().'.bat' : '',
|
||||
\ 'new': get(a:opts, 'new', 0) }
|
||||
let s:jobs[a:name] = job
|
||||
let argv = add(s:is_win ? ['cmd', '/c'] : ['sh', '-c'],
|
||||
\ has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd)
|
||||
let cmd = has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd
|
||||
if !empty(job.batchfile)
|
||||
call writefile(["@echo off\r", cmd . "\r"], job.batchfile)
|
||||
let cmd = job.batchfile
|
||||
endif
|
||||
let argv = add(s:is_win ? ['cmd', '/c'] : ['sh', '-c'], cmd)
|
||||
|
||||
if s:nvim
|
||||
call extend(job, {
|
||||
@@ -1193,7 +1229,7 @@ function! s:spawn(name, cmd, opts)
|
||||
\ 'Invalid arguments (or job table is full)']
|
||||
endif
|
||||
elseif s:vim8
|
||||
let jid = job_start(argv, {
|
||||
let jid = job_start(s:is_win ? join(argv, ' ') : argv, {
|
||||
\ 'out_cb': function('s:job_cb', ['s:job_out_cb', job]),
|
||||
\ 'exit_cb': function('s:job_cb', ['s:job_exit_cb', job]),
|
||||
\ 'out_mode': 'raw'
|
||||
@@ -1206,8 +1242,7 @@ function! s:spawn(name, cmd, opts)
|
||||
let job.lines = ['Failed to start job']
|
||||
endif
|
||||
else
|
||||
let params = has_key(a:opts, 'dir') ? [a:cmd, a:opts.dir] : [a:cmd]
|
||||
let job.lines = s:lines(call('s:system', params))
|
||||
let job.lines = s:lines(call('s:system', [cmd]))
|
||||
let job.error = v:shell_error != 0
|
||||
let job.running = 0
|
||||
endif
|
||||
@@ -1227,6 +1262,9 @@ function! s:reap(name)
|
||||
call s:log(bullet, a:name, empty(result) ? 'OK' : result)
|
||||
call s:bar()
|
||||
|
||||
if has_key(job, 'batchfile') && !empty(job.batchfile)
|
||||
call delete(job.batchfile)
|
||||
endif
|
||||
call remove(s:jobs, a:name)
|
||||
endfunction
|
||||
|
||||
@@ -1293,7 +1331,7 @@ while 1 " Without TCO, Vim stack is bound to explode
|
||||
|
||||
let name = keys(s:update.todo)[0]
|
||||
let spec = remove(s:update.todo, name)
|
||||
let new = !isdirectory(spec.dir)
|
||||
let new = empty(globpath(spec.dir, '.git', 1))
|
||||
|
||||
call s:log(new ? '+' : '*', name, pull ? 'Updating ...' : 'Installing ...')
|
||||
redraw
|
||||
@@ -1776,6 +1814,7 @@ function! s:update_ruby()
|
||||
tries = VIM::evaluate('get(g:, "plug_retries", 2)') + 1
|
||||
nthr = VIM::evaluate('s:update.threads').to_i
|
||||
maxy = VIM::evaluate('winheight(".")').to_i
|
||||
vim7 = VIM::evaluate('v:version').to_i <= 703 && RUBY_PLATFORM =~ /darwin/
|
||||
cd = iswin ? 'cd /d' : 'cd'
|
||||
tot = VIM::evaluate('len(s:update.todo)') || 0
|
||||
bar = ''
|
||||
@@ -1865,11 +1904,17 @@ function! s:update_ruby()
|
||||
main = Thread.current
|
||||
threads = []
|
||||
watcher = Thread.new {
|
||||
require 'io/console' # >= Ruby 1.9
|
||||
nil until IO.console.getch == 3.chr
|
||||
if vim7
|
||||
while VIM::evaluate('getchar(1)')
|
||||
sleep 0.1
|
||||
end
|
||||
else
|
||||
require 'io/console' # >= Ruby 1.9
|
||||
nil until IO.console.getch == 3.chr
|
||||
end
|
||||
mtx.synchronize do
|
||||
running = false
|
||||
threads.each { |t| t.raise Interrupt }
|
||||
threads.each { |t| t.raise Interrupt } unless vim7
|
||||
end
|
||||
threads.each { |t| t.join rescue nil }
|
||||
main.kill
|
||||
@@ -1937,8 +1982,19 @@ function! s:update_ruby()
|
||||
EOF
|
||||
endfunction
|
||||
|
||||
function! s:shellesc_cmd(arg)
|
||||
let escaped = substitute(a:arg, '[&|<>()@^]', '^&', 'g')
|
||||
let escaped = substitute(escaped, '%', '%%', 'g')
|
||||
let escaped = substitute(escaped, '"', '\\^&', 'g')
|
||||
let escaped = substitute(escaped, '\(\\\+\)\(\\^\)', '\1\1\2', 'g')
|
||||
return '^"'.substitute(escaped, '\(\\\+\)$', '\1\1', '').'^"'
|
||||
endfunction
|
||||
|
||||
function! s:shellesc(arg)
|
||||
return '"'.escape(a:arg, '"').'"'
|
||||
if &shell =~# 'cmd.exe$'
|
||||
return s:shellesc_cmd(a:arg)
|
||||
endif
|
||||
return shellescape(a:arg)
|
||||
endfunction
|
||||
|
||||
function! s:glob_dir(path)
|
||||
@@ -1976,11 +2032,19 @@ endfunction
|
||||
|
||||
function! s:system(cmd, ...)
|
||||
try
|
||||
let [sh, shrd] = s:chsh(1)
|
||||
let [sh, shellcmdflag, shrd] = s:chsh(1)
|
||||
let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd
|
||||
if s:is_win
|
||||
let batchfile = tempname().'.bat'
|
||||
call writefile(["@echo off\r", cmd . "\r"], batchfile)
|
||||
let cmd = batchfile
|
||||
endif
|
||||
return system(s:is_win ? '('.cmd.')' : cmd)
|
||||
finally
|
||||
let [&shell, &shellredir] = [sh, shrd]
|
||||
let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd]
|
||||
if s:is_win
|
||||
call delete(batchfile)
|
||||
endif
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
@@ -2015,7 +2079,7 @@ function! s:git_validate(spec, check_branch)
|
||||
" Check tag
|
||||
if has_key(a:spec, 'tag')
|
||||
let tag = s:system_chomp('git describe --exact-match --tags HEAD 2>&1', a:spec.dir)
|
||||
if a:spec.tag !=# tag
|
||||
if a:spec.tag !=# tag && a:spec.tag !~ '\*'
|
||||
let err = printf('Invalid tag: %s (expected: %s). Try PlugUpdate.',
|
||||
\ (empty(tag) ? 'N/A' : tag), a:spec.tag)
|
||||
endif
|
||||
@@ -2025,10 +2089,21 @@ function! s:git_validate(spec, check_branch)
|
||||
\ branch, a:spec.branch)
|
||||
endif
|
||||
if empty(err)
|
||||
let commits = len(s:lines(s:system(printf('git rev-list origin/%s..HEAD', a:spec.branch), a:spec.dir)))
|
||||
if !v:shell_error && commits
|
||||
let err = join([printf('Diverged from origin/%s by %d commit(s).', a:spec.branch, commits),
|
||||
\ 'Reinstall after PlugClean.'], "\n")
|
||||
let [ahead, behind] = split(s:lastline(s:system(printf(
|
||||
\ 'git rev-list --count --left-right HEAD...origin/%s',
|
||||
\ a:spec.branch), a:spec.dir)), '\t')
|
||||
if !v:shell_error && ahead
|
||||
if behind
|
||||
" Only mention PlugClean if diverged, otherwise it's likely to be
|
||||
" pushable (and probably not that messed up).
|
||||
let err = printf(
|
||||
\ "Diverged from origin/%s (%d commit(s) ahead and %d commit(s) behind!\n"
|
||||
\ .'Backup local changes and run PlugClean and PlugUpdate to reinstall it.', a:spec.branch, ahead, behind)
|
||||
else
|
||||
let err = printf("Ahead of origin/%s by %d commit(s).\n"
|
||||
\ .'Cannot update until local changes are pushed.',
|
||||
\ a:spec.branch, ahead)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
@@ -2184,15 +2259,16 @@ function! s:status()
|
||||
let unloaded = 0
|
||||
let [cnt, total] = [0, len(g:plugs)]
|
||||
for [name, spec] in items(g:plugs)
|
||||
let is_dir = isdirectory(spec.dir)
|
||||
if has_key(spec, 'uri')
|
||||
if isdirectory(spec.dir)
|
||||
if is_dir
|
||||
let [err, _] = s:git_validate(spec, 1)
|
||||
let [valid, msg] = [empty(err), empty(err) ? 'OK' : err]
|
||||
else
|
||||
let [valid, msg] = [0, 'Not found. Try PlugInstall.']
|
||||
endif
|
||||
else
|
||||
if isdirectory(spec.dir)
|
||||
if is_dir
|
||||
let [valid, msg] = [1, 'OK']
|
||||
else
|
||||
let [valid, msg] = [0, 'Not found.']
|
||||
@@ -2201,7 +2277,7 @@ function! s:status()
|
||||
let cnt += 1
|
||||
let ecnt += !valid
|
||||
" `s:loaded` entry can be missing if PlugUpgraded
|
||||
if valid && get(s:loaded, name, -1) == 0
|
||||
if is_dir && get(s:loaded, name, -1) == 0
|
||||
let unloaded = 1
|
||||
let msg .= ' (not loaded)'
|
||||
endif
|
||||
@@ -2271,7 +2347,7 @@ function! s:preview_commit()
|
||||
let b:plug_preview = !s:is_preview_window_open()
|
||||
endif
|
||||
|
||||
let sha = matchstr(getline('.'), '^ \X*\zs[0-9a-f]\{7}')
|
||||
let sha = matchstr(getline('.'), '^ \X*\zs[0-9a-f]\{7,9}')
|
||||
if empty(sha)
|
||||
return
|
||||
endif
|
||||
@@ -2289,7 +2365,21 @@ function! s:preview_commit()
|
||||
wincmd P
|
||||
endif
|
||||
setlocal previewwindow filetype=git buftype=nofile nobuflisted modifiable
|
||||
execute 'silent %!cd' s:shellesc(g:plugs[name].dir) '&& git show --no-color --pretty=medium' sha
|
||||
try
|
||||
let [sh, shellcmdflag, shrd] = s:chsh(1)
|
||||
let cmd = 'cd '.s:shellesc(g:plugs[name].dir).' && git show --no-color --pretty=medium '.sha
|
||||
if s:is_win
|
||||
let batchfile = tempname().'.bat'
|
||||
call writefile(["@echo off\r", cmd . "\r"], batchfile)
|
||||
let cmd = batchfile
|
||||
endif
|
||||
execute 'silent %!' cmd
|
||||
finally
|
||||
let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd]
|
||||
if s:is_win
|
||||
call delete(batchfile)
|
||||
endif
|
||||
endtry
|
||||
setlocal nomodifiable
|
||||
nnoremap <silent> <buffer> q :q<cr>
|
||||
wincmd p
|
||||
@@ -2330,7 +2420,7 @@ function! s:diff()
|
||||
call s:append_ul(2, origin ? 'Pending updates:' : 'Last update:')
|
||||
for [k, v] in plugs
|
||||
let range = origin ? '..origin/'.v.branch : 'HEAD@{1}..'
|
||||
let diff = s:system_chomp('git log --graph --color=never --pretty=format:"%x01%h%x01%d%x01%s%x01%cr" '.s:shellesc(range), v.dir)
|
||||
let diff = s:system_chomp('git log --graph --color=never '.join(map(['--pretty=format:%x01%h%x01%d%x01%s%x01%cr', range], 's:shellesc(v:val)')), v.dir)
|
||||
if !empty(diff)
|
||||
let ref = has_key(v, 'tag') ? (' (tag: '.v.tag.')') : has_key(v, 'commit') ? (' '.v.commit) : ''
|
||||
call append(5, extend(['', '- '.k.':'.ref], map(s:lines(diff), 's:format_git_log(v:val)')))
|
||||
@@ -2349,8 +2439,13 @@ function! s:diff()
|
||||
\ . (cnts[1] ? printf(' %d plugin(s) have pending updates.', cnts[1]) : ''))
|
||||
|
||||
if cnts[0] || cnts[1]
|
||||
nnoremap <silent> <buffer> <cr> :silent! call <SID>preview_commit()<cr>
|
||||
nnoremap <silent> <buffer> o :silent! call <SID>preview_commit()<cr>
|
||||
nnoremap <silent> <buffer> <plug>(plug-preview) :silent! call <SID>preview_commit()<cr>
|
||||
if empty(maparg("\<cr>", 'n'))
|
||||
nmap <buffer> <cr> <plug>(plug-preview)
|
||||
endif
|
||||
if empty(maparg('o', 'n'))
|
||||
nmap <buffer> o <plug>(plug-preview)
|
||||
endif
|
||||
endif
|
||||
if cnts[0]
|
||||
nnoremap <silent> <buffer> X :call <SID>revert()<cr>
|
||||
@@ -2371,7 +2466,7 @@ function! s:revert()
|
||||
return
|
||||
endif
|
||||
|
||||
call s:system('git reset --hard HEAD@{1} && git checkout '.s:esc(g:plugs[name].branch), g:plugs[name].dir)
|
||||
call s:system('git reset --hard HEAD@{1} && git checkout '.s:esc(g:plugs[name].branch).' --', g:plugs[name].dir)
|
||||
setlocal modifiable
|
||||
normal! "_dap
|
||||
setlocal nomodifiable
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
**********************************************************************
|
||||
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()
|
||||
@@ -7,13 +8,14 @@ Execute (#112 On-demand loading should not suppress messages from ftplugin):
|
||||
redir => out
|
||||
tabnew a.c
|
||||
redir END
|
||||
Assert stridx(out, 'ftplugin-c') >= 0
|
||||
Assert stridx(out, 'ftplugin-c') >= 0, 'Unexpected output (1): '.out
|
||||
|
||||
* The same applies to plug#load())
|
||||
call ResetPlug()
|
||||
redir => out
|
||||
call plug#load('ftplugin-msg')
|
||||
redir END
|
||||
Assert stridx(out, 'ftplugin-c') >= 0
|
||||
Assert stridx(out, 'ftplugin-c') >= 0, 'Unexpected output (2): '.out
|
||||
q
|
||||
|
||||
|
||||
@@ -39,6 +41,7 @@ Execute (#130 Proper cleanup of on-demand loading triggers):
|
||||
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'
|
||||
@@ -89,10 +92,11 @@ Execute (#139-1 Using new remote branch):
|
||||
PlugUpdate
|
||||
|
||||
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'
|
||||
Assert !exists('g:baz'), 'g:baz should not be found'
|
||||
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)'
|
||||
|
||||
" Create a new branch on origin
|
||||
call system('cd /tmp/vim-plug-test/new-branch && git checkout -b new &&'
|
||||
@@ -110,10 +114,11 @@ 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'
|
||||
Assert exists('g:bar'), 'g:bar should be found'
|
||||
Assert !exists('g:baz'), 'g:baz should not be found'
|
||||
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)'
|
||||
|
||||
call PlugStatusSorted()
|
||||
|
||||
@@ -140,6 +145,7 @@ 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'
|
||||
@@ -225,7 +231,7 @@ Execute (#159: shell=/bin/tcsh):
|
||||
**********************************************************************
|
||||
Execute (#154: Spaces in &rtp should not be escaped):
|
||||
call plug#begin('/tmp/vim-plug-test/plug it')
|
||||
Plug 'seoul256 vim'
|
||||
Plug 'foo/seoul256 vim'
|
||||
call plug#end()
|
||||
Log &rtp
|
||||
Assert stridx(&rtp, 'plug it/seoul256 vim') >= 0
|
||||
@@ -233,12 +239,12 @@ Execute (#154: Spaces in &rtp should not be escaped):
|
||||
**********************************************************************
|
||||
Execute (#184: Duplicate entries in &rtp):
|
||||
call plug#begin('/tmp/vim-plug-test/plugged')
|
||||
Plug 'plugin1'
|
||||
\| Plug 'plugin0'
|
||||
Plug 'foo/plugin1'
|
||||
\| Plug 'foo/plugin0'
|
||||
|
||||
Plug 'plugin2'
|
||||
\| Plug 'plugin0'
|
||||
\| Plug 'plugin1'
|
||||
Plug 'foo/plugin2'
|
||||
\| Plug 'foo/plugin0'
|
||||
\| Plug 'foo/plugin1'
|
||||
call plug#end()
|
||||
|
||||
Log &rtp
|
||||
@@ -304,17 +310,19 @@ Execute (#474: Load ftdetect files in filetypedetect augroup):
|
||||
bd
|
||||
|
||||
**********************************************************************
|
||||
Execute (#489 On-demand loading with 'on' option should trigger BufRead autocmd):
|
||||
Execute (#489/#587 On-demand loading with 'on' option should trigger BufRead autocmd w/o nomodeline):
|
||||
call plug#begin('$PLUG_FIXTURES')
|
||||
Plug 'ftplugin-msg', { 'on': 'XXX' }
|
||||
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
|
||||
q
|
||||
AssertEqual 'lava', &filetype
|
||||
q!
|
||||
|
||||
**********************************************************************
|
||||
Execute (Cursor moved to another window during post-update hook):
|
||||
@@ -330,3 +338,38 @@ Execute (Cursor moved to another window during post-update hook):
|
||||
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).
|
||||
[=]
|
||||
|
||||
37
test/run
37
test/run
@@ -1,6 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd $(dirname "${BASH_SOURCE[0]}")
|
||||
# Privileged mode, ignores $CDPATH etc.
|
||||
set -p
|
||||
set -eu
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
|
||||
export BASE="$PWD"
|
||||
export PLUG_SRC="$PWD/../plug.vim"
|
||||
@@ -16,8 +20,8 @@ set shell=/bin/bash
|
||||
VIMRC
|
||||
|
||||
clone() {
|
||||
if [ ! -d $2 ]; then
|
||||
git clone $1 $2
|
||||
if [ ! -d "$2" ]; then
|
||||
git clone "$1" "$2"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -44,8 +48,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', [])
|
||||
@@ -73,13 +77,17 @@ 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/ftplugin"
|
||||
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"
|
||||
|
||||
@@ -91,13 +99,15 @@ DOC
|
||||
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
|
||||
@@ -109,13 +119,12 @@ clone_repos
|
||||
prepare
|
||||
|
||||
git --version
|
||||
VIM=$(select_vim)
|
||||
echo "Selected Vim: $VIM"
|
||||
if [ "$1" = '!' ]; then
|
||||
$VIM -Nu $TEMP/mini-vimrc -c 'Vader! test.vader' > /dev/null &&
|
||||
vim=$(select_vim)
|
||||
echo "Selected Vim: $vim"
|
||||
if [ "${1:-}" = '!' ]; then
|
||||
$vim -Nu $TEMP/mini-vimrc -c 'Vader! test.vader' > /dev/null &&
|
||||
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
|
||||
else
|
||||
$VIM -Nu $TEMP/mini-vimrc -c 'Vader test.vader'
|
||||
$vim -Nu $TEMP/mini-vimrc -c 'Vader test.vader'
|
||||
fi
|
||||
|
||||
|
||||
@@ -37,9 +37,10 @@ Execute (Initialize test environment):
|
||||
g/^$/d
|
||||
endfunction
|
||||
|
||||
function! AssertExpect(bang, pat, cnt)
|
||||
function! AssertExpect(bang, pat, cnt, ...)
|
||||
let op = a:bang ? '==#' : '=~#'
|
||||
AssertEqual a:cnt, len(filter(getline(1, '$'), "v:val ".op." '".a:pat."'"))
|
||||
let args = [a:cnt, len(filter(getline(1, '$'), "v:val ".op." '".a:pat."'"))] + a:000
|
||||
call call('vader#assert#equal', args)
|
||||
endfunction
|
||||
command! -nargs=+ -bang AssertExpect call AssertExpect('<bang>' == '!', <args>)
|
||||
|
||||
|
||||
@@ -19,6 +19,13 @@ 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'
|
||||
@@ -57,12 +64,17 @@ Execute (Test Plug command):
|
||||
AssertEqual join([g:temp_plugged, 'vim-emoji/'], '/'), g:plugs['vim-emoji'].dir
|
||||
|
||||
" vim-scripts/
|
||||
Plug 'beauty256'
|
||||
Plug 'vim-scripts/beauty256'
|
||||
AssertEqual 'file:///tmp/vim-plug-test/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)
|
||||
Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co', 'rtp': '././' }
|
||||
@@ -212,7 +224,7 @@ Expect:
|
||||
[==]
|
||||
x seoul256.vim:
|
||||
|
||||
Execute (Corrected the URI but diverged from master):
|
||||
Execute (Corrected the URI but ahead of upstream):
|
||||
call plug#begin()
|
||||
Plug 'junegunn/seoul256.vim'
|
||||
Plug 'file:///tmp/vim-plug-test/jg/vim-emoji'
|
||||
@@ -223,8 +235,8 @@ Execute (Corrected the URI but diverged from master):
|
||||
call PlugStatusSorted()
|
||||
|
||||
Expect:
|
||||
Diverged from origin/master by 3 commit(s).
|
||||
Reinstall after PlugClean.
|
||||
Ahead of origin/master by 3 commit(s).
|
||||
Cannot update until local changes are pushed.
|
||||
- vim-emoji: OK
|
||||
Finished. 1 error(s).
|
||||
[==]
|
||||
@@ -237,11 +249,44 @@ Expect:
|
||||
# q
|
||||
# PGdd
|
||||
|
||||
Execute (PlugClean! to remove seoul256.vim):
|
||||
Execute (PlugClean! keeps seoul256.vim):
|
||||
PlugClean!
|
||||
" Three removed, emoji left
|
||||
AssertEqual 'Removed 3 directories.', getline(4)
|
||||
AssertExpect '^\~ ', 3
|
||||
" 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
|
||||
Assert empty(globpath(&rtp, 'colors/seoul256.vim'))
|
||||
Assert !empty(globpath(&rtp, 'autoload/emoji.vim'))
|
||||
@@ -270,8 +315,8 @@ Execute (PlugClean! to remove vim-emoji):
|
||||
PlugClean!
|
||||
AssertExpect '^\~ ', 1
|
||||
AssertEqual 'Removed 1 directories.', getline(4)
|
||||
Assert empty(globpath(&rtp, 'colors/seoul256.vim'))
|
||||
Assert empty(globpath(&rtp, 'autoload/emoji.vim'))
|
||||
Assert empty(globpath(&rtp, 'colors/seoul256.vim')), 'seoul256.vim was removed'
|
||||
Assert empty(globpath(&rtp, 'autoload/emoji.vim')), 'emoji was removed'
|
||||
q
|
||||
|
||||
Execute (PlugUpdate to install both again):
|
||||
@@ -283,7 +328,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
|
||||
AssertExpect 'Already up.to.date', 2, 'Expected 2 times "Already up-to-date", but got: '.string(getline(1, '$'))
|
||||
normal D
|
||||
AssertEqual '0 plugin(s) updated.', getline(1)
|
||||
q
|
||||
@@ -325,8 +370,15 @@ Execute (New commits on remote, PlugUpdate, then PlugDiff):
|
||||
AssertEqual 1, &previewwindow
|
||||
AssertEqual 'git', &filetype
|
||||
|
||||
" Back to plug window
|
||||
wincmd p
|
||||
" 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'
|
||||
|
||||
" ]] motion
|
||||
execute 'normal $]]'
|
||||
@@ -381,6 +433,27 @@ Execute (Test g:plug_pwindow):
|
||||
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
|
||||
@@ -471,7 +544,7 @@ Execute (PlugDiff):
|
||||
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')
|
||||
@@ -1064,16 +1137,28 @@ 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')
|
||||
@@ -1081,6 +1166,12 @@ 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': [] }
|
||||
@@ -1175,7 +1266,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 'beauty256'
|
||||
Plug 'vim-scripts/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
|
||||
@@ -1419,8 +1510,8 @@ Execute (Commit hash support):
|
||||
PlugUpdate
|
||||
Log getline(1, '$')
|
||||
AssertEqual 'x goyo.vim:', getline(5)
|
||||
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 ' fatal: invalid reference: ffffffff', getline(6)
|
||||
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]
|
||||
AssertEqual '9db7fcfee0d90dafdbcb7a32090c0a9085eb054a', hash
|
||||
@@ -1529,21 +1620,33 @@ Execute (#532 - Reuse plug window):
|
||||
call system(printf('cd "%s" && git commit --allow-empty -m "dummy"', g:plugs['goyo.vim'].dir))
|
||||
|
||||
PlugDiff
|
||||
AssertEqual 1, winnr()
|
||||
AssertEqual 2, winnr('$')
|
||||
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()
|
||||
AssertEqual 3, winnr('$')
|
||||
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()
|
||||
AssertEqual 3, winnr('$')
|
||||
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()
|
||||
AssertEqual 2, winnr('$')
|
||||
AssertEqual 2, winnr(), 'Current window is #2 after PlugStatus (but is '.winnr().')'
|
||||
AssertEqual 2, winnr('$'), 'Three windows after PlugStatus (but got '.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
|
||||
|
||||
Reference in New Issue
Block a user