From d499fc311abee24428dfb8f2f2bf26eba0ee1d63 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Tue, 29 Jul 2014 01:45:05 +0900 Subject: [PATCH] Use dot operator instead of get() The reason I used get() instead of concise dot operator when accessing `frozen` and `local` properties of plugin spec was to avoid errors when a user "PlugUpgrade" from an old version of vim-plug whose g:plugs does not have those properties. Added the code to patch the old version of g:plugs so that we can safely use dot operators. --- plug.vim | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/plug.vim b/plug.vim index 6c839ab..cd4b4a1 100644 --- a/plug.vim +++ b/plug.vim @@ -109,7 +109,7 @@ function! plug#begin(...) command! -nargs=* -complete=customlist,s:names PlugInstall call s:install() command! -nargs=* -complete=customlist,s:names PlugUpdate call s:update() command! -nargs=0 -bang PlugClean call s:clean('' == '!') - command! -nargs=0 PlugUpgrade if s:upgrade() | execute "source ". s:me | endif + command! -nargs=0 PlugUpgrade if s:upgrade() | call s:upgrade_specs() | execute "source ". s:me | endif command! -nargs=0 PlugStatus call s:status() command! -nargs=0 PlugDiff call s:diff() @@ -552,7 +552,7 @@ function! s:update_impl(pull, args) abort \ remove(args, -1) : get(g:, 'plug_threads', 16) let managed = filter(copy(g:plugs), 's:is_managed(v:key)') - let todo = empty(args) ? filter(managed, '!get(v:val, "frozen", 0)') : + let todo = empty(args) ? filter(managed, '!v:val.frozen') : \ filter(managed, 'index(args, v:key) >= 0') if empty(todo) @@ -625,7 +625,7 @@ function! s:extend(names, ...) command! -nargs=+ Plug call s:add(0, ) for name in a:names let spec = g:plugs[name] - if get(spec, 'local', 0) + if spec.local let plugfile = globpath(s:rtp(spec), s:plug_file) if filereadable(plugfile) execute 'source '. s:esc(plugfile) @@ -1087,6 +1087,13 @@ EOF endif endfunction +function! s:upgrade_specs() + for spec in values(g:plugs) + let spec.frozen = get(spec, 'frozen', 0) + let spec.local = get(spec, 'local', 0) + endfor +endfunction + function! s:status() call s:prepare() call append(0, 'Checking plugins')