diff --git a/plug.vim b/plug.vim index 25be27f..0603ebe 100644 --- a/plug.vim +++ b/plug.vim @@ -632,17 +632,34 @@ function! plug#(repo, ...) let g:plugs[name] = spec let s:loaded[name] = get(s:loaded, name, 0) catch - return s:err(v:exception) + return s:err(repo . ' ' . v:exception) endtry endfunction function! s:parse_options(arg) let opts = copy(s:base_spec) let type = type(a:arg) + let opt_errfmt = 'Invalid argument for "%s" option of :Plug (expected: %s)' if type == s:TYPE.string + if empty(a:arg) + throw printf(opt_errfmt, 'tag', 'string') + endif let opts.tag = a:arg elseif type == s:TYPE.dict call extend(opts, a:arg) + for opt in ['branch', 'tag', 'commit', 'rtp', 'dir', 'as'] + if has_key(opts, opt) + \ && (type(opts[opt]) != s:TYPE.string || empty(opts[opt])) + throw printf(opt_errfmt, opt, 'string') + endif + endfor + for opt in ['on', 'for'] + if has_key(opts, opt) + \ && type(opts[opt]) != s:TYPE.list + \ && (type(opts[opt]) != s:TYPE.string || empty(opts[opt])) + throw printf(opt_errfmt, opt, 'string or list') + endif + endfor if has_key(opts, 'dir') let opts.dir = s:dirpath(s:plug_expand(opts.dir)) endif diff --git a/test/workflow.vader b/test/workflow.vader index 7d70946..58e59b7 100644 --- a/test/workflow.vader +++ b/test/workflow.vader @@ -49,11 +49,19 @@ Execute (Test Plug command): AssertEqual 'no-t_co', g:plugs['seoul256.vim'].branch ^ Git repo with tag (DEPRECATED. USE TAG OPTION) + redir => out + Plug 'foo/bar.vim', '' + redir END + Assert out =~ 'Invalid argument for "tag" option of :Plug (expected: string)' Plug 'junegunn/goyo.vim', '1.5.2' AssertEqual 'file:///tmp/vim-plug-test/junegunn/goyo.vim', g:plugs['goyo.vim'].uri AssertEqual join([g:temp_plugged, 'goyo.vim/'], '/'), g:plugs['goyo.vim'].dir AssertEqual '1.5.2', g:plugs['goyo.vim'].tag + redir => out + Plug 'foo/bar.vim', {'tag': ''} + redir END + Assert out =~ 'Invalid argument for "tag" option of :Plug (expected: string)' Plug 'junegunn/goyo.vim', { 'tag': '1.5.3' } " Using tag option AssertEqual '1.5.3', g:plugs['goyo.vim'].tag @@ -77,6 +85,18 @@ Execute (Test Plug command): Execute (Plug command with dictionary option): Log string(g:plugs) + for opt in ['branch', 'tag', 'commit', 'rtp', 'dir', 'as'] + redir => out + Plug 'foo/bar.vim', {opt: ''} + redir END + Assert out =~ 'Invalid argument for "'.opt.'" option of :Plug (expected: string)' + endfor + for opt in ['on', 'for'] + redir => out + Plug 'foo/bar.vim', {opt: ''} + redir END + Assert out =~ 'Invalid argument for "'.opt.'" option of :Plug (expected: string or list)' + endfor Plug 'junegunn/seoul256.vim', { 'branch': 'no-t_co', 'rtp': '././' } AssertEqual join([g:temp_plugged, 'seoul256.vim/'], '/'), g:plugs['seoul256.vim'].dir AssertEqual '././', g:plugs['seoul256.vim'].rtp