aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-02-17 23:59:17 -0500
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-02-17 23:59:17 -0500
commitb46a92f519591f1316b3e8b7d8a9cdeceab52029 (patch)
treee5cfc652a95f5e5d308b11b2732ba15afdbb1996
parentd3c6f7449838ef30b8d3b71fa418cec207e3de71 (diff)
downloadrneovim-b46a92f519591f1316b3e8b7d8a9cdeceab52029.tar.gz
rneovim-b46a92f519591f1316b3e8b7d8a9cdeceab52029.tar.bz2
rneovim-b46a92f519591f1316b3e8b7d8a9cdeceab52029.zip
runtime/tar: 23515b4ef7580af8b9d3b964a558ab2007cacda5
Port tar files only in order to support '*.tar.zst' files. Close https://github.com/neovim/neovim/pull/13337
-rw-r--r--runtime/autoload/tar.vim37
-rw-r--r--runtime/plugin/tarPlugin.vim2
2 files changed, 38 insertions, 1 deletions
diff --git a/runtime/autoload/tar.vim b/runtime/autoload/tar.vim
index 9f9609434f..b6c4c660b8 100644
--- a/runtime/autoload/tar.vim
+++ b/runtime/autoload/tar.vim
@@ -163,7 +163,7 @@ fun! tar#Browse(tarfile)
" call Decho("1: exe silent r! gzip -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ")
exe "sil! r! gzip -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
- elseif tarfile =~# '\.\(tgz\)$' || tarfile =~# '\.\(tbz\)$' || tarfile =~# '\.\(txz\)$'
+ elseif tarfile =~# '\.\(tgz\)$' || tarfile =~# '\.\(tbz\)$' || tarfile =~# '\.\(txz\)$' || tarfile =~# '\.\(tzs\)$'
if has("unix") && executable("file")
let filekind= system("file ".shellescape(tarfile,1)) =~ "bzip2"
else
@@ -174,6 +174,8 @@ fun! tar#Browse(tarfile)
exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
elseif filekind =~ "XZ"
exe "sil! r! xz -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
+ elseif filekind =~ "Zstandard"
+ exe "sil! r! zstd --decompress --stdout -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
else
exe "sil! r! gzip -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
endif
@@ -190,6 +192,8 @@ fun! tar#Browse(tarfile)
elseif tarfile =~# '\.\(xz\|txz\)$'
" call Decho("3: exe silent r! xz --decompress --stdout -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ")
exe "sil! r! xz --decompress --stdout -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
+ elseif tarfile =~# '\.\(zst\|tzs\)$'
+ exe "sil! r! zstd --decompress --stdout -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
else
if tarfile =~ '^\s*-'
" A file name starting with a dash is taken as an option. Prepend ./ to avoid that.
@@ -302,6 +306,9 @@ fun! tar#Read(fname,mode)
elseif fname =~ '\.xz$' && executable("xzcat")
let decmp= "|xzcat"
let doro = 1
+ elseif fname =~ '\.zst$' && executable("zstdcat")
+ let decmp= "|zstdcat"
+ let doro = 1
else
let decmp=""
let doro = 0
@@ -331,6 +338,8 @@ fun! tar#Read(fname,mode)
exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
elseif filekind =~ "XZ"
exe "sil! r! xz -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
+ elseif filekind =~ "Zstandard"
+ exe "sil! r! zstd --decompress --stdout -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
else
exe "sil! r! gzip -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
endif
@@ -452,6 +461,10 @@ fun! tar#Write(fname)
let tarfile = substitute(tarfile,'\.xz','','e')
let compress= "xz -- ".shellescape(tarfile,0)
" call Decho("compress<".compress.">")
+ elseif tarfile =~# '\.zst'
+ call system("zstd --decompress -- ".shellescape(tarfile,0))
+ let tarfile = substitute(tarfile,'\.zst','','e')
+ let compress= "zstd -- ".shellescape(tarfile,0)
elseif tarfile =~# '\.lzma'
call system("lzma -d -- ".shellescape(tarfile,0))
let tarfile = substitute(tarfile,'\.lzma','','e')
@@ -676,6 +689,28 @@ fun! tar#Extract()
else
echo "***note*** successfully extracted ".fname
endif
+
+ elseif filereadable(tarbase.".tzs")
+ let extractcmd= substitute(extractcmd,"-","--zstd","")
+" call Decho("system(".extractcmd." ".shellescape(tarbase).".tzs ".shellescape(fname).")")
+ call system(extractcmd." ".shellescape(tarbase).".txz ".shellescape(fname))
+ if v:shell_error != 0
+ echohl Error | echo "***error*** ".extractcmd." ".tarbase.".tzs ".fname.": failed!" | echohl NONE
+" call Decho("***error*** ".extractcmd." ".tarbase.".tzs ".fname.": failed!")
+ else
+ echo "***note*** successfully extracted ".fname
+ endif
+
+ elseif filereadable(tarbase.".tar.zst")
+ let extractcmd= substitute(extractcmd,"-","--zstd","")
+" call Decho("system(".extractcmd." ".shellescape(tarbase).".tar.zst ".shellescape(fname).")")
+ call system(extractcmd." ".shellescape(tarbase).".tar.xz ".shellescape(fname))
+ if v:shell_error != 0
+ echohl Error | echo "***error*** ".extractcmd." ".tarbase.".tar.zst ".fname.": failed!" | echohl NONE
+" call Decho("***error*** ".extractcmd." ".tarbase.".tar.zst ".fname.": failed!")
+ else
+ echo "***note*** successfully extracted ".fname
+ endif
endif
" restore option
diff --git a/runtime/plugin/tarPlugin.vim b/runtime/plugin/tarPlugin.vim
index 1fdd72c130..d55492a93e 100644
--- a/runtime/plugin/tarPlugin.vim
+++ b/runtime/plugin/tarPlugin.vim
@@ -44,6 +44,8 @@ augroup tar
au BufReadCmd *.tar.lzma call tar#Browse(expand("<amatch>"))
au BufReadCmd *.tar.xz call tar#Browse(expand("<amatch>"))
au BufReadCmd *.txz call tar#Browse(expand("<amatch>"))
+ au BufReadCmd *.tar.zst call tar#Browse(expand("<amatch>"))
+ au BufReadCmd *.tzs call tar#Browse(expand("<amatch>"))
augroup END
com! -nargs=? -complete=file Vimuntar call tar#Vimuntar(<q-args>)