plug.txt 15 KB

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