plug.txt 15 KB

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