plug.txt 15 KB

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