diff options
-rw-r--r-- | runtime/autoload/tar.vim | 36 | ||||
-rw-r--r-- | runtime/plugin/gzip.vim | 8 | ||||
-rw-r--r-- | runtime/plugin/tarPlugin.vim | 1 |
3 files changed, 41 insertions, 4 deletions
diff --git a/runtime/autoload/tar.vim b/runtime/autoload/tar.vim index b998a33adc..40be27341d 100644 --- a/runtime/autoload/tar.vim +++ b/runtime/autoload/tar.vim @@ -1,9 +1,15 @@ " tar.vim: Handles browsing tarfiles - AUTOLOAD PORTION -" Date: Feb 06, 2025 +" Date: Feb 28, 2025 " Version: 32b (with modifications from the Vim Project) " Maintainer: This runtime file is looking for a new maintainer. " Former Maintainer: Charles E Campbell " License: Vim License (see vim's :help license) +" Last Change: +" 2024 Jan 08 by Vim Project: fix a few problems (#138331, #12637, #8109) +" 2024 Feb 19 by Vim Project: announce adoption +" 2024 Nov 11 by Vim Project: support permissions (#7379) +" 2025 Feb 06 by Vim Project: add support for lz4 (#16591) +" 2025 Feb 28 by Vim Project: add support for bzip3 (#16755) " " Contains many ideas from Michael Toren's <tar.vim> " @@ -161,6 +167,8 @@ fun! tar#Browse(tarfile) if filekind =~ "bzip2" exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - " + elseif filekind =~ "bzip3" + exe "sil! r! bzip3 -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" @@ -175,6 +183,8 @@ fun! tar#Browse(tarfile) exe "sil! r! cat -- ".shellescape(tarfile,1)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - " elseif tarfile =~# '\.\(bz2\|tbz\|tb2\)$' exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - " + elseif tarfile =~# '\.\(bz3\|tb3\)$' + exe "sil! r! bzip3 -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - " elseif tarfile =~# '\.\(lzma\|tlz\)$' exe "sil! r! lzma -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - " elseif tarfile =~# '\.\(xz\|txz\)$' @@ -316,6 +326,9 @@ fun! tar#Read(fname,mode) if fname =~ '\.bz2$' && executable("bzcat") let decmp= "|bzcat" let doro = 1 + elseif fname =~ '\.bz3$' && executable("bz3cat") + let decmp= "|bz3cat" + let doro = 1 elseif fname =~ '\.t\=gz$' && executable("zcat") let decmp= "|zcat" let doro = 1 @@ -334,7 +347,7 @@ fun! tar#Read(fname,mode) else let decmp="" let doro = 0 - if fname =~ '\.bz2$\|\.gz$\|\.lzma$\|\.xz$\|\.zip$\|\.Z$' + if fname =~ '\.bz2$\|\.bz3$\|\.gz$\|\.lzma$\|\.xz$\|\.zip$\|\.Z$' setlocal bin endif endif @@ -348,6 +361,9 @@ fun! tar#Read(fname,mode) if tarfile =~# '\.bz2$' exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp exe "read ".fname + if tarfile =~# '\.bz3$' + exe "sil! r! bzip3 -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp + exe "read ".fname elseif tarfile =~# '\.\(gz\)$' exe "sil! r! gzip -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp exe "read ".fname @@ -360,6 +376,9 @@ fun! tar#Read(fname,mode) if filekind =~ "bzip2" exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp exe "read ".fname + elseif filekind =~ "bzip3" + exe "sil! r! bzip3 -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp + exe "read ".fname elseif filekind =~ "XZ" exe "sil! r! xz -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp exe "read ".fname @@ -446,6 +465,10 @@ fun! tar#Write(fname) call system("bzip2 -d -- ".shellescape(tarfile,0)) let tarfile = substitute(tarfile,'\.bz2','','e') let compress= "bzip2 -- ".shellescape(tarfile,0) + elseif tarfile =~# '\.bz3' + call system("bzip3 -d -- ".shellescape(tarfile,0)) + let tarfile = substitute(tarfile,'\.bz3','','e') + let compress= "bzip3 -- ".shellescape(tarfile,0) elseif tarfile =~# '\.gz' call system("gzip -d -- ".shellescape(tarfile,0)) let tarfile = substitute(tarfile,'\.gz','','e') @@ -638,6 +661,15 @@ fun! tar#Extract() echo "***note*** successfully extracted ".fname endif + elseif filereadable(tarbase.".tar.bz3") + let extractcmd= substitute(extractcmd,"-","-j","") + call system(extractcmd." ".shellescape(tarbase).".tar.bz3 ".shellescape(fname)) + if v:shell_error != 0 + echohl Error | echo "***error*** ".extractcmd."j ".tarbase.".tar.bz3 ".fname.": failed!" | echohl NONE + else + echo "***note*** successfully extracted ".fname + endif + elseif filereadable(tarbase.".txz") let extractcmd= substitute(extractcmd,"-","-J","") call system(extractcmd." ".shellescape(tarbase).".txz ".shellescape(fname)) diff --git a/runtime/plugin/gzip.vim b/runtime/plugin/gzip.vim index b431b5ba80..9138844e6c 100644 --- a/runtime/plugin/gzip.vim +++ b/runtime/plugin/gzip.vim @@ -1,6 +1,6 @@ " Vim plugin for editing compressed files. " Maintainer: The Vim Project <https://github.com/vim/vim> -" Last Change: 2025 Feb 06 +" Last Change: 2025 Feb 28 " Former Maintainer: Bram Moolenaar <Bram@vim.org> " Exit quickly when: @@ -20,11 +20,12 @@ augroup gzip " The functions are defined in autoload/gzip.vim. " " Set binary mode before reading the file. - autocmd BufReadPre,FileReadPre *.gz,*.bz2,*.Z,*.lzma,*.xz,*.lz,*.zst,*.br,*.lzo,*.lz4 setlocal bin + autocmd BufReadPre,FileReadPre *.gz,*.bz2,*.bz3,*.Z,*.lzma,*.xz,*.lz,*.zst,*.br,*.lzo,*.lz4 setlocal bin " Use "gzip -d" and similar commands, gunzip isn't always available. autocmd BufReadPost,FileReadPost *.br call gzip#read("brotli -d --rm") autocmd BufReadPost,FileReadPost *.bz2 call gzip#read("bzip2 -d") + autocmd BufReadPost,FileReadPost *.bz3 call gzip#read("bzip3 -d") autocmd BufReadPost,FileReadPost *.gz call gzip#read("gzip -dn") autocmd BufReadPost,FileReadPost *.lz call gzip#read("lzip -d") autocmd BufReadPost,FileReadPost *.lz4 call gzip#read("lz4 -d -q --rm") @@ -36,6 +37,7 @@ augroup gzip autocmd BufWritePost,FileWritePost *.br call gzip#write("brotli --rm") autocmd BufWritePost,FileWritePost *.bz2 call gzip#write("bzip2") + autocmd BufWritePost,FileWritePost *.bz3 call gzip#write("bzip3") autocmd BufWritePost,FileWritePost *.gz call gzip#write("gzip") autocmd BufWritePost,FileWritePost *.lz call gzip#write("lzip") autocmd BufWritePost,FileWritePost *.lz4 call gzip#write("lz4 -q --rm") @@ -47,6 +49,7 @@ augroup gzip autocmd FileAppendPre *.br call gzip#appre("brotli -d --rm") autocmd FileAppendPre *.bz2 call gzip#appre("bzip2 -d") + autocmd FileAppendPre *.bz3 call gzip#appre("bzip3 -d") autocmd FileAppendPre *.gz call gzip#appre("gzip -dn") autocmd FileAppendPre *.lz call gzip#appre("lzip -d") autocmd FileAppendPre *.lz4 call gzip#appre("lz4 -d -q --rm") @@ -58,6 +61,7 @@ augroup gzip autocmd FileAppendPost *.br call gzip#write("brotli --rm") autocmd FileAppendPost *.bz2 call gzip#write("bzip2") + autocmd FileAppendPost *.bz3 call gzip#write("bzip3") autocmd FileAppendPost *.gz call gzip#write("gzip") autocmd FileAppendPost *.lz call gzip#write("lzip") autocmd FileAppendPost *.lz4 call gzip#write("lz4 --rm") diff --git a/runtime/plugin/tarPlugin.vim b/runtime/plugin/tarPlugin.vim index 64266fd3f2..a337c91214 100644 --- a/runtime/plugin/tarPlugin.vim +++ b/runtime/plugin/tarPlugin.vim @@ -38,6 +38,7 @@ augroup tar au BufReadCmd *.lrp call tar#Browse(expand("<amatch>")) au BufReadCmd *.tar call tar#Browse(expand("<amatch>")) au BufReadCmd *.tar.bz2 call tar#Browse(expand("<amatch>")) + au BufReadCmd *.tar.bz3 call tar#Browse(expand("<amatch>")) au BufReadCmd *.tar.gz call tar#Browse(expand("<amatch>")) au BufReadCmd *.tar.lz4 call tar#Browse(expand("<amatch>")) au BufReadCmd *.tar.lzma call tar#Browse(expand("<amatch>")) |