Ver Fonte

Workaround for PlugUpgrade error on Neovim (#111)

Junegunn Choi há 11 anos atrás
pai
commit
4b3fbd1592
1 ficheiros alterados com 10 adições e 6 exclusões
  1. 10 6
      plug.vim

+ 10 - 6
plug.vim

@@ -1268,12 +1268,7 @@ function! s:upgrade()
         throw get(s:lines(output), -1, v:shell_error)
       endif
     elseif has('ruby')
-      ruby << EOF
-      require 'open-uri'
-      File.open(VIM::evaluate('new'), 'w') do |f|
-        f << open(VIM::evaluate('s:plug_src')).read
-      end
-EOF
+      call s:upgrade_using_ruby(new)
     else
       return s:err('curl executable or ruby support not found')
     endif
@@ -1294,6 +1289,15 @@ EOF
   endif
 endfunction
 
+function! s:upgrade_using_ruby(new)
+  ruby << EOF
+  require 'open-uri'
+  File.open(VIM::evaluate('a:new'), 'w') do |f|
+    f << open(VIM::evaluate('s:plug_src')).read
+  end
+EOF
+endfunction
+
 function! s:upgrade_specs()
   for spec in values(g:plugs)
     let spec.frozen = get(spec, 'frozen', 0)