.vim/autoload/plug.vim

changeset 781
eddff1b70d20
parent 773
36a9b54b0eea
child 795
b6105413b6b7
equal deleted inserted replaced
780:21fa6f49ea55 781:eddff1b70d20
792 silent! execute 'f' fnameescape(name) 792 silent! execute 'f' fnameescape(name)
793 endfunction 793 endfunction
794 794
795 function! s:chsh(swap) 795 function! s:chsh(swap)
796 let prev = [&shell, &shellcmdflag, &shellredir] 796 let prev = [&shell, &shellcmdflag, &shellredir]
797 if s:is_win 797 if !s:is_win && a:swap
798 set shell=cmd.exe shellcmdflag=/c shellredir=>%s\ 2>&1
799 elseif a:swap
800 set shell=sh shellredir=>%s\ 2>&1 798 set shell=sh shellredir=>%s\ 2>&1
801 endif 799 endif
802 return prev 800 return prev
803 endfunction 801 endfunction
804 802
809 " but it won't work on Windows. 807 " but it won't work on Windows.
810 let cmd = a:0 ? s:with_cd(a:cmd, a:1) : a:cmd 808 let cmd = a:0 ? s:with_cd(a:cmd, a:1) : a:cmd
811 if s:is_win 809 if s:is_win
812 let batchfile = tempname().'.bat' 810 let batchfile = tempname().'.bat'
813 call writefile(["@echo off\r", cmd . "\r"], batchfile) 811 call writefile(["@echo off\r", cmd . "\r"], batchfile)
814 let cmd = s:shellesc(batchfile) 812 let cmd = s:shellesc(expand(batchfile))
815 endif 813 endif
816 let g:_plug_bang = (s:is_win && has('gui_running') ? 'silent ' : '').'!'.escape(cmd, '#!%') 814 let g:_plug_bang = (s:is_win && has('gui_running') ? 'silent ' : '').'!'.escape(cmd, '#!%')
817 execute "normal! :execute g:_plug_bang\<cr>\<cr>" 815 execute "normal! :execute g:_plug_bang\<cr>\<cr>"
818 finally 816 finally
819 unlet g:_plug_bang 817 unlet g:_plug_bang
1208 \ 'new': get(a:opts, 'new', 0) } 1206 \ 'new': get(a:opts, 'new', 0) }
1209 let s:jobs[a:name] = job 1207 let s:jobs[a:name] = job
1210 let cmd = has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd 1208 let cmd = has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd
1211 if !empty(job.batchfile) 1209 if !empty(job.batchfile)
1212 call writefile(["@echo off\r", cmd . "\r"], job.batchfile) 1210 call writefile(["@echo off\r", cmd . "\r"], job.batchfile)
1213 let cmd = s:shellesc(job.batchfile) 1211 let cmd = s:shellesc(expand(job.batchfile))
1214 endif 1212 endif
1215 let argv = add(s:is_win ? ['cmd', '/c'] : ['sh', '-c'], cmd) 1213 let argv = add(s:is_win ? ['cmd', '/c'] : ['sh', '-c'], cmd)
1216 1214
1217 if s:nvim 1215 if s:nvim
1218 call extend(job, { 1216 call extend(job, {
2035 let [sh, shellcmdflag, shrd] = s:chsh(1) 2033 let [sh, shellcmdflag, shrd] = s:chsh(1)
2036 let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd 2034 let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd
2037 if s:is_win 2035 if s:is_win
2038 let batchfile = tempname().'.bat' 2036 let batchfile = tempname().'.bat'
2039 call writefile(["@echo off\r", cmd . "\r"], batchfile) 2037 call writefile(["@echo off\r", cmd . "\r"], batchfile)
2040 let cmd = s:shellesc(batchfile) 2038 let cmd = s:shellesc(expand(batchfile))
2041 endif 2039 endif
2042 return system(cmd) 2040 return system(cmd)
2043 finally 2041 finally
2044 let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] 2042 let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd]
2045 if s:is_win 2043 if s:is_win
2369 let [sh, shellcmdflag, shrd] = s:chsh(1) 2367 let [sh, shellcmdflag, shrd] = s:chsh(1)
2370 let cmd = 'cd '.s:shellesc(g:plugs[name].dir).' && git show --no-color --pretty=medium '.sha 2368 let cmd = 'cd '.s:shellesc(g:plugs[name].dir).' && git show --no-color --pretty=medium '.sha
2371 if s:is_win 2369 if s:is_win
2372 let batchfile = tempname().'.bat' 2370 let batchfile = tempname().'.bat'
2373 call writefile(["@echo off\r", cmd . "\r"], batchfile) 2371 call writefile(["@echo off\r", cmd . "\r"], batchfile)
2374 let cmd = batchfile 2372 let cmd = expand(batchfile)
2375 endif 2373 endif
2376 execute 'silent %!' cmd 2374 execute 'silent %!' cmd
2377 finally 2375 finally
2378 let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] 2376 let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd]
2379 if s:is_win 2377 if s:is_win

mercurial