Compare commits

..

16 Commits

Author SHA1 Message Date
Junegunn Choi
d80f495fab
Allow pressing 'q' to abort the running tasks, then 'R' to retry (#1289)
If you press 'q' while `PlugInstall` or `PlugUpdate` is in progress,
the current version of vim-plug immediately closes its window and aborts
all the running processes.

This commit enhances the 'q' map so that it doesn't close the window,
but instead displays the aborted tasks so that the user can press 'R' to
retry the tasks.

Fix #1285
2024-07-09 20:09:41 +09:00
Junegunn Choi
d863d07832
Add more explanation on plug#end() 2024-06-19 20:05:15 +09:00
Junegunn Choi
b98b66242b
Fix PlugClean when &shell is powershell on Windows (#1283) 2024-06-18 18:02:36 +09:00
Junegunn Choi
db37a8a29a
Update comment in plug.vim 2024-06-01 15:58:29 +09:00
Junegunn Choi
7095372c4b
Add colorscheme example (should be loaded after plug#end()) 2024-06-01 15:40:24 +09:00
Junegunn Choi
3f1daea5bd
Adjust heading levels in README 2024-05-15 03:07:01 +09:00
Junegunn Choi
9b4ecd1bb5
Update documentation (#1280) 2024-05-14 19:06:23 +09:00
Junegunn Choi
c0992146e2
Update README 2024-05-14 17:20:08 +09:00
Junegunn Choi
47ca942ea4
Update README 2024-05-14 16:57:04 +09:00
Junegunn Choi
d977fa3786
Do not remove 'frozen' plugins on PlugClean
Close #1152
2024-03-31 00:53:55 +09:00
Junegunn Choi
24d7ac280f
Remove dead code
Close #1194
2024-03-29 13:02:03 +09:00
Junegunn Choi
2cd7bf673b
README: Fix typo 2024-03-15 23:16:01 +09:00
Junegunn Choi
d54f8d5bbd
README: Use markdown alerts (#1276) 2024-03-15 21:22:16 +09:00
Junegunn Choi
61b6df67b4
Update examples 2024-03-14 19:11:37 +09:00
Junegunn Choi
94b7aa99a9
Update README and vimdoc 2024-03-07 23:41:50 +09:00
DanielApt
03a9bb6d84
Add reload/restart step to usage section (#1255)
Reloading the .vimrc should be part of the usage section, not the example section.
2024-03-07 23:31:28 +09:00
4 changed files with 526 additions and 399 deletions

339
README.md
View File

@ -30,12 +30,15 @@ A minimalist Vim plugin manager.
<img src="https://raw.githubusercontent.com/junegunn/i/master/vim-plug/installer.gif" height="450"> <img src="https://raw.githubusercontent.com/junegunn/i/master/vim-plug/installer.gif" height="450">
### Pros. ## Pros.
- Easy to set up: Single file. No boilerplate code required. - Minimalist design
- Easy to use: Concise, intuitive syntax - Just one file with no dependencies. Super easy to set up.
- Concise, intuitive syntax that you can learn within minutes. No boilerplate code required.
- No feature bloat
- Extremely stable with flawless backward compatibility
- Works perfectly with all versions of Vim since 2006 and all versions of Neovim ever released
- [Super-fast][40/4] parallel installation/update - [Super-fast][40/4] parallel installation/update
(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
- On-demand loading for [faster startup time][startup-time] - On-demand loading for [faster startup time][startup-time]
- Can review and rollback updates - Can review and rollback updates
@ -44,17 +47,19 @@ A minimalist Vim plugin manager.
- Support for externally managed plugins - Support for externally managed plugins
[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/
[startup-time]: https://github.com/junegunn/vim-startuptime-benchmark#result [startup-time]: https://github.com/junegunn/vim-startuptime-benchmark#result
### 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 <details>
<summary>Click to see the instructions</summary>
###### Unix ### Vim
#### Unix
```sh ```sh
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
@ -66,59 +71,94 @@ file as suggested [here][auto].
[auto]: https://github.com/junegunn/vim-plug/wiki/tips#automatic-installation [auto]: https://github.com/junegunn/vim-plug/wiki/tips#automatic-installation
###### Windows (PowerShell) #### Windows (PowerShell)
```powershell ```powershell
iwr -useb https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |` iwr -useb https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |`
ni $HOME/vimfiles/autoload/plug.vim -Force ni $HOME/vimfiles/autoload/plug.vim -Force
``` ```
#### Neovim ### Neovim
###### Unix, Linux #### Unix, Linux
```sh ```sh
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \ 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' https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
``` ```
###### Linux (Flatpak) #### Linux (Flatpak)
```sh ```sh
curl -fLo ~/.var/app/io.neovim.nvim/data/nvim/site/autoload/plug.vim --create-dirs \ 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 |` 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 ni "$(@($env:XDG_DATA_HOME, $env:LOCALAPPDATA)[$null -eq $env:XDG_DATA_HOME])/nvim-data/site/autoload/plug.vim" -Force
``` ```
</details>
## Usage
Add a vim-plug section to your `~/.vimrc` (or `~/.config/nvim/init.vim` for Neovim)
1. Begin the section with `call plug#begin()`
1. List the plugins with `Plug` commands
1. End the section with `call plug#end()`
For example,
```vim
call plug#begin()
" List your plugins here
Plug 'tpope/vim-sensible'
call plug#end()
```
Reload the file or restart Vim, then you can,
* `:PlugInstall` to install the plugins
* `:PlugUpdate` to install or update the plugins
* `:PlugDiff` to review the changes from the last update
* `:PlugClean` to remove plugins no longer in the list
> [!NOTE]
> That's basically all you need to know to get started. The rest of the
> document is for advanced users who want to know more about the features and
> options.
> [!TIP]
> `plug#end()` automatically executes `filetype plugin indent on` and `syntax
> enable`. We believe this is a good default for most users, but if you don't
> want this behavior, you can revert the settings after the call.
>
> ```vim
> call plug#end()
> filetype indent off " Disable file-type-specific indentation
> syntax off " Disable syntax highlighting
> ```
### Getting Help ### Getting Help
- See [tutorial] page to learn the basics of vim-plug - See [tutorial] page to learn more about the basics of vim-plug
- See [tips] and [FAQ] pages for common problems and questions - 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 [tutorial]: https://github.com/junegunn/vim-plug/wiki/tutorial
[tips]: https://github.com/junegunn/vim-plug/wiki/tips [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
### Usage ## Examples
Add a vim-plug section to your `~/.vimrc` (or `stdpath('config') . '/init.vim'` for Neovim) The following examples demonstrate the additional features of vim-plug.
1. Begin the section with `call plug#begin([PLUGIN_DIR])` ### Vim script example
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 ```vim
call plug#begin() call plug#begin()
@ -132,48 +172,55 @@ call plug#begin()
" Make sure you use single quotes " Make sure you use single quotes
" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align " Shorthand notation for GitHub; translates to https://github.com/junegunn/seoul256.vim.git
Plug 'junegunn/vim-easy-align' Plug 'junegunn/seoul256.vim'
" 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-easy-align.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) " Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
Plug 'fatih/vim-go', { 'tag': '*' } Plug 'fatih/vim-go', { 'tag': '*' }
" Plugin options " Using a non-default branch
Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' } Plug 'neoclide/coc.nvim', { 'branch': 'release' }
" Plugin outside ~/.vim/plugged with post-update hook " Use 'dir' option to install plugin in a non-default directory
Plug 'junegunn/fzf', { 'dir': '~/.fzf' }
" Post-update hook: run a shell command after installing or updating the plugin
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
" Post-update hook can be a lambda expression
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
" If the vim plugin is in a subdirectory, use 'rtp' option to specify its path
Plug 'nsf/gocode', { 'rtp': 'vim' }
" On-demand loading: loaded when the specified command is executed
Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
" On-demand loading: loaded when a file with a specific file type is opened
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
" Unmanaged plugin (manually installed and updated) " Unmanaged plugin (manually installed and updated)
Plug '~/my-prototype-plugin' Plug '~/my-prototype-plugin'
" Initialize plugin system " Call plug#end to update &runtimepath and initialize the plugin system.
" - Automatically executes `filetype plugin indent on` and `syntax enable`. " - It 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: " You can revert the settings after the call like so:
" filetype indent off " Disable file-type-specific indentation " filetype indent off " Disable file-type-specific indentation
" syntax off " Disable syntax highlighting " syntax off " Disable syntax highlighting
" Color schemes should be loaded after plug#end().
" We prepend it with 'silent!' to ignore errors when it's not yet installed.
silent! colorscheme seoul256
``` ```
Reload .vimrc and `:PlugInstall` to install plugins. ### Lua example for Neovim
#### Example (Lua configuration for Neovim)
In Neovim, you can write your configuration in a Lua script file named 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 `init.lua`. The following code is the Lua script equivalent to the Vim script
example above. example above.
```lua ```lua
@ -182,42 +229,49 @@ local Plug = vim.fn['plug#']
vim.call('plug#begin') vim.call('plug#begin')
-- Shorthand notation; fetches https://github.com/junegunn/vim-easy-align -- Shorthand notation for GitHub; translates to https://github.com/junegunn/seoul256.vim.git
Plug('junegunn/vim-easy-align') Plug('junegunn/seoul256.vim')
-- 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-easy-align.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) -- Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
Plug('fatih/vim-go', { ['tag'] = '*' }) Plug('fatih/vim-go', { ['tag'] = '*' })
-- Plugin options -- Using a non-default branch
Plug('nsf/gocode', { ['tag'] = 'v.20150303', ['rtp'] = 'vim' }) Plug('neoclide/coc.nvim', { ['branch'] = 'release' })
-- Plugin outside ~/.vim/plugged with post-update hook -- Use 'dir' option to install plugin in a non-default directory
Plug('junegunn/fzf', { ['dir'] = '~/.fzf' })
-- Post-update hook: run a shell command after installing or updating the plugin
Plug('junegunn/fzf', { ['dir'] = '~/.fzf', ['do'] = './install --all' }) Plug('junegunn/fzf', { ['dir'] = '~/.fzf', ['do'] = './install --all' })
-- Post-update hook can be a lambda expression
Plug('junegunn/fzf', { ['do'] = function()
vim.fn['fzf#install']()
end })
-- If the vim plugin is in a subdirectory, use 'rtp' option to specify its path
Plug('nsf/gocode', { ['rtp'] = 'vim' })
-- On-demand loading: loaded when the specified command is executed
Plug('preservim/nerdtree', { ['on'] = 'NERDTreeToggle' })
-- On-demand loading: loaded when a file with a specific file type is opened
Plug('tpope/vim-fireplace', { ['for'] = 'clojure' })
-- Unmanaged plugin (manually installed and updated) -- Unmanaged plugin (manually installed and updated)
Plug('~/my-prototype-plugin') Plug('~/my-prototype-plugin')
vim.call('plug#end') vim.call('plug#end')
-- Color schemes should be loaded after plug#end().
-- We prepend it with 'silent!' to ignore errors when it's not yet installed.
vim.cmd('silent! colorscheme seoul256')
``` ```
More examples can be found in: ## Commands
* https://gitlab.com/sultanahamer/dotfiles/-/blob/master/nvim/lua/plugins.lua?ref_type=heads
### Commands
| Command | Description | | Command | Description |
| ----------------------------------- | ------------------------------------------------------------------ | | ----------------------------------- | ------------------------------------------------------------------ |
@ -229,10 +283,10 @@ More examples can be found in:
| `PlugDiff` | Examine changes from the previous update and the pending changes | | `PlugDiff` | Examine changes from the previous update and the pending changes |
| `PlugSnapshot[!] [output path]` | Generate script for restoring the current snapshot of the plugins | | `PlugSnapshot[!] [output path]` | Generate script for restoring the current snapshot of the plugins |
### `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 |
@ -240,9 +294,9 @@ More examples can be found in:
| `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 or `<Plug>`-mappings |
| `for` | On-demand loading: File types | | `for` | On-demand loading: File types |
| `frozen` | Do not update unless explicitly specified | | `frozen` | Do not remove and do not update unless explicitly specified |
### Global options ## Global options
| Flag | Default | Description | | Flag | Default | Description |
| ------------------- | --------------------------------- | ------------------------------------------------------ | | ------------------- | --------------------------------- | ------------------------------------------------------ |
@ -255,54 +309,19 @@ More examples can be found in:
| `g:plug_url_format` | `https://git::@github.com/%s.git` | `printf` format to build repo URL (Only applies to the subsequent `Plug` commands) | | `g:plug_url_format` | `https://git::@github.com/%s.git` | `printf` format to build repo URL (Only applies to the subsequent `Plug` commands) |
### Keybindings ## Keybindings
- `D` - `PlugDiff` - `D` - `PlugDiff`
- `S` - `PlugStatus` - `S` - `PlugStatus`
- `R` - Retry failed update or installation tasks - `R` - Retry failed update or installation tasks
- `U` - Update plugins in the selected range - `U` - Update plugins in the selected range
- `q` - Close the window - `q` - Abort the running tasks or close the window
- `:PlugStatus` - `:PlugStatus`
- `L` - Load plugin - `L` - Load plugin
- `:PlugDiff` - `:PlugDiff`
- `X` - Revert the update - `X` - Revert the update
### Example: A small [sensible](https://github.com/tpope/vim-sensible) Vim configuration ## Post-update hooks
```vim
call plug#begin()
Plug 'tpope/vim-sensible'
call plug#end()
```
### On-demand loading of plugins
```vim
" 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
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 the `do` option to describe the task to be performed.
@ -345,21 +364,22 @@ 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 when the repository has changed, but you can force it to run unconditionally
with the bang-versions of the commands: `PlugInstall!` and `PlugUpdate!`. with the bang-versions of the commands: `PlugInstall!` and `PlugUpdate!`.
Make sure to escape BARs and double-quotes when you write the `do` option > [!TIP]
inline as they are mistakenly recognized as command separator or the start of > Make sure to escape BARs and double-quotes when you write the `do` option
the trailing comment. > inline as they are mistakenly recognized as command separator or the start of
> the trailing comment.
```vim >
Plug 'junegunn/fzf', { 'do': 'yes \| ./install' } > ```vim
``` > Plug 'junegunn/fzf', { 'do': 'yes \| ./install' }
> ```
But you can avoid the escaping if you extract the inline specification using a >
variable (or any Vimscript expression) as follows: > But you can avoid the escaping if you extract the inline specification using a
> variable (or any Vim script expression) as follows:
```vim >
let g:fzf_install = 'yes | ./install' > ```vim
Plug 'junegunn/fzf', { 'do': g:fzf_install } > let g:fzf_install = 'yes | ./install'
``` > Plug 'junegunn/fzf', { 'do': g:fzf_install }
> ```
### `PlugInstall!` and `PlugUpdate!` ### `PlugInstall!` and `PlugUpdate!`
@ -373,18 +393,71 @@ The installer takes the following steps when installing/updating a plugin:
The commands with the `!` suffix ensure that all steps are run unconditionally. The commands with the `!` suffix ensure that all steps are run unconditionally.
### Articles ## On-demand loading of plugins
- [Writing my own Vim plugin manager](http://junegunn.kr/2013/09/writing-my-own-vim-plugin-manager) ```vim
- [Vim plugins and startup time](http://junegunn.kr/2014/07/vim-plugins-and-startup-time) " NERD tree will be loaded on the first invocation of NERDTreeToggle command
- ~~[Thoughts on Vim plugin dependency](http://junegunn.kr/2013/09/thoughts-on-vim-plugin-dependency)~~ Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
- *Support for Plugfile has been removed since 0.5.0*
### Collaborators " Multiple commands
Plug 'junegunn/vim-github-dashboard', { 'on': ['GHDashboard', 'GHActivity'] }
" Loaded when clojure file is opened
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
" Multiple file types
Plug 'kovisoft/paredit', { 'for': ['clojure', 'scheme'] }
" On-demand loading on both conditions
Plug 'junegunn/vader.vim', { 'on': 'Vader', 'for': 'vader' }
" Code to execute when the plugin is lazily loaded on demand
Plug 'junegunn/goyo.vim', { 'for': 'markdown' }
autocmd! User goyo.vim echom 'Goyo is now loaded!'
```
> [!NOTE]
> #### Should I set up on-demand loading?
>
> You probably don't need to.
>
> A properly implemented Vim plugin should already load lazily without any
> help from a plugin manager (`:help autoload`). So there are few cases where
> these options actually make much sense. Making a plugin load faster is
> the responsibility of the plugin developer, not the user. If you find
> a plugin that takes too long to load, consider opening an issue on the
> plugin's issue tracker.
>
> Let me give you a perspective. The time it takes to load a plugin is usually
> less than 2 or 3ms on modern computers. So unless you use a very large
> number of plugins, you are unlikely to save more than 50ms. If you have
> spent an hour carefully setting up the options to shave off 50ms, you
> will have to start Vim 72,000 times just to break even. You should ask
> yourself if that's a good investment of your time.
>
> Make sure that you're tackling the right problem by breaking down the
> startup time of Vim using `--startuptime`.
>
> ```sh
> vim --startuptime /tmp/log
> ```
>
> On-demand loading should only be used as a last resort. It is basically
> a hacky workaround and is not always guaranteed to work.
> [!TIP]
> You can pass an empty list to `on` or `for` option to disable the loading
> of the plugin. You can manually load the plugin using `plug#load(NAMES...)`
> function.
>
> See https://github.com/junegunn/vim-plug/wiki/tips#loading-plugins-manually
## Collaborators
- [Jan Edmund Lazo](https://github.com/janlazo) - Windows support - [Jan Edmund Lazo](https://github.com/janlazo) - Windows support
- [Jeremy Pallats](https://github.com/starcraftman) - Python installer - [Jeremy Pallats](https://github.com/starcraftman) - Python installer
### License ## License
MIT MIT

View File

@ -1,136 +1,114 @@
plug.txt plug Last change: March 7 2024 plug.txt plug Last change: Jun 1 2024
PLUG - TABLE OF CONTENTS *plug* *plug-toc* PLUG - TABLE OF CONTENTS *plug* *plug-toc*
============================================================================== ==============================================================================
vim-plug vim-plug |vim-plug|
Pros. Pros. |plug-pros|
Installation Installation |plug-installation|
Vim Usage |plug-usage|
Unix Getting Help |plug-getting-help|
Windows (PowerShell) Examples |plug-examples|
Neovim Vim script example |plug-vim-script-example|
Unix Lua example for Neovim |plug-lua-example-for-neovim|
Windows (PowerShell) Commands |plug-commands|
Getting Help Plug options |plug-options|
Usage Global options |plug-global-options|
Example Keybindings |plug-keybindings|
Commands Post-update hooks |plug-post-update-hooks|
Plug options PlugInstall! and PlugUpdate! |pluginstall-and-plugupdate|
Global options On-demand loading of plugins |plug-on-demand-loading-of-plugins|
Keybindings Collaborators |plug-collaborators|
Example: A small sensible Vim configuration License |plug-license|
On-demand loading of plugins
Post-update hooks
PlugInstall! and PlugUpdate!
Articles
Collaborators
License
VIM-PLUG *vim-plug* VIM-PLUG *vim-plug*
============================================================================== ==============================================================================
A minimalist Vim plugin manager. A minimalist Vim plugin manager.
https://raw.githubusercontent.com/junegunn/i/master/vim-plug/installer.gif
PROS. *plug-pros*
==============================================================================
< Pros. >_____________________________________________________________________~ - Minimalist design
*plug-pros* - Just one file with no dependencies. Super easy to set up.
- Concise, intuitive syntax that you can learn within minutes. No
- Easy to set up: Single file. No boilerplate code required. boilerplate code required.
- Easy to use: Concise, intuitive syntax - No feature bloat
- {Super-fast}{1} parallel installation/update (with any of `+job`, `+python`, - Extremely stable with flawless backward compatibility
`+python3`, `+ruby`, or {Neovim}{2}) - Works perfectly with all versions of Vim since 2006 and all versions of
Neovim ever released
- {Super-fast}{1} parallel installation/update
- Creates shallow clones to minimize disk space usage and download time - Creates shallow clones to minimize disk space usage and download time
- On-demand loading for {faster startup time}{3} - On-demand loading for {faster startup time}{2}
- Can review and rollback updates - Can review and rollback updates
- Branch/tag/commit support - Branch/tag/commit support
- Post-update hooks - Post-update hooks
- Support for externally managed plugins - Support for externally managed plugins
{1} https://raw.githubusercontent.com/junegunn/i/master/vim-plug/40-in-4.gif {1} https://raw.githubusercontent.com/junegunn/i/master/vim-plug/40-in-4.gif
{2} http://neovim.org/ {2} https://github.com/junegunn/vim-startuptime-benchmark#result
{3} https://github.com/junegunn/vim-startuptime-benchmark#result
< Installation >______________________________________________________________~ INSTALLATION *plug-installation*
*plug-installation* ==============================================================================
{Download plug.vim}{4} and put it in the "autoload" directory. {Download plug.vim}{3} and put it in the "autoload" directory.
{4} https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim {3} https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
Vim~ USAGE *plug-usage*
*plug-vim* ==============================================================================
Add a vim-plug section to your `~/.vimrc` (or `init.vim` for Neovim)
>> Unix~ *plug#begin* *plug#end*
1. Begin the section with `callplug#begin()`
2. List the plugins with `Plug` commands
3. End the section with `callplug#end()`
For example,
> >
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ call plug#begin()
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
" List your plugins here
Plug 'tpope/vim-sensible'
call plug#end()
< <
You can automate the process by putting the command in your Vim configuration Reload the file or restart Vim, then you can,
file as suggested {here}{5}.
{5} https://github.com/junegunn/vim-plug/wiki/tips#automatic-installation *:PlugInstall* *:PlugUpdate* *:PlugDiff*
- `:PlugInstall` to install the plugins
- `:PlugUpdate` to install or update the plugins
- `:PlugDiff` to review the changes from the last update
>> Windows (PowerShell)~ [!NOTE] That's basically all you need to know to get started. The rest of the
> document is for advanced users who want to know more about the features and
iwr -useb https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |` options.
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 >______________________________________________________________~ < Getting Help >______________________________________________________________~
*plug-getting-help* *plug-getting-help*
- See {tutorial}{6} page to learn the basics of vim-plug - See {tutorial}{4} page to learn more about the basics of vim-plug
- See {tips}{7} and {FAQ}{8} pages for common problems and questions - See {tips}{5} and {FAQ}{6} 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 {4} https://github.com/junegunn/vim-plug/wiki/tutorial
{7} https://github.com/junegunn/vim-plug/wiki/tips {5} https://github.com/junegunn/vim-plug/wiki/tips
{8} https://github.com/junegunn/vim-plug/wiki/faq {6} 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 >_____________________________________________________________________~ EXAMPLES *plug-examples*
*plug-usage* ==============================================================================
Add a vim-plug section to your `~/.vimrc` (or `stdpath('config').'/init.vim'` for The following examples demonstrate the additional features of vim-plug.
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~ < Vim script example >________________________________________________________~
*plug-example* *plug-vim-script-example*
> >
call plug#begin() call plug#begin()
" The default plugin directory will be as follows: " The default plugin directory will be as follows:
@ -143,69 +121,129 @@ Example~
" Make sure you use single quotes " Make sure you use single quotes
" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align " Shorthand notation for GitHub; translates to https://github.com/junegunn/seoul256.vim.git
Plug 'junegunn/vim-easy-align' Plug 'junegunn/seoul256.vim'
" 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-easy-align.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) " Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
Plug 'fatih/vim-go', { 'tag': '*' } Plug 'fatih/vim-go', { 'tag': '*' }
" Plugin options " Using a non-default branch
Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' } Plug 'neoclide/coc.nvim', { 'branch': 'release' }
" Plugin outside ~/.vim/plugged with post-update hook " Use 'dir' option to install plugin in a non-default directory
Plug 'junegunn/fzf', { 'dir': '~/.fzf' }
" Post-update hook: run a shell command after installing or updating the plugin
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
" Post-update hook can be a lambda expression
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
" If the vim plugin is in a subdirectory, use 'rtp' option to specify its path
Plug 'nsf/gocode', { 'rtp': 'vim' }
" On-demand loading: loaded when the specified command is executed
Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
" On-demand loading: loaded when a file with a specific file type is opened
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
" Unmanaged plugin (manually installed and updated) " Unmanaged plugin (manually installed and updated)
Plug '~/my-prototype-plugin' Plug '~/my-prototype-plugin'
" Initialize plugin system " Call plug#end to update &runtimepath and initialize the plugin system.
" - Automatically executes `filetype plugin indent on` and `syntax enable`. " - It 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: " You can revert the settings after the call like so:
" filetype indent off " Disable file-type-specific indentation " filetype indent off " Disable file-type-specific indentation
" syntax off " Disable syntax highlighting " syntax off " Disable syntax highlighting
" Color schemes should be loaded after plug#end().
" We prepend it with 'silent!' to ignore errors when it's not yet installed.
silent! colorscheme seoul256
< <
*:PlugInstall*
Reload .vimrc and `:PlugInstall` to install plugins. < Lua example for Neovim >____________________________________________________~
*plug-lua-example-for-neovim*
In Neovim, you can write your configuration in a Lua script file named
`init.lua`. The following code is the Lua script equivalent to the Vim script
example above.
>
local vim = vim
local Plug = vim.fn['plug#']
< Commands >__________________________________________________________________~ vim.call('plug#begin')
*plug-commands*
------------------------------------+------------------------------------------------------------------- -- Shorthand notation for GitHub; translates to https://github.com/junegunn/seoul256.vim.git
Plug('junegunn/seoul256.vim')
-- Any valid git URL is allowed
Plug('https://github.com/junegunn/vim-easy-align.git')
-- Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
Plug('fatih/vim-go', { ['tag'] = '*' })
-- Using a non-default branch
Plug('neoclide/coc.nvim', { ['branch'] = 'release' })
-- Use 'dir' option to install plugin in a non-default directory
Plug('junegunn/fzf', { ['dir'] = '~/.fzf' })
-- Post-update hook: run a shell command after installing or updating the plugin
Plug('junegunn/fzf', { ['dir'] = '~/.fzf', ['do'] = './install --all' })
-- Post-update hook can be a lambda expression
Plug('junegunn/fzf', { ['do'] = function()
vim.fn['fzf#install']()
end })
-- If the vim plugin is in a subdirectory, use 'rtp' option to specify its path
Plug('nsf/gocode', { ['rtp'] = 'vim' })
-- On-demand loading: loaded when the specified command is executed
Plug('preservim/nerdtree', { ['on'] = 'NERDTreeToggle' })
-- On-demand loading: loaded when a file with a specific file type is opened
Plug('tpope/vim-fireplace', { ['for'] = 'clojure' })
-- Unmanaged plugin (manually installed and updated)
Plug('~/my-prototype-plugin')
vim.call('plug#end')
-- Color schemes should be loaded after plug#end().
-- We prepend it with 'silent!' to ignore errors when it's not yet installed.
vim.cmd('silent! colorscheme seoul256')
<
COMMANDS *plug-commands*
==============================================================================
-------------------------------------+------------------------------------------------------------------
Command | Description ~ 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 unlisted plugins (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
`PlugSnapshot[!][outputpath]` | Generate script for restoring the current snapshot of the plugins `PlugSnapshot[!] [output path]` | Generate script for restoring the current snapshot of the plugins
------------------------------------+------------------------------------------------------------------- -------------------------------------+------------------------------------------------------------------
< Plug options >______________________________________________________________~ PLUG OPTIONS *plug-options*
*plug-options* ==============================================================================
*:Plug*
------------------------+----------------------------------------------- *<Plug>-mappings*
------------------------+------------------------------------------------------------
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
@ -213,12 +251,12 @@ Reload .vimrc and `:PlugInstall` to install plugins.
`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 or <Plug>-mappings
`for` | On-demand loading: File types `for` | On-demand loading: File types
`frozen` | Do not update unless explicitly specified `frozen` | Do not remove and do not update unless explicitly specified
------------------------+----------------------------------------------- ------------------------+------------------------------------------------------------
< Global options >____________________________________________________________~ GLOBAL OPTIONS *plug-global-options*
*plug-global-options* ==============================================================================
*g:plug_threads* *g:plug_timeout* *g:plug_retries* *g:plug_shallow* *g:plug_window* *g:plug_threads* *g:plug_timeout* *g:plug_retries* *g:plug_shallow* *g:plug_window*
*g:plug_pwindow* *g:plug_url_format* *g:plug_pwindow* *g:plug_url_format*
@ -236,10 +274,8 @@ Reload .vimrc and `:PlugInstall` to install plugins.
--------------------+-----------------------------------+----------------------------------------------------------------------------------- --------------------+-----------------------------------+-----------------------------------------------------------------------------------
< Keybindings >_______________________________________________________________~ KEYBINDINGS *plug-keybindings*
*plug-keybindings* ==============================================================================
*:PlugStatus* *:PlugDiff*
- `D` - `PlugDiff` - `D` - `PlugDiff`
- `S` - `PlugStatus` - `S` - `PlugStatus`
@ -252,43 +288,8 @@ Reload .vimrc and `:PlugInstall` to install plugins.
- `X` - Revert the update - `X` - Revert the update
< Example: A small sensible Vim configuration >_______________________________~ POST-UPDATE HOOKS *plug-post-update-hooks*
*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. 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 the `do` option to describe the task to be performed.
@ -323,16 +324,14 @@ 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 when the repository has changed, but you can force it to run unconditionally
with the bang-versions of the commands: `PlugInstall!` and `PlugUpdate!`. with the bang-versions of the commands: `PlugInstall!` and `PlugUpdate!`.
Make sure to escape BARs and double-quotes when you write the `do` option [!TIP] Make sure to escape BARs and double-quotes when you write the `do`
inline as they are mistakenly recognized as command separator or the start of option inline as they are mistakenly recognized as command separator or the
the trailing comment. start of the trailing comment.
> >
Plug 'junegunn/fzf', { 'do': 'yes \| ./install' } Plug 'junegunn/fzf', { 'do': 'yes \| ./install' }
< <
But you can avoid the escaping if you extract the inline specification using a But you can avoid the escaping if you extract the inline specification using a
variable (or any Vimscript expression) as follows: variable (or any Vim script expression) as follows:
*g:fzf_install*
> >
let g:fzf_install = 'yes | ./install' let g:fzf_install = 'yes | ./install'
Plug 'junegunn/fzf', { 'do': g:fzf_install } Plug 'junegunn/fzf', { 'do': g:fzf_install }
@ -343,8 +342,8 @@ variable (or any Vimscript expression) as follows:
The installer takes the following steps when installing/updating a plugin: The installer takes the following steps when installing/updating a plugin:
1. `gitclone` or `gitfetch` from its origin 1. `git clone` or `git fetch` from its origin
2. Check out branch, tag, or commit and optionally `gitmerge` remote branch 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) 3. If the plugin was updated (or installed for the first time)
1. Update submodules 1. Update submodules
2. Execute post-update hooks 2. Execute post-update hooks
@ -353,34 +352,77 @@ The commands with the `!` suffix ensure that all steps are run
unconditionally. unconditionally.
< Articles >__________________________________________________________________~ ON-DEMAND LOADING OF PLUGINS *plug-on-demand-loading-of-plugins*
*plug-articles* ==============================================================================
>
" NERD tree will be loaded on the first invocation of NERDTreeToggle command
Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
- {Writing my own Vim plugin manager}{11} " Multiple commands
- {Vim plugins and startup time}{12} Plug 'junegunn/vim-github-dashboard', { 'on': ['GHDashboard', 'GHActivity'] }
- ~~{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 " Loaded when clojure file is opened
{12} http://junegunn.kr/2014/07/vim-plugins-and-startup-time Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
{13} http://junegunn.kr/2013/09/thoughts-on-vim-plugin-dependency
" Multiple file types
Plug 'kovisoft/paredit', { 'for': ['clojure', 'scheme'] }
" On-demand loading on both conditions
Plug 'junegunn/vader.vim', { 'on': 'Vader', 'for': 'vader' }
" Code to execute when the plugin is lazily loaded on demand
Plug 'junegunn/goyo.vim', { 'for': 'markdown' }
autocmd! User goyo.vim echom 'Goyo is now loaded!'
<
[!NOTE] #### Should I set up on-demand loading?
You probably don't need to.
A properly implemented Vim plugin should already load lazily without any help
from a plugin manager (`:helpautoload`). So there are few cases where these
options actually make much sense. Making a plugin load faster is the
responsibility of the plugin developer, not the user. If you find a plugin
that takes too long to load, consider opening an issue on the plugin's issue
tracker.
Let me give you a perspective. The time it takes to load a plugin is usually
less than 2 or 3ms on modern computers. So unless you use a very large number
of plugins, you are unlikely to save more than 50ms. If you have spent an hour
carefully setting up the options to shave off 50ms, you will have to start Vim
72,000 times just to break even. You should ask yourself if that's a good
investment of your time.
Make sure that you're tackling the right problem by breaking down the startup
time of Vim using `--startuptime`.
>
vim --startuptime /tmp/log
<
On-demand loading should only be used as a last resort. It is basically a
hacky workaround and is not always guaranteed to work.
*plug#load*
[!TIP] You can pass an empty list to `on` or `for` option to disable the
loading of the plugin. You can manually load the plugin using
`plug#load(NAMES...)` function.
See https://github.com/junegunn/vim-plug/wiki/tips#loading-plugins-manually
< Collaborators >_____________________________________________________________~ COLLABORATORS *plug-collaborators*
*plug-collaborators* ==============================================================================
- {Jan Edmund Lazo}{14} - Windows support - {Jan Edmund Lazo}{7} - Windows support
- {Jeremy Pallats}{15} - Python installer - {Jeremy Pallats}{8} - Python installer
{14} https://github.com/janlazo {7} https://github.com/janlazo
{15} https://github.com/starcraftman {8} https://github.com/starcraftman
< License >___________________________________________________________________~ LICENSE *plug-license*
*plug-license* ==============================================================================
MIT MIT
============================================================================== ==============================================================================
vim:tw=78:sw=2:ts=2:ft=help:norl:nowrap: vim:tw=78:sw=2:ts=2:ft=help:norl:nowrap:

122
plug.vim
View File

@ -1,67 +1,36 @@
" vim-plug: Vim plugin manager " vim-plug: Vim plugin manager
" ============================ " ============================
" "
" Download plug.vim and put it in ~/.vim/autoload " 1. Download plug.vim and put it in 'autoload' directory
" "
" # Vim
" curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ " 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
" "
" Edit your .vimrc " # Neovim
" 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'
" "
" call plug#begin('~/.vim/plugged') " 2. Add a vim-plug section to your ~/.vimrc (or ~/.config/nvim/init.vim for Neovim)
" "
" " Make sure you use single quotes " call plug#begin()
" "
" " Shorthand notation; fetches https://github.com/junegunn/vim-easy-align " " List your plugins here
" Plug 'junegunn/vim-easy-align' " Plug 'tpope/vim-sensible'
" "
" " 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
" call plug#end() " call plug#end()
" "
" Then reload .vimrc and :PlugInstall to install plugins. " 3. Reload the file or restart Vim, then you can,
" "
" Plug options: " :PlugInstall to install plugins
" :PlugUpdate to update plugins
" :PlugDiff to review the changes from the last update
" :PlugClean to remove plugins no longer in the list
" "
"| Option | Description | " For more information, see https://github.com/junegunn/vim-plug
"| ----------------------- | ------------------------------------------------ |
"| `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 |
"
" More information: https://github.com/junegunn/vim-plug
" "
" "
" Copyright (c) 2017 Junegunn Choi " Copyright (c) 2024 Junegunn Choi
" "
" MIT License " MIT License
" "
@ -238,7 +207,6 @@ endfunction
function! plug#begin(...) function! plug#begin(...)
if a:0 > 0 if a:0 > 0
let s:plug_home_org = a:1
let home = s:path(s:plug_fnamemodify(s:plug_expand(a:1), ':p')) let home = s:path(s:plug_fnamemodify(s:plug_expand(a:1), ':p'))
elseif exists('g:plug_home') elseif exists('g:plug_home')
let home = s:path(g:plug_home) let home = s:path(g:plug_home)
@ -815,10 +783,11 @@ endfunction
function! s:syntax() function! s:syntax()
syntax clear syntax clear
syntax region plug1 start=/\%1l/ end=/\%2l/ contains=plugNumber syntax region plug1 start=/\%1l/ end=/\%2l/ contains=plugNumber
syntax region plug2 start=/\%2l/ end=/\%3l/ contains=plugBracket,plugX syntax region plug2 start=/\%2l/ end=/\%3l/ contains=plugBracket,plugX,plugAbort
syn match plugNumber /[0-9]\+[0-9.]*/ contained syn match plugNumber /[0-9]\+[0-9.]*/ contained
syn match plugBracket /[[\]]/ contained syn match plugBracket /[[\]]/ contained
syn match plugX /x/ contained syn match plugX /x/ contained
syn match plugAbort /\~/ contained
syn match plugDash /^-\{1}\ / syn match plugDash /^-\{1}\ /
syn match plugPlus /^+/ syn match plugPlus /^+/
syn match plugStar /^*/ syn match plugStar /^*/
@ -843,6 +812,7 @@ function! s:syntax()
hi def link plug2 Repeat hi def link plug2 Repeat
hi def link plugH2 Type hi def link plugH2 Type
hi def link plugX Exception hi def link plugX Exception
hi def link plugAbort Ignore
hi def link plugBracket Structure hi def link plugBracket Structure
hi def link plugNumber Number hi def link plugNumber Number
@ -940,7 +910,7 @@ function! s:prepare(...)
endif endif
endfor endfor
call s:job_abort() call s:job_abort(0)
if s:switch_in() if s:switch_in()
if b:plug_preview == 1 if b:plug_preview == 1
pc pc
@ -976,6 +946,8 @@ function! s:close_pane()
if b:plug_preview == 1 if b:plug_preview == 1
pc pc
let b:plug_preview = -1 let b:plug_preview = -1
elseif exists('s:jobs') && !empty(s:jobs)
call s:job_abort(1)
else else
bd bd
endif endif
@ -1358,7 +1330,12 @@ function! s:update_finish()
endif endif
endfunction endfunction
function! s:job_abort() function! s:mark_aborted(name, message)
let attrs = { 'running': 0, 'error': 1, 'abort': 1, 'lines': [a:message] }
let s:jobs[a:name] = extend(get(s:jobs, a:name, {}), attrs)
endfunction
function! s:job_abort(cancel)
if (!s:nvim && !s:vim8) || !exists('s:jobs') if (!s:nvim && !s:vim8) || !exists('s:jobs')
return return
endif endif
@ -1372,8 +1349,18 @@ function! s:job_abort()
if j.new if j.new
call s:rm_rf(g:plugs[name].dir) call s:rm_rf(g:plugs[name].dir)
endif endif
if a:cancel
call s:mark_aborted(name, 'Aborted')
endif
endfor endfor
if a:cancel
for todo in values(s:update.todo)
let todo.abort = 1
endfor
else
let s:jobs = {} let s:jobs = {}
endif
endfunction endfunction
function! s:last_non_empty_line(lines) function! s:last_non_empty_line(lines)
@ -1387,6 +1374,16 @@ function! s:last_non_empty_line(lines)
return '' return ''
endfunction endfunction
function! s:bullet_for(job, ...)
if a:job.running
return a:job.new ? '+' : '*'
endif
if get(a:job, 'abort', 0)
return '~'
endif
return a:job.error ? 'x' : get(a:000, 0, '-')
endfunction
function! s:job_out_cb(self, data) abort function! s:job_out_cb(self, data) abort
let self = a:self let self = a:self
let data = remove(self.lines, -1) . a:data let data = remove(self.lines, -1) . a:data
@ -1395,10 +1392,9 @@ function! s:job_out_cb(self, data) abort
" To reduce the number of buffer updates " To reduce the number of buffer updates
let self.tick = get(self, 'tick', -1) + 1 let self.tick = get(self, 'tick', -1) + 1
if !self.running || self.tick % len(s:jobs) == 0 if !self.running || self.tick % len(s:jobs) == 0
let bullet = self.running ? (self.new ? '+' : '*') : (self.error ? 'x' : '-')
let result = self.error ? join(self.lines, "\n") : s:last_non_empty_line(self.lines) let result = self.error ? join(self.lines, "\n") : s:last_non_empty_line(self.lines)
if len(result) if len(result)
call s:log(bullet, self.name, result) call s:log(s:bullet_for(self), self.name, result)
endif endif
endif endif
endfunction endfunction
@ -1412,7 +1408,7 @@ endfunction
function! s:job_cb(fn, job, ch, data) function! s:job_cb(fn, job, ch, data)
if !s:plug_window_exists() " plug window closed if !s:plug_window_exists() " plug window closed
return s:job_abort() return s:job_abort(0)
endif endif
call call(a:fn, [a:job, a:data]) call call(a:fn, [a:job, a:data])
endfunction endfunction
@ -1484,17 +1480,16 @@ function! s:reap(name)
endif endif
let more = len(get(job, 'queue', [])) let more = len(get(job, 'queue', []))
let bullet = job.error ? 'x' : more ? (job.new ? '+' : '*') : '-'
let result = job.error ? join(job.lines, "\n") : s:last_non_empty_line(job.lines) let result = job.error ? join(job.lines, "\n") : s:last_non_empty_line(job.lines)
if len(result) if len(result)
call s:log(bullet, a:name, result) call s:log(s:bullet_for(job), a:name, result)
endif endif
if !job.error && more if !job.error && more
let job.spec.queue = job.queue let job.spec.queue = job.queue
let s:update.todo[a:name] = job.spec let s:update.todo[a:name] = job.spec
else else
let s:update.bar .= job.error ? 'x' : '=' let s:update.bar .= s:bullet_for(job, '=')
call s:bar() call s:bar()
endif endif
endfunction endfunction
@ -1573,6 +1568,12 @@ while 1 " Without TCO, Vim stack is bound to explode
let name = keys(s:update.todo)[0] let name = keys(s:update.todo)[0]
let spec = remove(s:update.todo, name) let spec = remove(s:update.todo, name)
if get(spec, 'abort', 0)
call s:mark_aborted(name, 'Skipped')
call s:reap(name)
continue
endif
let queue = get(spec, 'queue', []) let queue = get(spec, 'queue', [])
let new = empty(globpath(spec.dir, '.git', 1)) let new = empty(globpath(spec.dir, '.git', 1))
@ -2313,7 +2314,10 @@ endfunction
function! s:with_cd(cmd, dir, ...) function! s:with_cd(cmd, dir, ...)
let script = a:0 > 0 ? a:1 : 1 let script = a:0 > 0 ? a:1 : 1
return printf('cd%s %s && %s', s:is_win ? ' /d' : '', plug#shellescape(a:dir, {'script': script}), a:cmd) let pwsh = s:is_powershell(&shell)
let cd = s:is_win && !pwsh ? 'cd /d' : 'cd'
let sep = pwsh ? ';' : '&&'
return printf('%s %s %s %s', cd, plug#shellescape(a:dir, {'script': script, 'shell': &shell}), sep, a:cmd)
endfunction endfunction
function! s:system(cmd, ...) function! s:system(cmd, ...)
@ -2436,7 +2440,7 @@ function! s:clean(force)
let errs = {} let errs = {}
let [cnt, total] = [0, len(g:plugs)] let [cnt, total] = [0, len(g:plugs)]
for [name, spec] in items(g:plugs) for [name, spec] in items(g:plugs)
if !s:is_managed(name) if !s:is_managed(name) || get(spec, 'frozen', 0)
call add(dirs, spec.dir) call add(dirs, spec.dir)
else else
let [err, clean] = s:git_validate(spec, 1) let [err, clean] = s:git_validate(spec, 1)

View File

@ -804,6 +804,14 @@ Execute (Check &rtp after SomeCommand):
AssertEqual g:first_rtp, split(&rtp, ',')[0] AssertEqual g:first_rtp, split(&rtp, ',')[0]
AssertEqual g:last_rtp, split(&rtp, ',')[-1] AssertEqual g:last_rtp, split(&rtp, ',')[-1]
Execute (PlugClean should not care about frozen plugins):
call plug#begin()
Plug 'xxx/vim-easy-align', { 'frozen': 1 }
call plug#end()
PlugClean
AssertExpect 'Already clean', 1
q
Execute (Common parent): Execute (Common parent):
call plug#begin() call plug#begin()
Plug 'junegunn/vim-pseudocl' Plug 'junegunn/vim-pseudocl'