Export Plug command as plug# function

https://github.com/junegunn/vim-plug/issues/477#issuecomment-212746298

One can directly use it to redefine Plug command:

    function! s:plug_with_default(...)
      call plug#(a:1, extend(get(g:, 'plug_opts', {}), get(a:000, 1, {})))
    endfunction
    command! -nargs=+ Plug call s:plug_with_default(<args>)
This commit is contained in:
Junegunn Choi 2016-04-22 02:26:11 +09:00
parent 0507fc897e
commit 41de3c713c
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -131,7 +131,7 @@ function! plug#begin(...)
endfunction endfunction
function! s:define_commands() function! s:define_commands()
command! -nargs=+ -bar Plug call s:Plug(<args>) command! -nargs=+ -bar Plug call plug#(<args>)
if !executable('git') if !executable('git')
return s:err('`git` executable not found. Most commands will not be available. To suppress this message, prepend `silent!` to `call plug#begin(...)`.') return s:err('`git` executable not found. Most commands will not be available. To suppress this message, prepend `silent!` to `call plug#begin(...)`.')
endif endif
@ -489,7 +489,7 @@ function! s:lod_map(map, names, prefix)
call feedkeys(a:prefix . substitute(a:map, '^<Plug>', "\<Plug>", '') . extra) call feedkeys(a:prefix . substitute(a:map, '^<Plug>', "\<Plug>", '') . extra)
endfunction endfunction
function! s:Plug(repo, ...) function! plug#(repo, ...)
if a:0 > 1 if a:0 > 1
return s:err('Invalid number of arguments (1..2)') return s:err('Invalid number of arguments (1..2)')
endif endif