plug.txt 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  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. " - Automatically executes `filetype plugin indent on` and `syntax enable`.
  132. call plug#end()
  133. " You can revert the settings after the call like so:
  134. " filetype indent off " Disable file-type-specific indentation
  135. " syntax off " Disable syntax highlighting
  136. <
  137. *:PlugInstall*
  138. Reload .vimrc and `:PlugInstall` to install plugins.
  139. < Commands >__________________________________________________________________~
  140. *plug-commands*
  141. ------------------------------------+-------------------------------------------------------------------
  142. Command | Description ~
  143. ------------------------------------+-------------------------------------------------------------------
  144. `PlugInstall [name ...] [#threads]` | Install plugins
  145. `PlugUpdate [name ...] [#threads]` | Install or update plugins
  146. `PlugClean[!]` | Remove unlisted plugins (bang version will clean without prompt)
  147. `PlugUpgrade` | Upgrade vim-plug itself
  148. `PlugStatus` | Check the status of plugins
  149. `PlugDiff` | Examine changes from the previous update and the pending changes
  150. `PlugSnapshot[!] [output path]` | Generate script for restoring the current snapshot of the plugins
  151. ------------------------------------+-------------------------------------------------------------------
  152. < Plug options >______________________________________________________________~
  153. *plug-options*
  154. *:Plug*
  155. ------------------------+-----------------------------------------------
  156. Option | Description ~
  157. ------------------------+-----------------------------------------------
  158. `branch` / `tag` / `commit` | Branch/tag/commit of the repository to use
  159. `rtp` | Subdirectory that contains Vim plugin
  160. `dir` | Custom directory for the plugin
  161. `as` | Use different name for the plugin
  162. `do` | Post-update hook (string or funcref)
  163. `on` | On-demand loading: Commands or <Plug>-mappings
  164. `for` | On-demand loading: File types
  165. `frozen` | Do not update unless explicitly specified
  166. ------------------------+-----------------------------------------------
  167. < Global options >____________________________________________________________~
  168. *plug-global-options*
  169. *g:plug_threads* *g:plug_timeout* *g:plug_retries* *g:plug_shallow* *g:plug_window*
  170. *g:plug_pwindow* *g:plug_url_format*
  171. --------------------+-----------------------------------+-----------------------------------------------------------------------------------
  172. Flag | Default | Description ~
  173. --------------------+-----------------------------------+-----------------------------------------------------------------------------------
  174. `g:plug_threads` | 16 | Default number of threads to use
  175. `g:plug_timeout` | 60 | Time limit of each task in seconds (Ruby & Python)
  176. `g:plug_retries` | 2 | Number of retries in case of timeout (Ruby & Python)
  177. `g:plug_shallow` | 1 | Use shallow clone
  178. `g:plug_window` | `vertical topleft new` | Command to open plug window
  179. `g:plug_pwindow` | `above 12new` | Command to open preview window in `PlugDiff`
  180. `g:plug_url_format` | `https://git::@github.com/%s.git` | `printf` format to build repo URL (Only applies to the subsequent `Plug` commands)
  181. --------------------+-----------------------------------+-----------------------------------------------------------------------------------
  182. < Keybindings >_______________________________________________________________~
  183. *plug-keybindings*
  184. *:PlugStatus* *:PlugDiff*
  185. - `D` - `PlugDiff`
  186. - `S` - `PlugStatus`
  187. - `R` - Retry failed update or installation tasks
  188. - `U` - Update plugins in the selected range
  189. - `q` - Close the window
  190. - `:PlugStatus`
  191. - `L` - Load plugin
  192. - `:PlugDiff`
  193. - `X` - Revert the update
  194. < Example: A small sensible Vim configuration >_______________________________~
  195. *plug-example-a-small-sensible-vim-configuration*
  196. >
  197. call plug#begin()
  198. Plug 'tpope/vim-sensible'
  199. call plug#end()
  200. <
  201. < On-demand loading of plugins >______________________________________________~
  202. *plug-on-demand-loading-of-plugins*
  203. >
  204. " NERD tree will be loaded on the first invocation of NERDTreeToggle command
  205. Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
  206. " Multiple commands
  207. Plug 'junegunn/vim-github-dashboard', { 'on': ['GHDashboard', 'GHActivity'] }
  208. " Loaded when clojure file is opened
  209. Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
  210. " Multiple file types
  211. Plug 'kovisoft/paredit', { 'for': ['clojure', 'scheme'] }
  212. " On-demand loading on both conditions
  213. Plug 'junegunn/vader.vim', { 'on': 'Vader', 'for': 'vader' }
  214. " Code to execute when the plugin is lazily loaded on demand
  215. Plug 'junegunn/goyo.vim', { 'for': 'markdown' }
  216. autocmd! User goyo.vim echom 'Goyo is now loaded!'
  217. <
  218. The `for` option is generally not needed as most plugins for specific file
  219. types usually don't have too much code in the `plugin` directory. You might
  220. want to examine the output of `vim --startuptime` before applying the option.
  221. < Post-update hooks >_________________________________________________________~
  222. *plug-post-update-hooks*
  223. There are some plugins that require extra steps after installation or update.
  224. In that case, use the `do` option to describe the task to be performed.
  225. >
  226. Plug 'Shougo/vimproc.vim', { 'do': 'make' }
  227. Plug 'ycm-core/YouCompleteMe', { 'do': './install.py' }
  228. <
  229. If the value starts with `:`, it will be recognized as a Vim command.
  230. *:GoInstallBinaries*
  231. >
  232. Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
  233. <
  234. If you need more control, you can pass a reference to a Vim function that
  235. takes a single argument.
  236. >
  237. function! BuildYCM(info)
  238. " info is a dictionary with 3 fields
  239. " - name: name of the plugin
  240. " - status: 'installed', 'updated', or 'unchanged'
  241. " - force: set on PlugInstall! or PlugUpdate!
  242. if a:info.status == 'installed' || a:info.force
  243. !./install.py
  244. endif
  245. endfunction
  246. Plug 'ycm-core/YouCompleteMe', { 'do': function('BuildYCM') }
  247. <
  248. Both forms of post-update hook are executed inside the directory of the plugin
  249. and only run when the repository has changed, but you can force it to run
  250. unconditionally with the bang-versions of the commands: `PlugInstall!` and
  251. `PlugUpdate!`.
  252. Make sure to escape BARs and double-quotes when you write the `do` option
  253. inline as they are mistakenly recognized as command separator or the start of
  254. the trailing comment.
  255. >
  256. Plug 'junegunn/fzf', { 'do': 'yes \| ./install' }
  257. <
  258. But you can avoid the escaping if you extract the inline specification using a
  259. variable (or any Vimscript expression) as follows:
  260. *g:fzf_install*
  261. >
  262. let g:fzf_install = 'yes | ./install'
  263. Plug 'junegunn/fzf', { 'do': g:fzf_install }
  264. <
  265. < PlugInstall! and PlugUpdate! >______________________________________________~
  266. *pluginstall-and-plugupdate*
  267. The installer takes the following steps when installing/updating a plugin:
  268. 1. `git clone` or `git fetch` from its origin
  269. 2. Check out branch, tag, or commit and optionally `git merge` remote branch
  270. 3. If the plugin was updated (or installed for the first time)
  271. 1. Update submodules
  272. 2. Execute post-update hooks
  273. The commands with the `!` suffix ensure that all steps are run
  274. unconditionally.
  275. < Articles >__________________________________________________________________~
  276. *plug-articles*
  277. - {Writing my own Vim plugin manager}{11}
  278. - {Vim plugins and startup time}{12}
  279. - ~~{Thoughts on Vim plugin dependency}{13}~~
  280. - Support for Plugfile has been removed since 0.5.0
  281. {11} http://junegunn.kr/2013/09/writing-my-own-vim-plugin-manager
  282. {12} http://junegunn.kr/2014/07/vim-plugins-and-startup-time
  283. {13} http://junegunn.kr/2013/09/thoughts-on-vim-plugin-dependency
  284. < Collaborators >_____________________________________________________________~
  285. *plug-collaborators*
  286. - {Jan Edmund Lazo}{14} - Windows support
  287. - {Jeremy Pallats}{15} - Python installer
  288. {14} https://github.com/janlazo
  289. {15} https://github.com/starcraftman
  290. < License >___________________________________________________________________~
  291. *plug-license*
  292. MIT
  293. ==============================================================================
  294. vim:tw=78:sw=2:ts=2:ft=help:norl:nowrap: