plug.txt 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. plug.txt plug Last change: May 15 2024
  2. PLUG - TABLE OF CONTENTS *plug* *plug-toc*
  3. ==============================================================================
  4. vim-plug |vim-plug|
  5. Pros. |plug-pros|
  6. Installation |plug-installation|
  7. Usage |plug-usage|
  8. Getting Help |plug-getting-help|
  9. Examples |plug-examples|
  10. Vim script example |plug-vim-script-example|
  11. Lua example for Neovim |plug-lua-example-for-neovim|
  12. Commands |plug-commands|
  13. Plug options |plug-options|
  14. Global options |plug-global-options|
  15. Keybindings |plug-keybindings|
  16. Post-update hooks |plug-post-update-hooks|
  17. PlugInstall! and PlugUpdate! |pluginstall-and-plugupdate|
  18. On-demand loading of plugins |plug-on-demand-loading-of-plugins|
  19. Collaborators |plug-collaborators|
  20. License |plug-license|
  21. VIM-PLUG *vim-plug*
  22. ==============================================================================
  23. A minimalist Vim plugin manager.
  24. PROS. *plug-pros*
  25. ==============================================================================
  26. - Minimalist design
  27. - Just one file with no dependencies. Super easy to set up.
  28. - Concise, intuitive syntax that you can learn within minutes. No
  29. boilerplate code required.
  30. - No feature bloat
  31. - Extremely stable with flawless backward compatibility
  32. - Works perfectly with all versions of Vim since 2006 and all versions of
  33. Neovim ever released
  34. - {Super-fast}{1} parallel installation/update
  35. - Creates shallow clones to minimize disk space usage and download time
  36. - On-demand loading for {faster startup time}{2}
  37. - Can review and rollback updates
  38. - Branch/tag/commit support
  39. - Post-update hooks
  40. - Support for externally managed plugins
  41. {1} https://raw.githubusercontent.com/junegunn/i/master/vim-plug/40-in-4.gif
  42. {2} https://github.com/junegunn/vim-startuptime-benchmark#result
  43. INSTALLATION *plug-installation*
  44. ==============================================================================
  45. {Download plug.vim}{3} and put it in the "autoload" directory.
  46. {3} https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  47. USAGE *plug-usage*
  48. ==============================================================================
  49. Add a vim-plug section to your `~/.vimrc` (or `init.vim` for Neovim)
  50. *plug#begin* *plug#end*
  51. 1. Begin the section with `call plug#begin()`
  52. 2. List the plugins with `Plug` commands
  53. 3. End the section with `call plug#end()`
  54. For example,
  55. >
  56. call plug#begin()
  57. " List your plugins here
  58. Plug 'tpope/vim-sensible'
  59. call plug#end()
  60. <
  61. Reload the file or restart Vim, then you can,
  62. *:PlugInstall* *:PlugUpdate* *:PlugDiff*
  63. - `:PlugInstall` to install the plugins
  64. - `:PlugUpdate` to install or update the plugins
  65. - `:PlugDiff` to review the changes from the last update
  66. [!NOTE] That's basically all you need to know to get started. The rest of the
  67. document is for advanced users who want to know more about the features and
  68. options.
  69. < Getting Help >______________________________________________________________~
  70. *plug-getting-help*
  71. - See {tutorial}{4} page to learn more about the basics of vim-plug
  72. - See {tips}{5} and {FAQ}{6} pages for common problems and questions
  73. {4} https://github.com/junegunn/vim-plug/wiki/tutorial
  74. {5} https://github.com/junegunn/vim-plug/wiki/tips
  75. {6} https://github.com/junegunn/vim-plug/wiki/faq
  76. EXAMPLES *plug-examples*
  77. ==============================================================================
  78. The following examples demonstrate the additional features of vim-plug.
  79. < Vim script example >________________________________________________________~
  80. *plug-vim-script-example*
  81. >
  82. call plug#begin()
  83. " The default plugin directory will be as follows:
  84. " - Vim (Linux/macOS): '~/.vim/plugged'
  85. " - Vim (Windows): '~/vimfiles/plugged'
  86. " - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged'
  87. " You can specify a custom plugin directory by passing it as the argument
  88. " - e.g. `call plug#begin('~/.vim/plugged')`
  89. " - Avoid using standard Vim directory names like 'plugin'
  90. " Make sure you use single quotes
  91. " Shorthand notation for GitHub; translates to https://github.com/junegunn/vim-easy-align
  92. Plug 'junegunn/vim-easy-align'
  93. " Any valid git URL is allowed
  94. Plug 'https://github.com/junegunn/seoul256.vim.git'
  95. " Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
  96. Plug 'fatih/vim-go', { 'tag': '*' }
  97. " Using a non-default branch
  98. Plug 'neoclide/coc.nvim', { 'branch': 'release' }
  99. " Use 'dir' option to install plugin in a non-default directory
  100. Plug 'junegunn/fzf', { 'dir': '~/.fzf' }
  101. " Post-update hook: run a shell command after installing or updating the plugin
  102. Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
  103. " Post-update hook can be a lambda expression
  104. Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
  105. " If the vim plugin is in a subdirectory, use 'rtp' option to specify its path
  106. Plug 'nsf/gocode', { 'rtp': 'vim' }
  107. " On-demand loading: loaded when the specified command is executed
  108. Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
  109. " On-demand loading: loaded when a file with a specific file type is opened
  110. Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
  111. " Unmanaged plugin (manually installed and updated)
  112. Plug '~/my-prototype-plugin'
  113. " Call plug#end to update &runtimepath and initialize the plugin system.
  114. " - It automatically executes `filetype plugin indent on` and `syntax enable`
  115. call plug#end()
  116. " You can revert the settings after the call like so:
  117. " filetype indent off " Disable file-type-specific indentation
  118. " syntax off " Disable syntax highlighting
  119. <
  120. < Lua example for Neovim >____________________________________________________~
  121. *plug-lua-example-for-neovim*
  122. In Neovim, you can write your configuration in a Lua script file named
  123. `init.lua`. The following code is the Lua script equivalent to the Vim script
  124. example above.
  125. >
  126. local vim = vim
  127. local Plug = vim.fn['plug#']
  128. vim.call('plug#begin')
  129. -- Shorthand notation for GitHub; translates to https://github.com/junegunn/vim-easy-align
  130. Plug('junegunn/vim-easy-align')
  131. -- Any valid git URL is allowed
  132. Plug('https://github.com/junegunn/seoul256.vim.git')
  133. -- Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
  134. Plug('fatih/vim-go', { ['tag'] = '*' })
  135. -- Using a non-default branch
  136. Plug('neoclide/coc.nvim', { ['branch'] = 'release' })
  137. -- Use 'dir' option to install plugin in a non-default directory
  138. Plug('junegunn/fzf', { ['dir'] = '~/.fzf' })
  139. -- Post-update hook: run a shell command after installing or updating the plugin
  140. Plug('junegunn/fzf', { ['dir'] = '~/.fzf', ['do'] = './install --all' })
  141. -- Post-update hook can be a lambda expression
  142. Plug('junegunn/fzf', { ['do'] = function()
  143. vim.fn['fzf#install']()
  144. end })
  145. -- If the vim plugin is in a subdirectory, use 'rtp' option to specify its path
  146. Plug('nsf/gocode', { ['rtp'] = 'vim' })
  147. -- On-demand loading: loaded when the specified command is executed
  148. Plug('preservim/nerdtree', { ['on'] = 'NERDTreeToggle' })
  149. -- On-demand loading: loaded when a file with a specific file type is opened
  150. Plug('tpope/vim-fireplace', { ['for'] = 'clojure' })
  151. -- Unmanaged plugin (manually installed and updated)
  152. Plug('~/my-prototype-plugin')
  153. vim.call('plug#end')
  154. <
  155. COMMANDS *plug-commands*
  156. ==============================================================================
  157. -------------------------------------+------------------------------------------------------------------
  158. Command | Description ~
  159. -------------------------------------+------------------------------------------------------------------
  160. `PlugInstall [name ...] [#threads]` | Install plugins
  161. `PlugUpdate [name ...] [#threads]` | Install or update plugins
  162. `PlugClean[!]` | Remove unlisted plugins (bang version will clean without prompt)
  163. `PlugUpgrade` | Upgrade vim-plug itself
  164. `PlugStatus` | Check the status of plugins
  165. `PlugDiff` | Examine changes from the previous update and the pending changes
  166. `PlugSnapshot[!] [output path]` | Generate script for restoring the current snapshot of the plugins
  167. -------------------------------------+------------------------------------------------------------------
  168. PLUG OPTIONS *plug-options*
  169. ==============================================================================
  170. *<Plug>-mappings*
  171. ------------------------+------------------------------------------------------------
  172. Option | Description ~
  173. ------------------------+------------------------------------------------------------
  174. `branch` / `tag` / `commit` | Branch/tag/commit of the repository to use
  175. `rtp` | Subdirectory that contains Vim plugin
  176. `dir` | Custom directory for the plugin
  177. `as` | Use different name for the plugin
  178. `do` | Post-update hook (string or funcref)
  179. `on` | On-demand loading: Commands or <Plug>-mappings
  180. `for` | On-demand loading: File types
  181. `frozen` | Do not remove and do not update unless explicitly specified
  182. ------------------------+------------------------------------------------------------
  183. GLOBAL OPTIONS *plug-global-options*
  184. ==============================================================================
  185. *g:plug_threads* *g:plug_timeout* *g:plug_retries* *g:plug_shallow* *g:plug_window*
  186. *g:plug_pwindow* *g:plug_url_format*
  187. --------------------+-----------------------------------+-----------------------------------------------------------------------------------
  188. Flag | Default | Description ~
  189. --------------------+-----------------------------------+-----------------------------------------------------------------------------------
  190. `g:plug_threads` | 16 | Default number of threads to use
  191. `g:plug_timeout` | 60 | Time limit of each task in seconds (Ruby & Python)
  192. `g:plug_retries` | 2 | Number of retries in case of timeout (Ruby & Python)
  193. `g:plug_shallow` | 1 | Use shallow clone
  194. `g:plug_window` | `-tabnew` | Command to open plug window
  195. `g:plug_pwindow` | `vertical rightbelow new` | Command to open preview window in `PlugDiff`
  196. `g:plug_url_format` | `https://git::@github.com/%s.git` | `printf` format to build repo URL (Only applies to the subsequent `Plug` commands)
  197. --------------------+-----------------------------------+-----------------------------------------------------------------------------------
  198. KEYBINDINGS *plug-keybindings*
  199. ==============================================================================
  200. - `D` - `PlugDiff`
  201. - `S` - `PlugStatus`
  202. - `R` - Retry failed update or installation tasks
  203. - `U` - Update plugins in the selected range
  204. - `q` - Close the window
  205. - `:PlugStatus`
  206. - `L` - Load plugin
  207. - `:PlugDiff`
  208. - `X` - Revert the update
  209. POST-UPDATE HOOKS *plug-post-update-hooks*
  210. ==============================================================================
  211. There are some plugins that require extra steps after installation or update.
  212. In that case, use the `do` option to describe the task to be performed.
  213. >
  214. Plug 'Shougo/vimproc.vim', { 'do': 'make' }
  215. Plug 'ycm-core/YouCompleteMe', { 'do': './install.py' }
  216. <
  217. If the value starts with `:`, it will be recognized as a Vim command.
  218. >
  219. Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
  220. <
  221. To call a Vim function, you can pass a lambda expression like so:
  222. >
  223. Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
  224. <
  225. If you need more control, you can pass a reference to a Vim function that
  226. takes a dictionary argument.
  227. >
  228. function! BuildYCM(info)
  229. " info is a dictionary with 3 fields
  230. " - name: name of the plugin
  231. " - status: 'installed', 'updated', or 'unchanged'
  232. " - force: set on PlugInstall! or PlugUpdate!
  233. if a:info.status == 'installed' || a:info.force
  234. !./install.py
  235. endif
  236. endfunction
  237. Plug 'ycm-core/YouCompleteMe', { 'do': function('BuildYCM') }
  238. <
  239. A post-update hook is executed inside the directory of the plugin and only run
  240. when the repository has changed, but you can force it to run unconditionally
  241. with the bang-versions of the commands: `PlugInstall!` and `PlugUpdate!`.
  242. [!TIP] Make sure to escape BARs and double-quotes when you write the `do`
  243. option inline as they are mistakenly recognized as command separator or the
  244. start of the trailing comment.
  245. >
  246. Plug 'junegunn/fzf', { 'do': 'yes \| ./install' }
  247. <
  248. But you can avoid the escaping if you extract the inline specification using a
  249. variable (or any Vim script expression) as follows:
  250. >
  251. let g:fzf_install = 'yes | ./install'
  252. Plug 'junegunn/fzf', { 'do': g:fzf_install }
  253. <
  254. < PlugInstall! and PlugUpdate! >______________________________________________~
  255. *pluginstall-and-plugupdate*
  256. The installer takes the following steps when installing/updating a plugin:
  257. 1. `git clone` or `git fetch` from its origin
  258. 2. Check out branch, tag, or commit and optionally `git merge` remote branch
  259. 3. If the plugin was updated (or installed for the first time)
  260. 1. Update submodules
  261. 2. Execute post-update hooks
  262. The commands with the `!` suffix ensure that all steps are run
  263. unconditionally.
  264. ON-DEMAND LOADING OF PLUGINS *plug-on-demand-loading-of-plugins*
  265. ==============================================================================
  266. >
  267. " NERD tree will be loaded on the first invocation of NERDTreeToggle command
  268. Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
  269. " Multiple commands
  270. Plug 'junegunn/vim-github-dashboard', { 'on': ['GHDashboard', 'GHActivity'] }
  271. " Loaded when clojure file is opened
  272. Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
  273. " Multiple file types
  274. Plug 'kovisoft/paredit', { 'for': ['clojure', 'scheme'] }
  275. " On-demand loading on both conditions
  276. Plug 'junegunn/vader.vim', { 'on': 'Vader', 'for': 'vader' }
  277. " Code to execute when the plugin is lazily loaded on demand
  278. Plug 'junegunn/goyo.vim', { 'for': 'markdown' }
  279. autocmd! User goyo.vim echom 'Goyo is now loaded!'
  280. <
  281. [!NOTE] #### Should I set up on-demand loading?
  282. You probably don't need to.
  283. A properly implemented Vim plugin should already load lazily without any help
  284. from a plugin manager (`:help autoload`). So there are few cases where these
  285. options actually make much sense. Making a plugin load faster is the
  286. responsibility of the plugin developer, not the user. If you find a plugin
  287. that takes too long to load, consider opening an issue on the plugin's issue
  288. tracker.
  289. Let me give you a perspective. The time it takes to load a plugin is usually
  290. less than 2 or 3ms on modern computers. So unless you use a very large number
  291. of plugins, you are unlikely to save more than 50ms. If you have spent an hour
  292. carefully setting up the options to shave off 50ms, you will have to start Vim
  293. 72,000 times just to break even. You should ask yourself if that's a good
  294. investment of your time.
  295. Make sure that you're tackling the right problem by breaking down the startup
  296. time of Vim using `--startuptime`.
  297. >
  298. vim --startuptime /tmp/log
  299. <
  300. On-demand loading should only be used as a last resort. It is basically a
  301. hacky workaround and is not always guaranteed to work.
  302. *plug#load*
  303. [!TIP] You can pass an empty list to `on` or `for` option to disable the
  304. loading of the plugin. You can manually load the plugin using
  305. `plug#load(NAMES...)` function.
  306. See https://github.com/junegunn/vim-plug/wiki/tips#loading-plugins-manually
  307. COLLABORATORS *plug-collaborators*
  308. ==============================================================================
  309. - {Jan Edmund Lazo}{7} - Windows support
  310. - {Jeremy Pallats}{8} - Python installer
  311. {7} https://github.com/janlazo
  312. {8} https://github.com/starcraftman
  313. LICENSE *plug-license*
  314. ==============================================================================
  315. MIT
  316. ==============================================================================
  317. vim:tw=78:sw=2:ts=2:ft=help:norl:nowrap: