Skip to content

Commit 9b4ecd1

Browse files
authored
Update documentation (#1280)
1 parent c099214 commit 9b4ecd1

File tree

2 files changed

+274
-174
lines changed

2 files changed

+274
-174
lines changed

README.md

+111-93
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ A minimalist Vim plugin manager.
3232

3333
### Pros.
3434

35-
- Easy to set up: Single file. No boilerplate code required.
36-
- Easy to use: Concise, intuitive syntax
37-
- Minimalist: No feature bloat
35+
- Minimalist design
36+
- Just one file with no dependencies. Super easy to set up.
37+
- Concise, intuitive syntax that you can learn within minutes. No boilerplate code required.
38+
- No feature bloat
3839
- Extremely stable with flawless backward compatibility
39-
- Works perfectly with Vim 7.0+ since 2006 and with all versions of Neovim since 2014
40+
- Works perfectly with all versions of Vim since 2006 and all versions of Neovim ever released
4041
- [Super-fast][40/4] parallel installation/update
4142
- Creates shallow clones to minimize disk space usage and download time
4243
- On-demand loading for [faster startup time][startup-time]
@@ -53,6 +54,9 @@ A minimalist Vim plugin manager.
5354
[Download plug.vim](https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim)
5455
and put it in the "autoload" directory.
5556

57+
<details>
58+
<summary>Click to see the instructions</summary>
59+
5660
#### Vim
5761

5862
###### Unix
@@ -97,30 +101,52 @@ iwr -useb https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |`
97101
ni "$(@($env:XDG_DATA_HOME, $env:LOCALAPPDATA)[$null -eq $env:XDG_DATA_HOME])/nvim-data/site/autoload/plug.vim" -Force
98102
```
99103

100-
### Getting Help
104+
</details>
105+
106+
### Usage
107+
108+
Add a vim-plug section to your `~/.vimrc` (or `init.vim` for Neovim)
109+
110+
1. Begin the section with `call plug#begin()`
111+
1. List the plugins with `Plug` commands
112+
1. End the section with `call plug#end()`
113+
114+
For example,
115+
116+
```vim
117+
call plug#begin()
118+
119+
" List your plugins here
120+
Plug 'tpope/vim-sensible'
121+
122+
call plug#end()
123+
```
124+
125+
Reload the file or restart Vim, then you can,
126+
127+
* `:PlugInstall` to install the plugins
128+
* `:PlugUpdate` to install or update the plugins
129+
* `:PlugDiff` to review the changes from the last update
130+
131+
> [!NOTE]
132+
> That's basically all you need to know to get started. The rest of the
133+
> document is for advanced users who want to know more about the features and
134+
> options.
135+
136+
#### Getting Help
101137

102-
- See [tutorial] page to learn the basics of vim-plug
138+
- See [tutorial] page to learn more about the basics of vim-plug
103139
- See [tips] and [FAQ] pages for common problems and questions
104-
- See [requirements] page for debugging information & tested configurations
105-
- Create an [issue](https://github.com/junegunn/vim-plug/issues/new)
106140

107141
[tutorial]: https://github.com/junegunn/vim-plug/wiki/tutorial
108142
[tips]: https://github.com/junegunn/vim-plug/wiki/tips
109143
[FAQ]: https://github.com/junegunn/vim-plug/wiki/faq
110-
[requirements]: https://github.com/junegunn/vim-plug/wiki/requirements
111144

112-
### Usage
145+
### More examples
113146

114-
Add a vim-plug section to your `~/.vimrc` (or `stdpath('config') . '/init.vim'` for Neovim)
147+
The following examples demonstrate the additional features of vim-plug.
115148

116-
1. Begin the section with `call plug#begin([PLUGIN_DIR])`
117-
1. List the plugins with `Plug` commands
118-
1. `call plug#end()` to update `&runtimepath` and initialize plugin system
119-
- Automatically executes `filetype plugin indent on` and `syntax enable`.
120-
You can revert the settings after the call. e.g. `filetype indent off`, `syntax off`, etc.
121-
1. Reload the file or restart Vim and run `:PlugInstall` to install plugins.
122-
123-
#### Example
149+
#### Vim script example
124150

125151
```vim
126152
call plug#begin()
@@ -167,18 +193,18 @@ Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
167193
" Unmanaged plugin (manually installed and updated)
168194
Plug '~/my-prototype-plugin'
169195
170-
" Initialize plugin system
171-
" - Automatically executes `filetype plugin indent on` and `syntax enable`.
196+
" Call plug#end to update &runtimepath and initialize the plugin system.
197+
" - It automatically executes `filetype plugin indent on` and `syntax enable`
172198
call plug#end()
173199
" You can revert the settings after the call like so:
174200
" filetype indent off " Disable file-type-specific indentation
175201
" syntax off " Disable syntax highlighting
176202
```
177203

178-
#### Example (Lua configuration for Neovim)
204+
#### Lua configuration example for Neovim
179205

180206
In Neovim, you can write your configuration in a Lua script file named
181-
`init.lua`. The following code is the Lua script equivalent to the VimScript
207+
`init.lua`. The following code is the Lua script equivalent to the Vim script
182208
example above.
183209

184210
```lua
@@ -279,74 +305,6 @@ More examples can be found in:
279305
- `:PlugDiff`
280306
- `X` - Revert the update
281307

282-
### Example: A small [sensible](https://github.com/tpope/vim-sensible) Vim configuration
283-
284-
```vim
285-
call plug#begin()
286-
Plug 'tpope/vim-sensible'
287-
call plug#end()
288-
```
289-
290-
### On-demand loading of plugins
291-
292-
```vim
293-
" NERD tree will be loaded on the first invocation of NERDTreeToggle command
294-
Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
295-
296-
" Multiple commands
297-
Plug 'junegunn/vim-github-dashboard', { 'on': ['GHDashboard', 'GHActivity'] }
298-
299-
" Loaded when clojure file is opened
300-
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
301-
302-
" Multiple file types
303-
Plug 'kovisoft/paredit', { 'for': ['clojure', 'scheme'] }
304-
305-
" On-demand loading on both conditions
306-
Plug 'junegunn/vader.vim', { 'on': 'Vader', 'for': 'vader' }
307-
308-
" Code to execute when the plugin is lazily loaded on demand
309-
Plug 'junegunn/goyo.vim', { 'for': 'markdown' }
310-
autocmd! User goyo.vim echom 'Goyo is now loaded!'
311-
```
312-
313-
> [!NOTE]
314-
> #### Should I set up on-demand loading?
315-
>
316-
> You probably don't need to.
317-
>
318-
> A properly implemented Vim plugin should already load lazily without any
319-
> help from a plugin manager (`:help autoload`). So there are few cases where
320-
> these options actually make much sense. Making a plugin load faster is
321-
> the responsibility of the plugin developer, not the user. If you find
322-
> a plugin that takes too long to load, consider opening an issue on the
323-
> plugin's issue tracker.
324-
>
325-
> Let me give you a perspective. The time it takes to load a plugin is usually
326-
> less than 2 or 3ms on modern computers. So unless you use a very large
327-
> number of plugins, you are unlikely to save more than 50ms. If you have
328-
> spent an hour carefully setting up the options to shave off 50ms, you
329-
> will have to start Vim 72,000 times just to break even. You should ask
330-
> yourself if that's a good investment of your time.
331-
>
332-
> Make sure that you're tackling the right problem by breaking down the
333-
> startup time of Vim using `--startuptime`.
334-
>
335-
> ```sh
336-
> vim --startuptime /tmp/log
337-
> ```
338-
>
339-
> On-demand loading should only be used as a last resort. It is basically
340-
> a hacky workaround and is not always guaranteed to work.
341-
342-
> [!TIP]
343-
> You can pass an empty list to `on` or `for` option to disable the loading
344-
> of the plugin. You can manually load the plugin using `plug#load(NAMES...)`
345-
> function.
346-
>
347-
> See https://github.com/junegunn/vim-plug/wiki/tips#loading-plugins-manually
348-
349-
350308
### Post-update hooks
351309

352310
There are some plugins that require extra steps after installation or update.
@@ -400,14 +358,14 @@ with the bang-versions of the commands: `PlugInstall!` and `PlugUpdate!`.
400358
> ```
401359
>
402360
> But you can avoid the escaping if you extract the inline specification using a
403-
> variable (or any Vimscript expression) as follows:
361+
> variable (or any Vim script expression) as follows:
404362
>
405363
> ```vim
406364
> let g:fzf_install = 'yes | ./install'
407365
> Plug 'junegunn/fzf', { 'do': g:fzf_install }
408366
> ```
409367
410-
### `PlugInstall!` and `PlugUpdate!`
368+
#### `PlugInstall!` and `PlugUpdate!`
411369
412370
The installer takes the following steps when installing/updating a plugin:
413371
@@ -419,6 +377,66 @@ The installer takes the following steps when installing/updating a plugin:
419377
420378
The commands with the `!` suffix ensure that all steps are run unconditionally.
421379
380+
### On-demand loading of plugins
381+
382+
```vim
383+
" NERD tree will be loaded on the first invocation of NERDTreeToggle command
384+
Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
385+
386+
" Multiple commands
387+
Plug 'junegunn/vim-github-dashboard', { 'on': ['GHDashboard', 'GHActivity'] }
388+
389+
" Loaded when clojure file is opened
390+
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
391+
392+
" Multiple file types
393+
Plug 'kovisoft/paredit', { 'for': ['clojure', 'scheme'] }
394+
395+
" On-demand loading on both conditions
396+
Plug 'junegunn/vader.vim', { 'on': 'Vader', 'for': 'vader' }
397+
398+
" Code to execute when the plugin is lazily loaded on demand
399+
Plug 'junegunn/goyo.vim', { 'for': 'markdown' }
400+
autocmd! User goyo.vim echom 'Goyo is now loaded!'
401+
```
402+
403+
> [!NOTE]
404+
> #### Should I set up on-demand loading?
405+
>
406+
> You probably don't need to.
407+
>
408+
> A properly implemented Vim plugin should already load lazily without any
409+
> help from a plugin manager (`:help autoload`). So there are few cases where
410+
> these options actually make much sense. Making a plugin load faster is
411+
> the responsibility of the plugin developer, not the user. If you find
412+
> a plugin that takes too long to load, consider opening an issue on the
413+
> plugin's issue tracker.
414+
>
415+
> Let me give you a perspective. The time it takes to load a plugin is usually
416+
> less than 2 or 3ms on modern computers. So unless you use a very large
417+
> number of plugins, you are unlikely to save more than 50ms. If you have
418+
> spent an hour carefully setting up the options to shave off 50ms, you
419+
> will have to start Vim 72,000 times just to break even. You should ask
420+
> yourself if that's a good investment of your time.
421+
>
422+
> Make sure that you're tackling the right problem by breaking down the
423+
> startup time of Vim using `--startuptime`.
424+
>
425+
> ```sh
426+
> vim --startuptime /tmp/log
427+
> ```
428+
>
429+
> On-demand loading should only be used as a last resort. It is basically
430+
> a hacky workaround and is not always guaranteed to work.
431+
432+
> [!TIP]
433+
> You can pass an empty list to `on` or `for` option to disable the loading
434+
> of the plugin. You can manually load the plugin using `plug#load(NAMES...)`
435+
> function.
436+
>
437+
> See https://github.com/junegunn/vim-plug/wiki/tips#loading-plugins-manually
438+
439+
422440
### Collaborators
423441
424442
- [Jan Edmund Lazo](https://github.com/janlazo) - Windows support

0 commit comments

Comments
 (0)