plug.txt 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. plug.txt plug Last change: Jun 1 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/seoul256.vim.git
  92. Plug 'junegunn/seoul256.vim'
  93. " Any valid git URL is allowed
  94. Plug 'https://github.com/junegunn/vim-easy-align.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. " Color schemes should be loaded after plug#end().
  120. " We prepend it with 'silent!' to ignore errors when it's not yet installed.
  121. silent! colorscheme seoul256
  122. <
  123. < Lua example for Neovim >____________________________________________________~
  124. *plug-lua-example-for-neovim*
  125. In Neovim, you can write your configuration in a Lua script file named
  126. `init.lua`. The following code is the Lua script equivalent to the Vim script
  127. example above.
  128. >
  129. local vim = vim
  130. local Plug = vim.fn['plug#']
  131. vim.call('plug#begin')
  132. -- Shorthand notation for GitHub; translates to https://github.com/junegunn/seoul256.vim.git
  133. Plug('junegunn/seoul256.vim')
  134. -- Any valid git URL is allowed
  135. Plug('https://github.com/junegunn/vim-easy-align.git')
  136. -- Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
  137. Plug('fatih/vim-go', { ['tag'] = '*' })
  138. -- Using a non-default branch
  139. Plug('neoclide/coc.nvim', { ['branch'] = 'release' })
  140. -- Use 'dir' option to install plugin in a non-default directory
  141. Plug('junegunn/fzf', { ['dir'] = '~/.fzf' })
  142. -- Post-update hook: run a shell command after installing or updating the plugin
  143. Plug('junegunn/fzf', { ['dir'] = '~/.fzf', ['do'] = './install --all' })
  144. -- Post-update hook can be a lambda expression
  145. Plug('junegunn/fzf', { ['do'] = function()
  146. vim.fn['fzf#install']()
  147. end })
  148. -- If the vim plugin is in a subdirectory, use 'rtp' option to specify its path
  149. Plug('nsf/gocode', { ['rtp'] = 'vim' })
  150. -- On-demand loading: loaded when the specified command is executed
  151. Plug('preservim/nerdtree', { ['on'] = 'NERDTreeToggle' })
  152. -- On-demand loading: loaded when a file with a specific file type is opened
  153. Plug('tpope/vim-fireplace', { ['for'] = 'clojure' })
  154. -- Unmanaged plugin (manually installed and updated)
  155. Plug('~/my-prototype-plugin')
  156. vim.call('plug#end')
  157. -- Color schemes should be loaded after plug#end().
  158. -- We prepend it with 'silent!' to ignore errors when it's not yet installed.
  159. vim.cmd('silent! colorscheme seoul256')
  160. <
  161. COMMANDS *plug-commands*
  162. ==============================================================================
  163. -------------------------------------+------------------------------------------------------------------
  164. Command | Description ~
  165. -------------------------------------+------------------------------------------------------------------
  166. `PlugInstall [name ...] [#threads]` | Install plugins
  167. `PlugUpdate [name ...] [#threads]` | Install or update plugins
  168. `PlugClean[!]` | Remove unlisted plugins (bang version will clean without prompt)
  169. `PlugUpgrade` | Upgrade vim-plug itself
  170. `PlugStatus` | Check the status of plugins
  171. `PlugDiff` | Examine changes from the previous update and the pending changes
  172. `PlugSnapshot[!] [output path]` | Generate script for restoring the current snapshot of the plugins
  173. -------------------------------------+------------------------------------------------------------------
  174. PLUG OPTIONS *plug-options*
  175. ==============================================================================
  176. *<Plug>-mappings*
  177. ------------------------+------------------------------------------------------------
  178. Option | Description ~
  179. ------------------------+------------------------------------------------------------
  180. `branch` / `tag` / `commit` | Branch/tag/commit of the repository to use
  181. `rtp` | Subdirectory that contains Vim plugin
  182. `dir` | Custom directory for the plugin
  183. `as` | Use different name for the plugin
  184. `do` | Post-update hook (string or funcref)
  185. `on` | On-demand loading: Commands or <Plug>-mappings
  186. `for` | On-demand loading: File types
  187. `frozen` | Do not remove and do not update unless explicitly specified
  188. ------------------------+------------------------------------------------------------
  189. GLOBAL OPTIONS *plug-global-options*
  190. ==============================================================================
  191. *g:plug_threads* *g:plug_timeout* *g:plug_retries* *g:plug_shallow* *g:plug_window*
  192. *g:plug_pwindow* *g:plug_url_format*
  193. --------------------+-----------------------------------+-----------------------------------------------------------------------------------
  194. Flag | Default | Description ~
  195. --------------------+-----------------------------------+-----------------------------------------------------------------------------------
  196. `g:plug_threads` | 16 | Default number of threads to use
  197. `g:plug_timeout` | 60 | Time limit of each task in seconds (Ruby & Python)
  198. `g:plug_retries` | 2 | Number of retries in case of timeout (Ruby & Python)
  199. `g:plug_shallow` | 1 | Use shallow clone
  200. `g:plug_window` | `-tabnew` | Command to open plug window
  201. `g:plug_pwindow` | `vertical rightbelow new` | Command to open preview window in `PlugDiff`
  202. `g:plug_url_format` | `https://git::@github.com/%s.git` | `printf` format to build repo URL (Only applies to the subsequent `Plug` commands)
  203. --------------------+-----------------------------------+-----------------------------------------------------------------------------------
  204. KEYBINDINGS *plug-keybindings*
  205. ==============================================================================
  206. - `D` - `PlugDiff`
  207. - `S` - `PlugStatus`
  208. - `R` - Retry failed update or installation tasks
  209. - `U` - Update plugins in the selected range
  210. - `q` - Close the window
  211. - `:PlugStatus`
  212. - `L` - Load plugin
  213. - `:PlugDiff`
  214. - `X` - Revert the update
  215. POST-UPDATE HOOKS *plug-post-update-hooks*
  216. ==============================================================================
  217. There are some plugins that require extra steps after installation or update.
  218. In that case, use the `do` option to describe the task to be performed.
  219. >
  220. Plug 'Shougo/vimproc.vim', { 'do': 'make' }
  221. Plug 'ycm-core/YouCompleteMe', { 'do': './install.py' }
  222. <
  223. If the value starts with `:`, it will be recognized as a Vim command.
  224. >
  225. Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
  226. <
  227. To call a Vim function, you can pass a lambda expression like so:
  228. >
  229. Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
  230. <
  231. If you need more control, you can pass a reference to a Vim function that
  232. takes a dictionary argument.
  233. >
  234. function! BuildYCM(info)
  235. " info is a dictionary with 3 fields
  236. " - name: name of the plugin
  237. " - status: 'installed', 'updated', or 'unchanged'
  238. " - force: set on PlugInstall! or PlugUpdate!
  239. if a:info.status == 'installed' || a:info.force
  240. !./install.py
  241. endif
  242. endfunction
  243. Plug 'ycm-core/YouCompleteMe', { 'do': function('BuildYCM') }
  244. <
  245. A post-update hook is executed inside the directory of the plugin and only run
  246. when the repository has changed, but you can force it to run unconditionally
  247. with the bang-versions of the commands: `PlugInstall!` and `PlugUpdate!`.
  248. [!TIP] Make sure to escape BARs and double-quotes when you write the `do`
  249. option inline as they are mistakenly recognized as command separator or the
  250. start of 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 Vim script expression) as follows:
  256. >
  257. let g:fzf_install = 'yes | ./install'
  258. Plug 'junegunn/fzf', { 'do': g:fzf_install }
  259. <
  260. < PlugInstall! and PlugUpdate! >______________________________________________~
  261. *pluginstall-and-plugupdate*
  262. The installer takes the following steps when installing/updating a plugin:
  263. 1. `git clone` or `git fetch` from its origin
  264. 2. Check out branch, tag, or commit and optionally `git merge` remote branch
  265. 3. If the plugin was updated (or installed for the first time)
  266. 1. Update submodules
  267. 2. Execute post-update hooks
  268. The commands with the `!` suffix ensure that all steps are run
  269. unconditionally.
  270. ON-DEMAND LOADING OF PLUGINS *plug-on-demand-loading-of-plugins*
  271. ==============================================================================
  272. >
  273. " NERD tree will be loaded on the first invocation of NERDTreeToggle command
  274. Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
  275. " Multiple commands
  276. Plug 'junegunn/vim-github-dashboard', { 'on': ['GHDashboard', 'GHActivity'] }
  277. " Loaded when clojure file is opened
  278. Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
  279. " Multiple file types
  280. Plug 'kovisoft/paredit', { 'for': ['clojure', 'scheme'] }
  281. " On-demand loading on both conditions
  282. Plug 'junegunn/vader.vim', { 'on': 'Vader', 'for': 'vader' }
  283. " Code to execute when the plugin is lazily loaded on demand
  284. Plug 'junegunn/goyo.vim', { 'for': 'markdown' }
  285. autocmd! User goyo.vim echom 'Goyo is now loaded!'
  286. <
  287. [!NOTE] #### Should I set up on-demand loading?
  288. You probably don't need to.
  289. A properly implemented Vim plugin should already load lazily without any help
  290. from a plugin manager (`:help autoload`). So there are few cases where these
  291. options actually make much sense. Making a plugin load faster is the
  292. responsibility of the plugin developer, not the user. If you find a plugin
  293. that takes too long to load, consider opening an issue on the plugin's issue
  294. tracker.
  295. Let me give you a perspective. The time it takes to load a plugin is usually
  296. less than 2 or 3ms on modern computers. So unless you use a very large number
  297. of plugins, you are unlikely to save more than 50ms. If you have spent an hour
  298. carefully setting up the options to shave off 50ms, you will have to start Vim
  299. 72,000 times just to break even. You should ask yourself if that's a good
  300. investment of your time.
  301. Make sure that you're tackling the right problem by breaking down the startup
  302. time of Vim using `--startuptime`.
  303. >
  304. vim --startuptime /tmp/log
  305. <
  306. On-demand loading should only be used as a last resort. It is basically a
  307. hacky workaround and is not always guaranteed to work.
  308. *plug#load*
  309. [!TIP] You can pass an empty list to `on` or `for` option to disable the
  310. loading of the plugin. You can manually load the plugin using
  311. `plug#load(NAMES...)` function.
  312. See https://github.com/junegunn/vim-plug/wiki/tips#loading-plugins-manually
  313. COLLABORATORS *plug-collaborators*
  314. ==============================================================================
  315. - {Jan Edmund Lazo}{7} - Windows support
  316. - {Jeremy Pallats}{8} - Python installer
  317. {7} https://github.com/janlazo
  318. {8} https://github.com/starcraftman
  319. LICENSE *plug-license*
  320. ==============================================================================
  321. MIT
  322. ==============================================================================
  323. vim:tw=78:sw=2:ts=2:ft=help:norl:nowrap: