From f2fb27c1097fa1960e4ab90c4defaf6d004bc2f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=95=E6=B5=B7=E6=B6=9B?= Date: Mon, 21 Mar 2016 18:14:57 +0800 Subject: [PATCH] support do vim command --- README.md | 7 +++++++ plug.vim | 13 +++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7154a34..1cb72bb 100644 --- a/README.md +++ b/README.md @@ -198,6 +198,13 @@ Plug 'Shougo/vimproc.vim', { 'do': 'make' } 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 takes a single argument. diff --git a/plug.vim b/plug.vim index 9cb02f7..beb51d2 100644 --- a/plug.vim +++ b/plug.vim @@ -723,10 +723,15 @@ function! s:do(pull, force, todo) let type = type(spec.do) if type == s:TYPE.string try - " 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\\" + if spec.do =~? '^:' + let g:_plug_do = spec.do[1:] + execute g:_plug_do + 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\\" + endif finally if v:shell_error let error = 'Exit status: ' . v:shell_error