plug.txt 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. plug.txt plug Last change: January 3 2022
  2. PLUG - TABLE OF CONTENTS *plug* *plug-toc*
  3. ==============================================================================
  4. vim-plug
  5. Pros.
  6. Installation
  7. Vim
  8. Unix
  9. Windows (PowerShell)
  10. Neovim
  11. Unix
  12. Windows (PowerShell)
  13. Getting Help
  14. Usage
  15. Example
  16. Commands
  17. Plug options
  18. Global options
  19. Keybindings
  20. Example: A small sensible Vim configuration
  21. On-demand loading of plugins
  22. Post-update hooks
  23. PlugInstall! and PlugUpdate!
  24. Articles
  25. Collaborators
  26. License
  27. VIM-PLUG *vim-plug*
  28. ==============================================================================
  29. A minimalist Vim plugin manager.
  30. https://raw.githubusercontent.com/junegunn/i/master/vim-plug/installer.gif
  31. < Pros. >_____________________________________________________________________~
  32. *plug-pros*
  33. - Easy to set up: Single file. No boilerplate code required.
  34. - Easy to use: Concise, intuitive syntax
  35. - {Super-fast}{1} parallel installation/update (with any of `+job`, `+python`,
  36. `+python3`, `+ruby`, or {Neovim}{2})
  37. - Creates shallow clones to minimize disk space usage and download time
  38. - On-demand loading for {faster startup time}{3}
  39. - Can review and rollback updates
  40. - Branch/tag/commit support
  41. - Post-update hooks
  42. - Support for externally managed plugins
  43. {1} https://raw.githubusercontent.com/junegunn/i/master/vim-plug/40-in-4.gif
  44. {2} http://neovim.org/
  45. {3} https://github.com/junegunn/vim-startuptime-benchmark#result
  46. < Installation >______________________________________________________________~
  47. *plug-installation*
  48. {Download plug.vim}{4} and put it in the "autoload" directory.
  49. {4} https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  50. Vim~
  51. *plug-vim*
  52. >> Unix~
  53. >
  54. curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
  55. https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  56. <
  57. You can automate the process by putting the command in your Vim configuration
  58. file as suggested {here}{5}.
  59. {5} https://github.com/junegunn/vim-plug/wiki/tips#automatic-installation
  60. >> Windows (PowerShell)~
  61. >
  62. iwr -useb https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |`
  63. ni $HOME/vimfiles/autoload/plug.vim -Force
  64. <
  65. Neovim~
  66. *plug-neovim*
  67. >> Unix~
  68. >
  69. sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
  70. https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
  71. <
  72. >> Windows (PowerShell)~
  73. >
  74. iwr -useb https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |`
  75. ni "$(@($env:XDG_DATA_HOME, $env:LOCALAPPDATA)[$null -eq $env:XDG_DATA_HOME])/nvim-data/site/autoload/plug.vim" -Force
  76. <
  77. < Getting Help >______________________________________________________________~
  78. *plug-getting-help*
  79. - See {tutorial}{6} page to learn the basics of vim-plug
  80. - See {tips}{7} and {FAQ}{8} pages for common problems and questions
  81. - See {requirements}{9} page for debugging information & tested configurations
  82. - Create an {issue}{10}
  83. {6} https://github.com/junegunn/vim-plug/wiki/tutorial
  84. {7} https://github.com/junegunn/vim-plug/wiki/tips
  85. {8} https://github.com/junegunn/vim-plug/wiki/faq
  86. {9} https://github.com/junegunn/vim-plug/wiki/requirements
  87. {10} https://github.com/junegunn/vim-plug/issues/new
  88. < Usage >_____________________________________________________________________~
  89. *plug-usage*
  90. Add a vim-plug section to your `~/.vimrc` (or `stdpath('config') . '/init.vim'` for
  91. Neovim)
  92. *plug#begin* *plug#end*
  93. 1. Begin the section with `call plug#begin([PLUGIN_DIR])`
  94. 2. List the plugins with `Plug` commands
  95. 3. `call plug#end()` to update 'runtimepath' and initialize plugin system
  96. - Automatically executes `filetype plugin indent on` and `syntax enable`.
  97. You can revert the settings after the call. e.g. `filetype indent off`,
  98. `syntax off`, etc.
  99. Example~
  100. *plug-example*
  101. >
  102. call plug#begin()
  103. " The default plugin directory will be as follows:
  104. " - Vim (Linux/macOS): '~/.vim/plugged'
  105. " - Vim (Windows): '~/vimfiles/plugged'
  106. " - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged'
  107. " You can specify a custom plugin directory by passing it as the argument
  108. " - e.g. `call plug#begin('~/.vim/plugged')`
  109. " - Avoid using standard Vim directory names like 'plugin'
  110. " Make sure you use single quotes
  111. " Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
  112. Plug 'junegunn/vim-easy-align'
  113. " Any valid git URL is allowed
  114. Plug 'https://github.com/junegunn/vim-github-dashboard.git'
  115. " Multiple Plug commands can be written in a single line using | separators
  116. Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
  117. " On-demand loading
  118. Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
  119. Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
  120. " Using a non-default branch
  121. Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }
  122. " Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
  123. Plug 'fatih/vim-go', { 'tag': '*' }
  124. " Plugin options
  125. Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }
  126. " Plugin outside ~/.vim/plugged with post-update hook
  127. Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
  128. " Unmanaged plugin (manually installed and updated)
  129. Plug '~/my-prototype-plugin'
  130. " Initialize plugin system
  131. call plug#end()
  132. <
  133. *:PlugInstall*
  134. Reload .vimrc and `:PlugInstall` to install plugins.
  135. < Commands >__________________________________________________________________~
  136. *plug-commands*
  137. ------------------------------------+-------------------------------------------------------------------
  138. Command | Description ~
  139. ------------------------------------+-------------------------------------------------------------------
  140. `PlugInstall [name ...] [#threads]` | Install plugins
  141. `PlugUpdate [name ...] [#threads]` | Install or update plugins
  142. `PlugClean[!]` | Remove unlisted plugins (bang version will clean without prompt)
  143. `PlugUpgrade` | Upgrade vim-plug itself
  144. `PlugStatus` | Check the status of plugins
  145. `PlugDiff` | Examine changes from the previous update and the pending changes
  146. `PlugSnapshot[!] [output path]` | Generate script for restoring the current snapshot of the plugins
  147. ------------------------------------+-------------------------------------------------------------------
  148. < Plug options >______________________________________________________________~
  149. *plug-options*
  150. *:Plug*
  151. ------------------------+-----------------------------------------------
  152. Option | Description ~
  153. ------------------------+-----------------------------------------------
  154. `branch` / `tag` / `commit` | Branch/tag/commit of the repository to use
  155. `rtp` | Subdirectory that contains Vim plugin
  156. `dir` | Custom directory for the plugin
  157. `as` | Use different name for the plugin
  158. `do` | Post-update hook (string or funcref)
  159. `on` | On-demand loading: Commands or <Plug>-mappings
  160. `for` | On-demand loading: File types
  161. `frozen` | Do not update unless explicitly specified
  162. ------------------------+-----------------------------------------------
  163. < Global options >____________________________________________________________~
  164. *plug-global-options*
  165. *g:plug_threads* *g:plug_timeout* *g:plug_retries* *g:plug_shallow* *g:plug_window*
  166. *g:plug_pwindow* *g:plug_url_format*
  167. --------------------+-----------------------------------+-----------------------------------------------------------------------------------
  168. Flag | Default | Description ~
  169. --------------------+-----------------------------------+-----------------------------------------------------------------------------------
  170. `g:plug_threads` | 16 | Default number of threads to use
  171. `g:plug_timeout` | 60 | Time limit of each task in seconds (Ruby & Python)
  172. `g:plug_retries` | 2 | Number of retries in case of timeout (Ruby & Python)
  173. `g:plug_shallow` | 1 | Use shallow clone
  174. `g:plug_window` | `vertical topleft new` | Command to open plug window
  175. `g:plug_pwindow` | `above 12new` | Command to open preview window in `PlugDiff`
  176. `g:plug_url_format` | `https://git::@github.com/%s.git` | `printf` format to build repo URL (Only applies to the subsequent `Plug` commands)
  177. --------------------+-----------------------------------+-----------------------------------------------------------------------------------
  178. < Keybindings >_______________________________________________________________~
  179. *plug-keybindings*
  180. *:PlugStatus* *:PlugDiff*
  181. - `D` - `PlugDiff`
  182. - `S` - `PlugStatus`
  183. - `R` - Retry failed update or installation tasks
  184. - `U` - Update plugins in the selected range
  185. - `q` - Close the window
  186. - `:PlugStatus`
  187. - `L` - Load plugin
  188. - `:PlugDiff`
  189. - `X` - Revert the update
  190. < Example: A small sensible Vim configuration >_______________________________~
  191. *plug-example-a-small-sensible-vim-configuration*
  192. >
  193. call plug#begin()
  194. Plug 'tpope/vim-sensible'
  195. call plug#end()
  196. <
  197. < On-demand loading of plugins >______________________________________________~
  198. *plug-on-demand-loading-of-plugins*
  199. >
  200. " NERD tree will be loaded on the first invocation of NERDTreeToggle command
  201. Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
  202. " Multiple commands
  203. Plug 'junegunn/vim-github-dashboard', { 'on': ['GHDashboard', 'GHActivity'] }
  204. " Loaded when clojure file is opened
  205. Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
  206. " Multiple file types
  207. Plug 'kovisoft/paredit', { 'for': ['clojure', 'scheme'] }
  208. " On-demand loading on both conditions
  209. Plug 'junegunn/vader.vim', { 'on': 'Vader', 'for': 'vader' }
  210. " Code to execute when the plugin is lazily loaded on demand
  211. Plug 'junegunn/goyo.vim', { 'for': 'markdown' }
  212. autocmd! User goyo.vim echom 'Goyo is now loaded!'
  213. <
  214. The `for` option is generally not needed as most plugins for specific file
  215. types usually don't have too much code in the `plugin` directory. You might
  216. want to examine the output of `vim --startuptime` before applying the option.
  217. < Post-update hooks >_________________________________________________________~
  218. *plug-post-update-hooks*
  219. There are some plugins that require extra steps after installation or update.
  220. In that case, use the `do` option to describe the task to be performed.
  221. >
  222. Plug 'Shougo/vimproc.vim', { 'do': 'make' }
  223. Plug 'ycm-core/YouCompleteMe', { 'do': './install.py' }
  224. <
  225. If the value starts with `:`, it will be recognized as a Vim command.
  226. *:GoInstallBinaries*
  227. >
  228. Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
  229. <
  230. If you need more control, you can pass a reference to a Vim function that
  231. takes a single argument.
  232. >
  233. function! BuildYCM(info)
  234. " info is a dictionary with 3 fields
  235. " - name: name of the plugin
  236. " - status: 'installed', 'updated', or 'unchanged'
  237. " - force: set on PlugInstall! or PlugUpdate!
  238. if a:info.status == 'installed' || a:info.force
  239. !./install.py
  240. endif
  241. endfunction
  242. Plug 'ycm-core/YouCompleteMe', { 'do': function('BuildYCM') }
  243. <
  244. Both forms of post-update hook are executed inside the directory of the plugin
  245. and only run when the repository has changed, but you can force it to run
  246. unconditionally with the bang-versions of the commands: `PlugInstall!` and
  247. `PlugUpdate!`.
  248. Make sure to escape BARs and double-quotes when you write the `do` option
  249. inline as they are mistakenly recognized as command separator or the start of
  250. the trailing comment.
  251. >
  252. Plug 'junegunn/fzf', { 'do': 'yes \| ./install' }
  253. <
  254. But you can avoid the escaping if you extract the inline specification using a
  255. variable (or any Vimscript expression) as follows:
  256. *g:fzf_install*
  257. >
  258. let g:fzf_install = 'yes | ./install'
  259. Plug 'junegunn/fzf', { 'do': g:fzf_install }
  260. <
  261. < PlugInstall! and PlugUpdate! >______________________________________________~
  262. *pluginstall-and-plugupdate*
  263. The installer takes the following steps when installing/updating a plugin:
  264. 1. `git clone` or `git fetch` from its origin
  265. 2. Check out branch, tag, or commit and optionally `git merge` remote branch
  266. 3. If the plugin was updated (or installed for the first time)
  267. 1. Update submodules
  268. 2. Execute post-update hooks
  269. The commands with the `!` suffix ensure that all steps are run
  270. unconditionally.
  271. < Articles >__________________________________________________________________~
  272. *plug-articles*
  273. - {Writing my own Vim plugin manager}{11}
  274. - {Vim plugins and startup time}{12}
  275. - ~~{Thoughts on Vim plugin dependency}{13}~~
  276. - Support for Plugfile has been removed since 0.5.0
  277. {11} http://junegunn.kr/2013/09/writing-my-own-vim-plugin-manager
  278. {12} http://junegunn.kr/2014/07/vim-plugins-and-startup-time
  279. {13} http://junegunn.kr/2013/09/thoughts-on-vim-plugin-dependency
  280. < Collaborators >_____________________________________________________________~
  281. *plug-collaborators*
  282. - {Jan Edmund Lazo}{14} - Windows support
  283. - {Jeremy Pallats}{15} - Python installer
  284. {14} https://github.com/janlazo
  285. {15} https://github.com/starcraftman
  286. < License >___________________________________________________________________~
  287. *plug-license*
  288. MIT
  289. ==============================================================================
  290. vim:tw=78:sw=2:ts=2:ft=help:norl:nowrap: