support do vim command

This commit is contained in:
吕海涛 2016-03-21 18:14:57 +08:00
parent a4e2c064f0
commit f2fb27c109
2 changed files with 16 additions and 4 deletions

View File

@ -198,6 +198,13 @@ Plug 'Shougo/vimproc.vim', { 'do': 'make' }
Plug 'Valloric/YouCompleteMe', { 'do': './install.py' } Plug 'Valloric/YouCompleteMe', { 'do': './install.py' }
``` ```
If you need to execute Vim's command, you can pass the command name with a
leading `:`.
```
Plug 'Shougo/deoplete.nvim', {'do':':UpdateRemotePlugins'}
```
If you need more control, you can pass a reference to a Vim function that If you need more control, you can pass a reference to a Vim function that
takes a single argument. takes a single argument.

View File

@ -723,10 +723,15 @@ function! s:do(pull, force, todo)
let type = type(spec.do) let type = type(spec.do)
if type == s:TYPE.string if type == s:TYPE.string
try try
" FIXME: Escaping is incomplete. We could use shellescape with eval, if spec.do =~? '^:'
" but it won't work on Windows. let g:_plug_do = spec.do[1:]
let g:_plug_do = '!'.escape(spec.do, '#!%') execute g:_plug_do
execute "normal! :execute g:_plug_do\<cr>\<cr>" else
" FIXME: Escaping is incomplete. We could use shellescape with eval,
" but it won't work on Windows.
let g:_plug_do = '!'.escape(spec.do, '#!%')
execute "normal! :execute g:_plug_do\<cr>\<cr>"
endif
finally finally
if v:shell_error if v:shell_error
let error = 'Exit status: ' . v:shell_error let error = 'Exit status: ' . v:shell_error