plug.txt 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. plug.txt plug Last change: March 14 2024
  2. PLUG - TABLE OF CONTENTS *plug* *plug-toc*
  3. ==============================================================================
  4. vim-plug |vim-plug|
  5. Getting Help |plug-getting-help|
  6. Usage |plug-usage|
  7. Example |plug-example|
  8. Example (Lua configuration for Neovim) |plug-examplelua-configuration-for-neovim|
  9. Commands |plug-commands|
  10. Plug options |plug-options|
  11. Global options |plug-global-options|
  12. Keybindings |plug-keybindings|
  13. Example: A small sensible Vim configuration |plug-example-a-small-sensible-vim-configuration|
  14. On-demand loading of plugins |plug-on-demand-loading-of-plugins|
  15. Post-update hooks |plug-post-update-hooks|
  16. PlugInstall! and PlugUpdate! |pluginstall-and-plugupdate|
  17. License |plug-license|
  18. VIM-PLUG *vim-plug*
  19. ==============================================================================
  20. A minimalist Vim plugin manager.
  21. < Getting Help >______________________________________________________________~
  22. *plug-getting-help*
  23. - See {tutorial}{1} page to learn the basics of vim-plug
  24. - See {tips}{2} and {FAQ}{3} pages for common problems and questions
  25. - See {requirements}{4} page for debugging information & tested configurations
  26. - Create an {issue}{5}
  27. {1} https://github.com/junegunn/vim-plug/wiki/tutorial
  28. {2} https://github.com/junegunn/vim-plug/wiki/tips
  29. {3} https://github.com/junegunn/vim-plug/wiki/faq
  30. {4} https://github.com/junegunn/vim-plug/wiki/requirements
  31. {5} https://github.com/junegunn/vim-plug/issues/new
  32. < Usage >_____________________________________________________________________~
  33. *plug-usage*
  34. Add a vim-plug section to your `~/.vimrc` (or
  35. `stdpath('config') . '/init.vim'` for Neovim)
  36. *plug#begin* *plug#end*
  37. 1. Begin the section with `call plug#begin([PLUGIN_DIR])`
  38. 2. List the plugins with `Plug` commands
  39. 3. `call plug#end()` to update 'runtimepath' and initialize plugin system
  40. - Automatically executes `filetype plugin indent on` and `syntax enable`.
  41. You can revert the settings after the call. e.g. `filetype indent off`,
  42. `syntax off`, etc.
  43. 4. Reload the file or restart Vim and run `:PlugInstall` to install plugins.
  44. Example~
  45. *plug-example*
  46. >
  47. call plug#begin()
  48. " The default plugin directory will be as follows:
  49. " - Vim (Linux/macOS): '~/.vim/plugged'
  50. " - Vim (Windows): '~/vimfiles/plugged'
  51. " - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged'
  52. " You can specify a custom plugin directory by passing it as the argument
  53. " - e.g. `call plug#begin('~/.vim/plugged')`
  54. " - Avoid using standard Vim directory names like 'plugin'
  55. " Make sure you use single quotes
  56. " Shorthand notation for GitHub; translates to https://github.com/junegunn/vim-easy-align
  57. Plug 'junegunn/vim-easy-align'
  58. " Any valid git URL is allowed
  59. Plug 'https://github.com/junegunn/seoul256.vim.git'
  60. " Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
  61. Plug 'fatih/vim-go', { 'tag': '*' }
  62. " Using a non-default branch
  63. Plug 'neoclide/coc.nvim', { 'branch': 'release' }
  64. " Use 'dir' option to install plugin in a non-default directory
  65. Plug 'junegunn/fzf', { 'dir': '~/.fzf' }
  66. " Post-update hook: run a shell command after installing or updating the plugin
  67. Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
  68. " Post-update hook can be a lambda expression
  69. Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
  70. " If the vim plugin is in a subdirectory, use 'rtp' option to specify its path
  71. Plug 'nsf/gocode', { 'rtp': 'vim' }
  72. " On-demand loading: loaded when the specified command is executed
  73. Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
  74. " On-demand loading: loaded when a file with a specific file type is opened
  75. Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
  76. " Unmanaged plugin (manually installed and updated)
  77. Plug '~/my-prototype-plugin'
  78. " Initialize plugin system
  79. " - Automatically executes `filetype plugin indent on` and `syntax enable`.
  80. call plug#end()
  81. " You can revert the settings after the call like so:
  82. " filetype indent off " Disable file-type-specific indentation
  83. " syntax off " Disable syntax highlighting
  84. <
  85. Example (Lua configuration for Neovim)~
  86. *plug-example-lua-configuration-for-neovim*
  87. In Neovim, you can write your configuration in a Lua script file named
  88. `init.lua`. The following code is the Lua script equivalent to the VimScript
  89. example above.
  90. >
  91. local vim = vim
  92. local Plug = vim.fn['plug#']
  93. vim.call('plug#begin')
  94. -- Shorthand notation for GitHub; translates to https://github.com/junegunn/vim-easy-align
  95. Plug('junegunn/vim-easy-align')
  96. -- Any valid git URL is allowed
  97. Plug('https://github.com/junegunn/seoul256.vim.git')
  98. -- Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
  99. Plug('fatih/vim-go', { ['tag'] = '*' })
  100. -- Using a non-default branch
  101. Plug('neoclide/coc.nvim', { ['branch'] = 'release' })
  102. -- Use 'dir' option to install plugin in a non-default directory
  103. Plug('junegunn/fzf', { ['dir'] = '~/.fzf' })
  104. -- Post-update hook: run a shell command after installing or updating the plugin
  105. Plug('junegunn/fzf', { ['dir'] = '~/.fzf', ['do'] = './install --all' })
  106. -- Post-update hook can be a lambda expression
  107. Plug('junegunn/fzf', { ['do'] = function()
  108. vim.fn['fzf#install']()
  109. end })
  110. -- If the vim plugin is in a subdirectory, use 'rtp' option to specify its path
  111. Plug('nsf/gocode', { ['rtp'] = 'vim' })
  112. -- On-demand loading: loaded when the specified command is executed
  113. Plug('preservim/nerdtree', { ['on'] = 'NERDTreeToggle' })
  114. -- On-demand loading: loaded when a file with a specific file type is opened
  115. Plug('tpope/vim-fireplace', { ['for'] = 'clojure' })
  116. -- Unmanaged plugin (manually installed and updated)
  117. Plug('~/my-prototype-plugin')
  118. vim.call('plug#end')
  119. <
  120. More examples can be found in:
  121. - https://gitlab.com/sultanahamer/dotfiles/-/blob/master/nvim/lua/plugins.lua?ref_type=heads
  122. < Commands >__________________________________________________________________~
  123. *plug-commands*
  124. *:PlugInstall* *:PlugUpdate* *:PlugClean* *:PlugUpgrade* *:PlugStatus* *:PlugDiff*
  125. *:PlugSnapshot*
  126. -------------------------------------+------------------------------------------------------------------
  127. Command | Description ~
  128. -------------------------------------+------------------------------------------------------------------
  129. `PlugInstall [name ...] [#threads]` | Install plugins
  130. `PlugUpdate [name ...] [#threads]` | Install or update plugins
  131. `PlugClean[!]` | Remove unlisted plugins (bang version will clean without prompt)
  132. `PlugUpgrade` | Upgrade vim-plug itself
  133. `PlugStatus` | Check the status of plugins
  134. `PlugDiff` | Examine changes from the previous update and the pending changes
  135. `PlugSnapshot[!] [output path]` | Generate script for restoring the current snapshot of the plugins
  136. -------------------------------------+------------------------------------------------------------------
  137. < Plug options >______________________________________________________________~
  138. *plug-options*
  139. *<Plug>-mappings*
  140. ------------------------+-----------------------------------------------
  141. Option | Description ~
  142. ------------------------+-----------------------------------------------
  143. `branch` / `tag` / `commit` | Branch/tag/commit of the repository to use
  144. `rtp` | Subdirectory that contains Vim plugin
  145. `dir` | Custom directory for the plugin
  146. `as` | Use different name for the plugin
  147. `do` | Post-update hook (string or funcref)
  148. `on` | On-demand loading: Commands or <Plug>-mappings
  149. `for` | On-demand loading: File types
  150. `frozen` | Do not update unless explicitly specified
  151. ------------------------+-----------------------------------------------
  152. < Global options >____________________________________________________________~
  153. *plug-global-options*
  154. *g:plug_threads* *g:plug_timeout* *g:plug_retries* *g:plug_shallow* *g:plug_window*
  155. *g:plug_pwindow* *g:plug_url_format*
  156. --------------------+-----------------------------------+-----------------------------------------------------------------------------------
  157. Flag | Default | Description ~
  158. --------------------+-----------------------------------+-----------------------------------------------------------------------------------
  159. `g:plug_threads` | 16 | Default number of threads to use
  160. `g:plug_timeout` | 60 | Time limit of each task in seconds (Ruby & Python)
  161. `g:plug_retries` | 2 | Number of retries in case of timeout (Ruby & Python)
  162. `g:plug_shallow` | 1 | Use shallow clone
  163. `g:plug_window` | `-tabnew` | Command to open plug window
  164. `g:plug_pwindow` | `vertical rightbelow new` | Command to open preview window in `PlugDiff`
  165. `g:plug_url_format` | `https://git::@github.com/%s.git` | `printf` format to build repo URL (Only applies to the subsequent `Plug` commands)
  166. --------------------+-----------------------------------+-----------------------------------------------------------------------------------
  167. < Keybindings >_______________________________________________________________~
  168. *plug-keybindings*
  169. - `D` - `PlugDiff`
  170. - `S` - `PlugStatus`
  171. - `R` - Retry failed update or installation tasks
  172. - `U` - Update plugins in the selected range
  173. - `q` - Close the window
  174. - `:PlugStatus`
  175. - `L` - Load plugin
  176. - `:PlugDiff`
  177. - `X` - Revert the update
  178. < Example: A small sensible Vim configuration >_______________________________~
  179. *plug-example-a-small-sensible-vim-configuration*
  180. >
  181. call plug#begin()
  182. Plug 'tpope/vim-sensible'
  183. call plug#end()
  184. <
  185. < On-demand loading of plugins >______________________________________________~
  186. *plug-on-demand-loading-of-plugins*
  187. >
  188. " NERD tree will be loaded on the first invocation of NERDTreeToggle command
  189. Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
  190. " Multiple commands
  191. Plug 'junegunn/vim-github-dashboard', { 'on': ['GHDashboard', 'GHActivity'] }
  192. " Loaded when clojure file is opened
  193. Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
  194. " Multiple file types
  195. Plug 'kovisoft/paredit', { 'for': ['clojure', 'scheme'] }
  196. " On-demand loading on both conditions
  197. Plug 'junegunn/vader.vim', { 'on': 'Vader', 'for': 'vader' }
  198. " Code to execute when the plugin is lazily loaded on demand
  199. Plug 'junegunn/goyo.vim', { 'for': 'markdown' }
  200. autocmd! User goyo.vim echom 'Goyo is now loaded!'
  201. <
  202. The `for` option is generally not needed as most plugins for specific file
  203. types usually don't have too much code in the `plugin` directory. You might
  204. want to examine the output of `vim --startuptime` before applying the option.
  205. < Post-update hooks >_________________________________________________________~
  206. *plug-post-update-hooks*
  207. There are some plugins that require extra steps after installation or update.
  208. In that case, use the `do` option to describe the task to be performed.
  209. >
  210. Plug 'Shougo/vimproc.vim', { 'do': 'make' }
  211. Plug 'ycm-core/YouCompleteMe', { 'do': './install.py' }
  212. <
  213. If the value starts with `:`, it will be recognized as a Vim command.
  214. >
  215. Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
  216. <
  217. To call a Vim function, you can pass a lambda expression like so:
  218. >
  219. Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
  220. <
  221. If you need more control, you can pass a reference to a Vim function that
  222. takes a dictionary argument.
  223. >
  224. function! BuildYCM(info)
  225. " info is a dictionary with 3 fields
  226. " - name: name of the plugin
  227. " - status: 'installed', 'updated', or 'unchanged'
  228. " - force: set on PlugInstall! or PlugUpdate!
  229. if a:info.status == 'installed' || a:info.force
  230. !./install.py
  231. endif
  232. endfunction
  233. Plug 'ycm-core/YouCompleteMe', { 'do': function('BuildYCM') }
  234. <
  235. A post-update hook is executed inside the directory of the plugin and only run
  236. when the repository has changed, but you can force it to run unconditionally
  237. with the bang-versions of the commands: `PlugInstall!` and `PlugUpdate!`.
  238. Make sure to escape BARs and double-quotes when you write the `do` option
  239. inline as they are mistakenly recognized as command separator or the start of
  240. the trailing comment.
  241. >
  242. Plug 'junegunn/fzf', { 'do': 'yes \| ./install' }
  243. <
  244. But you can avoid the escaping if you extract the inline specification using a
  245. variable (or any Vimscript expression) as follows:
  246. *g:fzf_install*
  247. >
  248. let g:fzf_install = 'yes | ./install'
  249. Plug 'junegunn/fzf', { 'do': g:fzf_install }
  250. <
  251. < PlugInstall! and PlugUpdate! >______________________________________________~
  252. *pluginstall-and-plugupdate*
  253. The installer takes the following steps when installing/updating a plugin:
  254. 1. `git clone` or `git fetch` from its origin
  255. 2. Check out branch, tag, or commit and optionally `git merge` remote branch
  256. 3. If the plugin was updated (or installed for the first time)
  257. 1. Update submodules
  258. 2. Execute post-update hooks
  259. The commands with the `!` suffix ensure that all steps are run
  260. unconditionally.
  261. < License >___________________________________________________________________~
  262. *plug-license*
  263. MIT
  264. ==============================================================================
  265. vim:tw=78:sw=2:ts=2:ft=help:norl:nowrap: