mirror of
https://github.com/junegunn/vim-plug.git
synced 2024-12-19 18:47:29 -07:00
Updated faq (markdown)
parent
563bdc0e40
commit
9312e8ffaf
102
faq.md
102
faq.md
@ -14,57 +14,6 @@ endif
|
||||
|
||||
(If you're behind an HTTP proxy, you may need to add `--insecure` option to the curl command. In that case, you also need to set `$GIT_SSL_NO_VERIFY` to true.)
|
||||
|
||||
### Conditional activation
|
||||
|
||||
Use plain "if" statement to conditionally activate plugins:
|
||||
|
||||
```vim
|
||||
if has('mac')
|
||||
Plug 'junegunn/vim-xmark'
|
||||
endif
|
||||
```
|
||||
|
||||
The caveat is that when the condition is not met, `PlugClean` will try to remove the plugin. This can be problematic if you share the same configuration across terminal Vim, GVim, and Neovim.
|
||||
|
||||
```vim
|
||||
" When started with plain Vim, the plugin is not registered
|
||||
" and PlugClean will try to remove it
|
||||
if has('nvim')
|
||||
Plug 'benekastah/neomake'
|
||||
endif
|
||||
```
|
||||
|
||||
Alternatively, you can pass an empty `on` or `for` option so that the plugin is registered but not loaded by default depending on the condition.
|
||||
|
||||
```vim
|
||||
Plug 'benekastah/neomake', has('nvim') ? {} : { 'on': [] }
|
||||
```
|
||||
|
||||
A helper function can improve the readability.
|
||||
|
||||
```vim
|
||||
function! Cond(cond, ...)
|
||||
let opts = get(a:000, 0, {})
|
||||
return a:cond ? opts : extend(opts, { 'on': [] })
|
||||
endfunction
|
||||
|
||||
" Looks better
|
||||
Plug 'benekastah/neomake', Cond(has('nvim'))
|
||||
|
||||
" With other options
|
||||
Plug 'benekastah/neomake', Cond(has('nvim'), { 'on': 'Neomake' })
|
||||
```
|
||||
|
||||
### Gist as plugin
|
||||
|
||||
vim-plug does not natively support installing small Vim plugins from Gist.
|
||||
But there is a workaround if you really want it.
|
||||
|
||||
```vim
|
||||
Plug 'https://gist.github.com/952560a43601cd9898f1.git',
|
||||
\ { 'as': 'xxx', 'do': 'mkdir -p plugin; cp -f *.vim plugin/' }
|
||||
```
|
||||
|
||||
### Migrating from other plugin managers
|
||||
|
||||
Download plug.vim in `autoload` directory
|
||||
@ -127,6 +76,57 @@ call plug#begin('~/.vim/bundle')
|
||||
call plug#begin('~/vimfiles/bundle')
|
||||
```
|
||||
|
||||
### Conditional activation
|
||||
|
||||
Use plain "if" statement to conditionally activate plugins:
|
||||
|
||||
```vim
|
||||
if has('mac')
|
||||
Plug 'junegunn/vim-xmark'
|
||||
endif
|
||||
```
|
||||
|
||||
The caveat is that when the condition is not met, `PlugClean` will try to remove the plugin. This can be problematic if you share the same configuration across terminal Vim, GVim, and Neovim.
|
||||
|
||||
```vim
|
||||
" When started with plain Vim, the plugin is not registered
|
||||
" and PlugClean will try to remove it
|
||||
if has('nvim')
|
||||
Plug 'benekastah/neomake'
|
||||
endif
|
||||
```
|
||||
|
||||
Alternatively, you can pass an empty `on` or `for` option so that the plugin is registered but not loaded by default depending on the condition.
|
||||
|
||||
```vim
|
||||
Plug 'benekastah/neomake', has('nvim') ? {} : { 'on': [] }
|
||||
```
|
||||
|
||||
A helper function can improve the readability.
|
||||
|
||||
```vim
|
||||
function! Cond(cond, ...)
|
||||
let opts = get(a:000, 0, {})
|
||||
return a:cond ? opts : extend(opts, { 'on': [] })
|
||||
endfunction
|
||||
|
||||
" Looks better
|
||||
Plug 'benekastah/neomake', Cond(has('nvim'))
|
||||
|
||||
" With other options
|
||||
Plug 'benekastah/neomake', Cond(has('nvim'), { 'on': 'Neomake' })
|
||||
```
|
||||
|
||||
### Gist as plugin
|
||||
|
||||
vim-plug does not natively support installing small Vim plugins from Gist.
|
||||
But there is a workaround if you really want it.
|
||||
|
||||
```vim
|
||||
Plug 'https://gist.github.com/952560a43601cd9898f1.git',
|
||||
\ { 'as': 'xxx', 'do': 'mkdir -p plugin; cp -f *.vim plugin/' }
|
||||
```
|
||||
|
||||
### Loading plugins manually
|
||||
|
||||
With `on` and `for` options, vim-plug allows you to defer loading of plugins. But if you want a plugin to be loaded on an event that is not supported by vim-plug, you can set `on` or `for` option to an empty list, and use `plug#load(names...)` function later to load the plugin manually. The following example will load [ultisnips](https://github.com/SirVer/ultisnips) and [YouCompleteMe](https://github.com/Valloric/YouCompleteMe) first time you enter insert mode.
|
||||
|
Loading…
Reference in New Issue
Block a user