From 3d39ea3ea9b6e66640e59731d155d731218e7e62 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 26 May 2024 07:11:50 +0800 Subject: vim-patch:9.1.0442: hare runtime files outdated (#29011) Problem: hare runtime files outdated Solution: runtime(hare): update hare.vim to match upstream (Amelia Clarke) closes: vim/vim#14836 https://github.com/vim/vim/commit/35dfe58a540e2fb0eff953630f8e4fcbf4bc26ca Co-authored-by: Amelia Clarke --- runtime/autoload/hare.vim | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 runtime/autoload/hare.vim (limited to 'runtime/autoload') diff --git a/runtime/autoload/hare.vim b/runtime/autoload/hare.vim new file mode 100644 index 0000000000..c4581fccf9 --- /dev/null +++ b/runtime/autoload/hare.vim @@ -0,0 +1,26 @@ +" Vim autoload file. +" Language: Hare +" Maintainer: Amelia Clarke +" Last Updated: 2024-05-10 +" Upstream: https://git.sr.ht/~sircmpwn/hare.vim + +" Attempt to find the directory for a given Hare module. +function hare#FindModule(str) + let path = substitute(trim(a:str, ':', 2), '::', '/', 'g') + let dir = finddir(path) + while !empty(path) && empty(dir) + let path = substitute(path, '/\?\h\w*$', '', '') + let dir = finddir(path) + endwhile + return dir +endfunction + +" Return the value of HAREPATH if it exists. Otherwise use a reasonable default. +function hare#GetPath() + if empty($HAREPATH) + return '/usr/src/hare/stdlib,/usr/src/hare/third-party' + endif + return substitute($HAREPATH, ':', ',', 'g') +endfunction + +" vim: et sts=2 sw=2 ts=8 -- cgit From 946a839aa9621e11f53e7044e594132d0497b99f Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Tue, 4 Jun 2024 19:09:23 +0200 Subject: vim-patch:98b73eb: runtime(netrw): prevent accidental data loss fixes: vim/vim#14915 https://github.com/vim/vim/commit/98b73eb645b68b6e197b63bbbae777b388d47612 Co-authored-by: Christian Brabandt --- runtime/autoload/netrw.vim | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'runtime/autoload') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index ae602c5be6..a1929636e5 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -12,6 +12,8 @@ " 2024 May 08 by Vim Project: cleanup legacy Win9X checks " 2024 May 09 by Vim Project: remove hard-coded private.ppk " 2024 May 10 by Vim Project: recursively delete directories by default +" 2024 May 13 by Vim Project: prefer scp over pscp +" 2024 Jun 04 by Vim Project: set bufhidden if buffer changed, nohidden is set and buffer shall be switched (#14915) " Former Maintainer: Charles E Campbell " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim " Copyright: Copyright (C) 2016 Charles E. Campbell {{{1 @@ -5681,6 +5683,9 @@ fun! s:NetrwEditFile(cmd,opt,fname) exe "NetrwKeepj keepalt ".a:opt." ".a:cmd." ".fnameescape(a:fname) else " call Decho("exe NetrwKeepj ".a:opt." ".a:cmd." ".fnameescape(a:fname)) + if a:cmd =~# 'e\%[new]!' && !&hidden && getbufvar(bufname('%'), '&modified', 0) + call setbufvar(bufname('%'), '&bufhidden', 'hide') + endif exe "NetrwKeepj ".a:opt." ".a:cmd." ".fnameescape(a:fname) endif " call Dret("s:NetrwEditFile") -- cgit From 4a2494098025c9e9b3aa205bdc2d357315831dc3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 14 Jun 2024 05:48:37 +0800 Subject: vim-patch:1487947: runtime(netrw): glob() on windows fails with [] in directory name (#29324) fixes: vim/vim#14952 closes: vim/vim#14991 https://github.com/vim/vim/commit/1487947fb625d44ed02382ea6b0d5bf72b12583a Co-authored-by: Christian Brabandt --- runtime/autoload/netrw.vim | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index a1929636e5..81cd66bc04 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -14,6 +14,7 @@ " 2024 May 10 by Vim Project: recursively delete directories by default " 2024 May 13 by Vim Project: prefer scp over pscp " 2024 Jun 04 by Vim Project: set bufhidden if buffer changed, nohidden is set and buffer shall be switched (#14915) +" 2024 Jun 13 by Vim Project: glob() on Windows fails when a directory name contains [] (#14952) " Former Maintainer: Charles E Campbell " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim " Copyright: Copyright (C) 2016 Charles E. Campbell {{{1 @@ -5756,16 +5757,20 @@ fun! s:NetrwGlob(direntry,expr,pare) let filelist= w:netrw_treedict[a:direntry] endif let w:netrw_liststyle= keep_liststyle - elseif v:version > 704 || (v:version == 704 && has("patch656")) - let filelist= glob(s:ComposePath(fnameescape(a:direntry),a:expr),0,1,1) - if a:pare - let filelist= map(filelist,'substitute(v:val, "^.*/", "", "")') - endif else - let filelist= glob(s:ComposePath(fnameescape(a:direntry),a:expr),0,1) - if a:pare - let filelist= map(filelist,'substitute(v:val, "^.*/", "", "")') - endif + let path= s:ComposePath(fnameescape(a:direntry),a:expr) + if has("win64") + " escape [ so it is not detected as wildcard character, see :h wildcard + let path= substitute(path, '[', '[[]', 'g') + endif + if v:version > 704 || (v:version == 704 && has("patch656")) + let filelist= glob(path,0,1,1) + else + let filelist= glob(path,0,1) + endif + if a:pare + let filelist= map(filelist,'substitute(v:val, "^.*/", "", "")') + endif endif " call Dret("s:NetrwGlob ".string(filelist)) return filelist -- cgit From 874869321a3a1695ba362dcb2e8334c8742c90a3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 14 Jun 2024 16:28:55 +0800 Subject: vim-patch:4407461: runtime(netrw): correctly test for windows in NetrwGlob() (#29330) use has("win32") instead of has("win64") otherwise it won't work on x86 systems. https://github.com/vim/vim/commit/440746158ce0fec2880ccacc03f39dbc954c5543 Co-authored-by: Christian Brabandt --- runtime/autoload/netrw.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 81cd66bc04..7da97c9690 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -5759,7 +5759,7 @@ fun! s:NetrwGlob(direntry,expr,pare) let w:netrw_liststyle= keep_liststyle else let path= s:ComposePath(fnameescape(a:direntry),a:expr) - if has("win64") + if has("win32") " escape [ so it is not detected as wildcard character, see :h wildcard let path= substitute(path, '[', '[[]', 'g') endif -- cgit From 6f1cbfc9ab483a09877e153ad130164875c40b1d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 16 Jun 2024 05:51:30 +0800 Subject: vim-patch:1c67342: runtime(zip): MS-Windows: handle files with spaces properly This change does the following 3 things: 1) non need to quote the file to be extracted The zipfile plugin used to quote and fnameescape() the path to the file to be extracted. However testing with unzip showed, that while this works on Linux on Windows you shall not escape the blanks in filenames. As long as the pathname is properly quoted, this words on Linux and Windows. 2) reset shellslash (MS-Windows only) When shellslash is set, filenames to the zip archive will be forward quoted. However since the filename is eventually handed over to the unzip command, we need to make sure to use native paths so that the command will understand what file to open. Therefore, if shellslash is set (and the shell is cmd.exe), replace any forward slashes by the expected backslashes 3) style: Use tabs for the Header, remove a few comments in the s:Escape() and zip#read() functions fixes: vim/vim#14998 https://github.com/vim/vim/commit/1c6734291295bf8aa39577840b40bb21a7f27120 Co-authored-by: Christian Brabandt --- runtime/autoload/zip.vim | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/zip.vim b/runtime/autoload/zip.vim index c0034f8a7a..fdd1a155ff 100644 --- a/runtime/autoload/zip.vim +++ b/runtime/autoload/zip.vim @@ -4,17 +4,18 @@ " Version: 33 " Maintainer: This runtime file is looking for a new maintainer. " Former Maintainer: Charles E Campbell +" Last Change: +" 2024 Jun 16 by Vim Project: handle whitespace on Windows properly (#14998) " License: Vim License (see vim's :help license) -" Copyright: Copyright (C) 2005-2019 Charles E. Campbell {{{1 -" Permission is hereby granted to use and distribute this code, -" with or without modifications, provided that this copyright -" notice is copied with it. Like anything else that's free, -" zip.vim and zipPlugin.vim are provided *as is* and comes with -" no warranty of any kind, either expressed or implied. By using -" this plugin, you agree that in no event will the copyright -" holder be liable for any damages resulting from the use -" of this software. -"redraw!|call DechoSep()|call inputsave()|call input("Press to continue")|call inputrestore() +" Copyright: Copyright (C) 2005-2019 Charles E. Campbell {{{1 +" Permission is hereby granted to use and distribute this code, +" with or without modifications, provided that this copyright +" notice is copied with it. Like anything else that's free, +" zip.vim and zipPlugin.vim are provided *as is* and comes with +" no warranty of any kind, either expressed or implied. By using +" this plugin, you agree that in no event will the copyright +" holder be liable for any damages resulting from the use +" of this software. " --------------------------------------------------------------------- " Load Once: {{{1 @@ -214,7 +215,6 @@ endfun " --------------------------------------------------------------------- " zip#Read: {{{2 fun! zip#Read(fname,mode) -" call Dfunc("zip#Read(fname<".a:fname.">,mode=".a:mode.")") let repkeep= &report set report=10 @@ -226,15 +226,12 @@ fun! zip#Read(fname,mode) let fname = substitute(a:fname,'^.\{-}zipfile://.\{-}::\([^\\].*\)$','\1','') let fname = substitute(fname, '[', '[[]', 'g') endif -" call Decho("zipfile<".zipfile.">") -" call Decho("fname <".fname.">") " sanity check if !executable(substitute(g:zip_unzipcmd,'\s\+.*$','','')) redraw! echohl Error | echo "***error*** (zip#Read) sorry, your system doesn't appear to have the ".g:zip_unzipcmd." program" | echohl None " call inputsave()|call input("Press to continue")|call inputrestore() let &report= repkeep -" call Dret("zip#Write") return endif @@ -242,10 +239,8 @@ fun! zip#Read(fname,mode) " exe "keepj sil! r! ".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fnameescape(fname),1) " but allows zipfile://... entries in quickfix lists let temp = tempname() -" call Decho("using temp file<".temp.">") let fn = expand('%:p') - exe "sil! !".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fnameescape(fname),1).' > '.temp -" call Decho("exe sil! !".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fnameescape(fname),1).' > '.temp) + exe "sil! !".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fname,1).' > '.temp sil exe 'keepalt file '.temp sil keepj e! sil exe 'keepalt file '.fnameescape(fn) @@ -254,11 +249,9 @@ fun! zip#Read(fname,mode) filetype detect " cleanup - " keepj 0d " used to be needed for the ...r! ... method set nomod let &report= repkeep -" call Dret("zip#Read") endfun " --------------------------------------------------------------------- @@ -314,6 +307,7 @@ fun! zip#Write(fname) if has("unix") let zipfile = substitute(a:fname,'zipfile://\(.\{-}\)::[^\\].*$','\1','') let fname = substitute(a:fname,'zipfile://.\{-}::\([^\\].*\)$','\1','') + let fname = fnameescape(fname) else let zipfile = substitute(a:fname,'^.\{-}zipfile://\(.\{-}\)::[^\\].*$','\1','') let fname = substitute(a:fname,'^.\{-}zipfile://.\{-}::\([^\\].*\)$','\1','') @@ -422,7 +416,6 @@ endfun " --------------------------------------------------------------------- " s:Escape: {{{2 fun! s:Escape(fname,isfilt) -" call Dfunc("QuoteFileDir(fname<".a:fname."> isfilt=".a:isfilt.")") if exists("*shellescape") if a:isfilt let qnameq= shellescape(a:fname,1) @@ -432,7 +425,10 @@ fun! s:Escape(fname,isfilt) else let qnameq= g:zip_shq.escape(a:fname,g:zip_shq).g:zip_shq endif -" call Dret("QuoteFileDir <".qnameq.">") + if exists("+shellslash") && &shellslash && &shell =~ "cmd.exe" + " renormalize directory separator on Windows + let qnameq=substitute(qnameq, '/', '\\', 'g') + endif return qnameq endfun -- cgit From c1d463fcafbe0efa9708d799e68f0cef0c4f7fb5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 16 Jun 2024 05:52:00 +0800 Subject: vim-patch:52f2ff0: runtime(zip): revert unintended change to zip#Write() This was wrongly included as of patch 1c6734291295bf8aa39577840b40bb because apparently I messed up the use of git apply :/ https://github.com/vim/vim/commit/52f2ff03636fe120f3c9d00e9b3cdc1da251bd73 Co-authored-by: Christian Brabandt --- runtime/autoload/zip.vim | 1 - 1 file changed, 1 deletion(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/zip.vim b/runtime/autoload/zip.vim index fdd1a155ff..d0e706e83a 100644 --- a/runtime/autoload/zip.vim +++ b/runtime/autoload/zip.vim @@ -307,7 +307,6 @@ fun! zip#Write(fname) if has("unix") let zipfile = substitute(a:fname,'zipfile://\(.\{-}\)::[^\\].*$','\1','') let fname = substitute(a:fname,'zipfile://.\{-}::\([^\\].*\)$','\1','') - let fname = fnameescape(fname) else let zipfile = substitute(a:fname,'^.\{-}zipfile://\(.\{-}\)::[^\\].*$','\1','') let fname = substitute(a:fname,'^.\{-}zipfile://.\{-}::\([^\\].*\)$','\1','') -- cgit From 295e223a2830e75b396f15726c68ef18ba955424 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 25 Jun 2024 09:38:50 +0800 Subject: vim-patch:62f7b55: runtime(netrw): save and restore register 0-9, a and unnamed (#29479) fixes: vim/vim#15077 https://github.com/vim/vim/commit/62f7b55c1a4564f8744af9446bc7af47fe16a245 Co-authored-by: Christian Brabandt --- runtime/autoload/netrw.vim | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 7da97c9690..c7306289e5 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -15,6 +15,7 @@ " 2024 May 13 by Vim Project: prefer scp over pscp " 2024 Jun 04 by Vim Project: set bufhidden if buffer changed, nohidden is set and buffer shall be switched (#14915) " 2024 Jun 13 by Vim Project: glob() on Windows fails when a directory name contains [] (#14952) +" 2024 Jun 23 by Vim Project: save ad restore registers when liststyle = WIDELIST (#15077) " Former Maintainer: Charles E Campbell " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim " Copyright: Copyright (C) 2016 Charles E. Campbell {{{1 @@ -5526,13 +5527,12 @@ endfun " --------------------------------------------------------------------- " netrw#BrowseXVis: used by gx in visual mode to select a file for browsing {{{2 fun! netrw#BrowseXVis() -" call Dfunc("netrw#BrowseXVis()") - let akeep = @a + let dict={} + let dict.a=[getreg('a'), getregtype('a')] norm! gv"ay let gxfile= @a - let @a = akeep + call s:RestoreRegister(dict) call netrw#BrowseX(gxfile,netrw#CheckIfRemote(gxfile)) -" call Dret("netrw#BrowseXVis") endfun " --------------------------------------------------------------------- @@ -9679,7 +9679,13 @@ fun! s:NetrwWideListing() " fpl: filenames per line " fpc: filenames per column setl ma noro - let keepa= @a + let dict={} + " save the unnamed register and register 0-9 and a + let dict.a=[getreg('a'), getregtype('a')] + for i in range(0, 9) + let dict[i] = [getreg(i), getregtype(i)] + endfor + let dict.unnamed = [getreg(''), getregtype('')] " call Decho("setl ma noro",'~'.expand("")) let b:netrw_cpf= 0 if line("$") >= w:netrw_bannercnt @@ -9687,7 +9693,8 @@ fun! s:NetrwWideListing() exe 'sil NetrwKeepj '.w:netrw_bannercnt.',$g/^./if virtcol("$") > b:netrw_cpf|let b:netrw_cpf= virtcol("$")|endif' NetrwKeepj call histdel("/",-1) else - let @a= keepa + " restore stored registers + call s:RestoreRegister(dict) " call Dret("NetrwWideListing") return endif @@ -9729,7 +9736,7 @@ fun! s:NetrwWideListing() exe 'nno b :call search(''^.\\|\s\s\zs\S'',''bW'')'."\" " call Decho("NetrwWideListing) setl noma nomod ro",'~'.expand("")) exe "setl ".g:netrw_bufsettings - let @a= keepa + call s:RestoreRegister(dict) " call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("")) " call Dret("NetrwWideListing") return @@ -9741,7 +9748,6 @@ fun! s:NetrwWideListing() sil! nunmap b endif endif - endfun " --------------------------------------------------------------------- @@ -10062,7 +10068,8 @@ fun! s:SetupNetrwStatusLine(statline) endif " set up User9 highlighting as needed - let keepa= @a + let dict={} + let dict.a=[getreg('a'), getregtype('a')] redir @a try hi User9 @@ -10074,7 +10081,7 @@ fun! s:SetupNetrwStatusLine(statline) endif endtry redir END - let @a= keepa + call s:RestoreRegister(dict) endif " set up status line (may use User9 highlighting) @@ -11884,6 +11891,16 @@ fun! s:RestoreCursorline() " call Dret("s:RestoreCursorline : restored cul=".&l:cursorline." cuc=".&l:cursorcolumn) endfun +" s:RestoreRegister: restores all registers given in the dict {{{2 +fun! s:RestoreRegister(dict) + for [key, val] in items(a:dict) + if key == 'unnamed' + let key = '' + endif + call setreg(key, val[0], val[1]) + endfor +endfun + " --------------------------------------------------------------------- " s:NetrwDelete: Deletes a file. {{{2 " Uses Steve Hall's idea to insure that Windows paths stay -- cgit From bda63d5b97dfb333de6f4bd757dbb978906062a2 Mon Sep 17 00:00:00 2001 From: bfredl Date: Tue, 25 Jun 2024 15:33:47 +0200 Subject: refactor(typval)!: remove distinction of binary and nonbinary strings This is a breaking change which will make refactor of typval and shada code a lot easier. In particular, code that would use or check for v:msgpack_types.binary in the wild would be broken. This appears to be rarely used in existing plugins. Also some cases where v:msgpack_type.string would be used to represent a binary string of "string" type, we use a BLOB instead, which is vimscripts native type for binary blobs, and already was used for BIN formats when necessary. msgpackdump(msgpackparse(data)) no longer preserves the distinction of BIN and STR strings. This is very common behavior for language-specific msgpack bindings. Nvim uses msgpack as a tool to serialize its data. Nvim is not a tool to bit-perfectly manipulate arbitrary msgpack data out in the wild. The changed tests should indicate how behavior changes in various edge cases. --- runtime/autoload/msgpack.vim | 50 +++++++++++++++++++++----------------------- runtime/autoload/shada.vim | 4 ++-- 2 files changed, 26 insertions(+), 28 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/msgpack.vim b/runtime/autoload/msgpack.vim index 18dcd1e6a6..fb438def4f 100644 --- a/runtime/autoload/msgpack.vim +++ b/runtime/autoload/msgpack.vim @@ -361,7 +361,7 @@ endfunction let s:MSGPACK_STANDARD_TYPES = { \type(0): 'integer', \type(0.0): 'float', - \type(''): 'binary', + \type(''): 'string', \type([]): 'array', \type({}): 'map', \type(v:true): 'boolean', @@ -412,9 +412,15 @@ endfunction "" " Dump |msgpack-special-dict| that represents a string. If any additional " parameter is given then it dumps binary string. -function s:msgpack_dump_string(v, ...) abort - let ret = [a:0 ? '"' : '="'] - for v in a:v._VAL +function s:msgpack_dump_string(v) abort + if type(a:v) == type({}) + let val = a:v + else + let val = {'_VAL': split(a:v, "\n", 1)} + end + + let ret = ['"'] + for v in val._VAL call add( \ret, \substitute( @@ -426,16 +432,6 @@ function s:msgpack_dump_string(v, ...) abort return join(ret, '') endfunction -"" -" Dump binary string. -function s:msgpack_dump_binary(v) abort - if type(a:v) == type({}) - return s:msgpack_dump_string(a:v, 1) - else - return s:msgpack_dump_string({'_VAL': split(a:v, "\n", 1)}, 1) - endif -endfunction - "" " Dump array value. function s:msgpack_dump_array(v) abort @@ -449,7 +445,7 @@ function s:msgpack_dump_map(v) abort let ret = ['{'] if msgpack#special_type(a:v) is 0 for [k, v] in items(a:v) - let ret += [s:msgpack_dump_string({'_VAL': split(k, "\n", 1)}), + let ret += [s:msgpack_dump_string({'_VAL': split(k, "\n")}), \': ', \msgpack#string(v), \', '] @@ -479,7 +475,7 @@ endfunction " Dump extension value. function s:msgpack_dump_ext(v) abort return printf('+(%i)%s', a:v._VAL[0], - \s:msgpack_dump_string({'_VAL': a:v._VAL[1]}, 1)) + \s:msgpack_dump_string({'_VAL': a:v._VAL[1]})) endfunction "" @@ -619,9 +615,7 @@ function msgpack#eval(s, special_objs) abort throw '"-invalid:Invalid string: ' . s endif call add(expr, '{''_TYPE'': v:msgpack_types.') - if empty(match[1]) - call add(expr, 'binary') - elseif match[1] is# '=' + if empty(match[1]) || match[1] is# '=' call add(expr, 'string') else call add(expr, 'ext') @@ -772,7 +766,7 @@ function msgpack#equal(a, b) let a = aspecial is 0 ? a:a : a:a._VAL let b = bspecial is 0 ? a:b : a:b._VAL return msgpack#equal(a, b) - elseif atype is# 'binary' + elseif atype is# 'string' let a = (aspecial is 0 ? split(a:a, "\n", 1) : a:a._VAL) let b = (bspecial is 0 ? split(a:b, "\n", 1) : a:b._VAL) return a ==# b @@ -787,13 +781,17 @@ function msgpack#equal(a, b) " Non-special mapping cannot have non-string keys return 0 endif - if (empty(k._VAL) - \|| k._VAL ==# [""] - \|| !empty(filter(copy(k._VAL), 'stridx(v:val, "\n") != -1'))) - " Non-special mapping cannot have zero byte in key or an empty key - return 0 + if type(k) == type({}) + if (empty(k._VAL) + \|| k._VAL ==# [""] + \|| !empty(filter(copy(k._VAL), 'stridx(v:val, "\n") != -1'))) + " Non-special mapping cannot have zero byte in key or an empty key + return 0 + endif + let kstr = join(k._VAL, "\n") + else + let kstr = k endif - let kstr = join(k._VAL, "\n") if !has_key(akeys, kstr) " Protects from both missing and duplicate keys return 0 diff --git a/runtime/autoload/shada.vim b/runtime/autoload/shada.vim index ae718ad2e7..4753973196 100644 --- a/runtime/autoload/shada.vim +++ b/runtime/autoload/shada.vim @@ -230,7 +230,7 @@ function s:shada_check_type(type, val) abort return 0 elseif a:type is# 'bin' " Binary string without zero bytes - if type isnot# 'binary' + if type isnot# 'string' return 'Expected binary string' elseif (type(a:val) == type({}) \&& !empty(filter(copy(a:val._VAL), 'stridx(v:val, "\n") != -1'))) @@ -247,7 +247,7 @@ function s:shada_check_type(type, val) abort if type isnot# 'array' return 'Expected array value' elseif !empty(filter(copy(type(a:val) == type({}) ? a:val._VAL : a:val), - \'msgpack#type(v:val) isnot# "binary"')) + \'msgpack#type(v:val) isnot# "string"')) return 'Expected array of binary strings' else for element in (type(a:val) == type({}) ? a:val._VAL : a:val) -- cgit From 71c50edceb5e097fe4faf9278a5fb4d41a303455 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Thu, 4 Jul 2024 19:57:21 +0200 Subject: vim-patch:3146d63: runtime(netrw): fix remaining case of register clobber complements 62f7b55c1a4564f8744af9446bc7af47fe16a245 closes: vim/vim#15114 https://github.com/vim/vim/commit/3146d63267664e0a0afdbe14be0cec30e7168a04 Co-authored-by: Enno --- runtime/autoload/netrw.vim | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index c7306289e5..0ac216e8b2 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -15,7 +15,7 @@ " 2024 May 13 by Vim Project: prefer scp over pscp " 2024 Jun 04 by Vim Project: set bufhidden if buffer changed, nohidden is set and buffer shall be switched (#14915) " 2024 Jun 13 by Vim Project: glob() on Windows fails when a directory name contains [] (#14952) -" 2024 Jun 23 by Vim Project: save ad restore registers when liststyle = WIDELIST (#15077) +" 2024 Jun 23 by Vim Project: save ad restore registers when liststyle = WIDELIST (#15077, #15114) " Former Maintainer: Charles E Campbell " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim " Copyright: Copyright (C) 2016 Charles E. Campbell {{{1 @@ -4450,7 +4450,15 @@ fun! s:NetrwGetWord() call cursor(line("."),filestart+1) NetrwKeepj norm! ma endif - let rega= @a + + let dict={} + " save the unnamed register and register 0-9 and a + let dict.a=[getreg('a'), getregtype('a')] + for i in range(0, 9) + let dict[i] = [getreg(i), getregtype(i)] + endfor + let dict.unnamed = [getreg(''), getregtype('')] + let eofname= filestart + b:netrw_cpf + 1 if eofname <= col("$") call cursor(line("."),filestart+b:netrw_cpf+1) @@ -4458,8 +4466,10 @@ fun! s:NetrwGetWord() else NetrwKeepj norm! "ay$ endif + let dirname = @a - let @a = rega + call s:RestoreRegister(dict) + " call Decho("2: dirname<".dirname.">",'~'.expand("")) let dirname= substitute(dirname,'\s\+$','','e') " call Decho("3: dirname<".dirname.">",'~'.expand("")) -- cgit From a0fd51c1e2db17ab21e2a2c907b232d05dfffc88 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Mon, 15 Jul 2024 20:02:22 +0200 Subject: vim-patch:1cc4cae: runtime(typst): Add typst runtime files closes: vim/vim#15234 https://github.com/vim/vim/commit/1cc4cae961a7b49608ef7bd56837cc723d49db4d Co-authored-by: Gregory Anders --- runtime/autoload/typst.vim | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 runtime/autoload/typst.vim (limited to 'runtime/autoload') diff --git a/runtime/autoload/typst.vim b/runtime/autoload/typst.vim new file mode 100644 index 0000000000..55edd23928 --- /dev/null +++ b/runtime/autoload/typst.vim @@ -0,0 +1,50 @@ +" Language: Typst +" Maintainer: Gregory Anders +" Last Change: 2024-07-14 +" Based on: https://github.com/kaarmu/typst.vim + +function! typst#indentexpr() abort + let l:lnum = v:lnum + let s:sw = shiftwidth() + + let [l:plnum, l:pline] = s:get_prev_nonblank(l:lnum - 1) + if l:plnum == 0 | return 0 | endif + + let l:line = getline(l:lnum) + let l:ind = indent(l:plnum) + + let l:synname = synIDattr(synID(l:lnum, 1, 1), 'name') + + " Use last indent for block comments + if l:synname == 'typstCommentBlock' + return l:ind + endif + + if l:pline =~ '\v[{[(]\s*$' + let l:ind += s:sw + endif + + if l:line =~ '\v^\s*[}\])]' + let l:ind -= s:sw + endif + + return l:ind +endfunction + +" Gets the previous non-blank line that is not a comment. +function! s:get_prev_nonblank(lnum) abort + let l:lnum = prevnonblank(a:lnum) + let l:line = getline(l:lnum) + + while l:lnum > 0 && l:line =~ '^\s*//' + let l:lnum = prevnonblank(l:lnum - 1) + let l:line = getline(l:lnum) + endwhile + + return [l:lnum, s:remove_comments(l:line)] +endfunction + +" Removes comments from the given line. +function! s:remove_comments(line) abort + return substitute(a:line, '\s*//.*', '', '') +endfunction -- cgit From 9322b7e0594de77f8c0f6ef34c197b8a3aac7844 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Mon, 22 Jul 2024 23:13:10 +0200 Subject: vim-patch:9d57ea5: runtime(netrw): Fix endless recursion in netrw#Explore() Problem: ':E /etc BOOM' give E132 error. Solution: Avoid recursion call with same arguments. fixes: vim/vim#5723 closes: vim/vim#15318 https://github.com/vim/vim/commit/9d57ea5cd3a23af02c72c0e86fe24b7bba57189a Co-authored-by: Damien <141588647+xrandomname@users.noreply.github.com> --- runtime/autoload/netrw.vim | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 0ac216e8b2..b4d7743236 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -16,6 +16,7 @@ " 2024 Jun 04 by Vim Project: set bufhidden if buffer changed, nohidden is set and buffer shall be switched (#14915) " 2024 Jun 13 by Vim Project: glob() on Windows fails when a directory name contains [] (#14952) " 2024 Jun 23 by Vim Project: save ad restore registers when liststyle = WIDELIST (#15077, #15114) +" 2024 Jul 22 by Vim Project: avoid endless recursion (#15318) " Former Maintainer: Charles E Campbell " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim " Copyright: Copyright (C) 2016 Charles E. Campbell {{{1 @@ -692,12 +693,11 @@ fun! netrw#Explore(indx,dosplit,style,...) \ ((isdirectory(s:NetrwFile(a:1))))? 'is a directory' : 'is not a directory', \ '~'.expand("")) if a:1 =~ "\\\s" && !filereadable(s:NetrwFile(a:1)) && !isdirectory(s:NetrwFile(a:1)) -" call Decho("re-trying Explore with <".substitute(a:1,'\\\(\s\)','\1','g').">",'~'.expand("")) - call netrw#Explore(a:indx,a:dosplit,a:style,substitute(a:1,'\\\(\s\)','\1','g')) -" call Dret("netrw#Explore : returning from retry") - return -" else " Decho -" call Decho("retry not needed",'~'.expand("")) + let a1 = substitute(a:1, '\\\(\s\)', '\1', 'g') + if a1 != a:1 + call netrw#Explore(a:indx, a:dosplit, a:style, a1) + return + endif endif endif -- cgit From c025c049a4a7b0a6dbcd94f804504bba6d081a84 Mon Sep 17 00:00:00 2001 From: Nikita Rudakov <53019776+zer0reaction@users.noreply.github.com> Date: Wed, 24 Jul 2024 02:33:44 +0300 Subject: vim-patch:581d4a7: runtime(netrw): escape filename before trying to delete it (#29838) fixes: vim/vim#15330 https://github.com/vim/vim/commit/581d4a7b356395bcb8606c1717ded65d47d26c68 Co-authored-by: Christian Brabandt --- runtime/autoload/netrw.vim | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index b4d7743236..92d8409440 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -17,6 +17,7 @@ " 2024 Jun 13 by Vim Project: glob() on Windows fails when a directory name contains [] (#14952) " 2024 Jun 23 by Vim Project: save ad restore registers when liststyle = WIDELIST (#15077, #15114) " 2024 Jul 22 by Vim Project: avoid endless recursion (#15318) +" 2024 Jul 23 by Vim Project: escape filename before trying to delete it (#15330) " Former Maintainer: Charles E Campbell " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim " Copyright: Copyright (C) 2016 Charles E. Campbell {{{1 @@ -11342,7 +11343,7 @@ fun! s:NetrwLocalRmFile(path,fname,all) let all= a:all let ok = "" NetrwKeepj norm! 0 - let rmfile= s:NetrwFile(s:ComposePath(a:path,a:fname)) + let rmfile= s:NetrwFile(s:ComposePath(a:path,escape(a:fname, '\\'))) " call Decho("rmfile<".rmfile.">",'~'.expand("")) if rmfile !~ '^"' && (rmfile =~ '@$' || rmfile !~ '[\/]$') @@ -11351,7 +11352,7 @@ fun! s:NetrwLocalRmFile(path,fname,all) if !all echohl Statement call inputsave() - let ok= input("Confirm deletion of file<".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ") + let ok= input("Confirm deletion of file <".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ") call inputrestore() echohl NONE if ok == "" @@ -11375,7 +11376,7 @@ fun! s:NetrwLocalRmFile(path,fname,all) if !all echohl Statement call inputsave() - let ok= input("Confirm *recursive* deletion of directory<".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ") + let ok= input("Confirm *recursive* deletion of directory <".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ") call inputrestore() let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e') if ok == "" -- cgit From 64727ac01219db0466bd094068cab9ee8044042c Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Tue, 23 Jul 2024 20:01:55 +0200 Subject: vim-patch:38ce71c: runtime(zip): correctly extract file from zip browser Problem: Enter 'x' in zip browser fail with E121 Solution: Fix typo in zip#Extract() closes: vim/vim#15321 https://github.com/vim/vim/commit/38ce71c1c323716cc4b130dbb3e8837a8b9a710b Co-authored-by: Damien <141588647+xrandomname@users.noreply.github.com> --- runtime/autoload/zip.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/zip.vim b/runtime/autoload/zip.vim index d0e706e83a..34bcad3368 100644 --- a/runtime/autoload/zip.vim +++ b/runtime/autoload/zip.vim @@ -1,11 +1,12 @@ " zip.vim: Handles browsing zipfiles " AUTOLOAD PORTION -" Date: Mar 12, 2023 +" Date: Jul 23, 2024 " Version: 33 " Maintainer: This runtime file is looking for a new maintainer. " Former Maintainer: Charles E Campbell " Last Change: " 2024 Jun 16 by Vim Project: handle whitespace on Windows properly (#14998) +" 2024 Jul 23 by Vim Project: fix 'x' command " License: Vim License (see vim's :help license) " Copyright: Copyright (C) 2005-2019 Charles E. Campbell {{{1 " Permission is hereby granted to use and distribute this code, @@ -395,8 +396,7 @@ fun! zip#Extract() endif " extract the file mentioned under the cursor -" call Decho("system(".g:zip_extractcmd." ".shellescape(b:zipfile)." ".shellescape(shell).")") - call system(g:zip_extractcmd." ".shellescape(b:zipfile)." ".shellescape(shell)) + call system($"{g:zip_extractcmd} {shellescape(b:zipfile)} {shellescape(fname)}") " call Decho("zipfile<".b:zipfile.">") if v:shell_error != 0 echohl Error | echo "***error*** ".g:zip_extractcmd." ".b:zipfile." ".fname.": failed!" | echohl NONE -- cgit From 90d40c68dcb91f30ad416e5d368cd230585c584d Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Thu, 25 Jul 2024 09:25:56 +0200 Subject: vim-patch:2cad941: runtime(zip): Use delete() for deleting directory This is safer because we don't invoke the shell. closes: vim/vim#15335 https://github.com/vim/vim/commit/2cad941dc0cb57bca577160eb3a349de2e667bcd Co-authored-by: Damien <141588647+xrandomname@users.noreply.github.com> --- runtime/autoload/zip.vim | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/zip.vim b/runtime/autoload/zip.vim index 34bcad3368..79f707fbd8 100644 --- a/runtime/autoload/zip.vim +++ b/runtime/autoload/zip.vim @@ -1,12 +1,13 @@ " zip.vim: Handles browsing zipfiles -" AUTOLOAD PORTION -" Date: Jul 23, 2024 +" AUTOLOAD PORTION +" Date: Jul 24, 2024 " Version: 33 " Maintainer: This runtime file is looking for a new maintainer. " Former Maintainer: Charles E Campbell " Last Change: -" 2024 Jun 16 by Vim Project: handle whitespace on Windows properly (#14998) -" 2024 Jul 23 by Vim Project: fix 'x' command +" 2024 Jun 16 by Vim Project: handle whitespace on Windows properly (#14998) +" 2024 Jul 23 by Vim Project: fix 'x' command +" 2024 Jul 24 by Vim Project: use delete() function " License: Vim License (see vim's :help license) " Copyright: Copyright (C) 2005-2019 Charles E. Campbell {{{1 " Permission is hereby granted to use and distribute this code, @@ -299,7 +300,7 @@ fun! zip#Write(fname) " place temporary files under .../_ZIPVIM_/ if isdirectory("_ZIPVIM_") - call s:Rmdir("_ZIPVIM_") + call delete("_ZIPVIM_", "rf") endif call mkdir("_ZIPVIM_") cd _ZIPVIM_ @@ -359,12 +360,12 @@ fun! zip#Write(fname) q! unlet s:zipfile_{winnr()} endif - + " cleanup and restore current directory cd .. - call s:Rmdir("_ZIPVIM_") + call delete("_ZIPVIM_", "rf") call s:ChgDir(curdir,s:WARNING,"(zip#Write) unable to return to ".curdir."!") - call s:Rmdir(tmpdir) + call delete(tmpdir, "rf") setlocal nomod let &report= repkeep @@ -456,18 +457,6 @@ fun! s:ChgDir(newdir,errlvl,errmsg) return 0 endfun -" --------------------------------------------------------------------- -" s:Rmdir: {{{2 -fun! s:Rmdir(fname) -" call Dfunc("Rmdir(fname<".a:fname.">)") - if (has("win32") || has("win95") || has("win64") || has("win16")) && &shell !~? 'sh$' - call system("rmdir /S/Q ".s:Escape(a:fname,0)) - else - call system("/bin/rm -rf ".s:Escape(a:fname,0)) - endif -" call Dret("Rmdir") -endfun - " ------------------------------------------------------------------------ " Modelines And Restoration: {{{1 let &cpo= s:keepcpo -- cgit From 34fa34e72033d107d9b133273fbd60ec57a2202c Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Tue, 30 Jul 2024 19:18:41 +0200 Subject: vim-patch:c4be066: runtime(zip): Opening a remote zipfile don't work Problem: Opening a zipfile from HTTP gives an empty buffer. Solution: Ensure that the magic bytes check does not skip protocol processing. Also use readblob() and remove commented out lines. closes: vim/vim#15396 https://github.com/vim/vim/commit/c4be066817d560c870f67f1593630cfb5b39dfc8 Co-authored-by: Damien <141588647+xrandomname@users.noreply.github.com> --- runtime/autoload/zip.vim | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/zip.vim b/runtime/autoload/zip.vim index 79f707fbd8..f77d729f03 100644 --- a/runtime/autoload/zip.vim +++ b/runtime/autoload/zip.vim @@ -1,6 +1,6 @@ " zip.vim: Handles browsing zipfiles " AUTOLOAD PORTION -" Date: Jul 24, 2024 +" Date: Jul 30, 2024 " Version: 33 " Maintainer: This runtime file is looking for a new maintainer. " Former Maintainer: Charles E Campbell @@ -8,6 +8,7 @@ " 2024 Jun 16 by Vim Project: handle whitespace on Windows properly (#14998) " 2024 Jul 23 by Vim Project: fix 'x' command " 2024 Jul 24 by Vim Project: use delete() function +" 2024 Jul 20 by Vim Project: fix opening remote zipfile " License: Vim License (see vim's :help license) " Copyright: Copyright (C) 2005-2019 Charles E. Campbell {{{1 " Permission is hereby granted to use and distribute this code, @@ -73,15 +74,11 @@ endif " --------------------------------------------------------------------- " zip#Browse: {{{2 fun! zip#Browse(zipfile) -" call Dfunc("zip#Browse(zipfile<".a:zipfile.">)") - " sanity check: insure that the zipfile has "PK" as its first two letters - " (zipped files have a leading PK as a "magic cookie") - if !filereadable(a:zipfile) || readfile(a:zipfile, "", 1)[0] !~ '^PK' - exe "noswapfile noautocmd noswapfile e ".fnameescape(a:zipfile) -" call Dret("zip#Browse : not a zipfile<".a:zipfile.">") + " sanity check: ensure that the zipfile has "PK" as its first two letters + " (zip files have a leading PK as a "magic cookie") + if filereadable(a:zipfile) && readblob(a:zipfile, 0, 2) != 0z50.4B + exe "noswapfile noautocmd e " .. fnameescape(a:zipfile) return -" else " Decho -" call Decho("zip#Browse: a:zipfile<".a:zipfile."> passed PK test - it's a zip file") endif let repkeep= &report @@ -97,9 +94,7 @@ fun! zip#Browse(zipfile) if !executable(g:zip_unzipcmd) redraw! echohl Error | echo "***error*** (zip#Browse) unzip not available on your system" -" call inputsave()|call input("Press to continue")|call inputrestore() let &report= repkeep -" call Dret("zip#Browse") return endif if !filereadable(a:zipfile) @@ -107,13 +102,10 @@ fun! zip#Browse(zipfile) " if it's an url, don't complain, let url-handlers such as vim do its thing redraw! echohl Error | echo "***error*** (zip#Browse) File not readable<".a:zipfile.">" | echohl None -" call inputsave()|call input("Press to continue")|call inputrestore() endif let &report= repkeep -" call Dret("zip#Browse : file<".a:zipfile."> not readable") return endif -" call Decho("passed sanity checks") if &ma != 1 set ma endif -- cgit From 617810d72d78ce7e1f5e6b6e71ccb6bb5960904d Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Tue, 30 Jul 2024 21:41:40 +0200 Subject: vim-patch:e34d0e3: runtime(netrw): removing trailing slash when copying files in same directory closes: vim/vim#14756 https://github.com/vim/vim/commit/e34d0e37e397419636ae5d27d4b236b193efef07 Co-authored-by: Travis Shelton --- runtime/autoload/netrw.vim | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 92d8409440..44088f3b7f 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -3,7 +3,7 @@ " Maintainer: This runtime file is looking for a new maintainer. " Date: May 03, 2023 " Version: 173a -" Last Change: +" Last Change: {{{1 " 2023 Nov 21 by Vim Project: ignore wildignore when expanding $COMSPEC (v173a) " 2023 Nov 22 by Vim Project: fix handling of very long filename on longlist style (v173a) " 2024 Feb 19 by Vim Project: (announce adoption) @@ -18,6 +18,8 @@ " 2024 Jun 23 by Vim Project: save ad restore registers when liststyle = WIDELIST (#15077, #15114) " 2024 Jul 22 by Vim Project: avoid endless recursion (#15318) " 2024 Jul 23 by Vim Project: escape filename before trying to delete it (#15330) +" 2024 Jul 30 by Vim Project: handle mark-copy to same target directory (#12112) +" }}} " Former Maintainer: Charles E Campbell " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim " Copyright: Copyright (C) 2016 Charles E. Campbell {{{1 @@ -7105,7 +7107,7 @@ fun! s:NetrwMarkFileCopy(islocal,...) endif " copy marked files while within the same directory (ie. allow renaming) - if simplify(s:netrwmftgt) == simplify(b:netrw_curdir) + if s:StripTrailingSlash(simplify(s:netrwmftgt)) == s:StripTrailingSlash(simplify(b:netrw_curdir)) if len(s:netrwmarkfilelist_{bufnr('%')}) == 1 " only one marked file " call Decho("case: only one marked file",'~'.expand("")) @@ -7182,7 +7184,7 @@ fun! s:NetrwMarkFileCopy(islocal,...) " call Decho("system(".copycmd." '".args."' '".tgt."')",'~'.expand("")) call system(copycmd.g:netrw_localcopycmdopt." '".args."' '".tgt."'") if v:shell_error != 0 - if exists("b:netrw_curdir") && b:netrw_curdir != getcwd() && !g:netrw_keepdir + if exists("b:netrw_curdir") && b:netrw_curdir != getcwd() && g:netrw_keepdir call netrw#ErrorMsg(s:ERROR,"copy failed; perhaps due to vim's current directory<".getcwd()."> not matching netrw's (".b:netrw_curdir.") (see :help netrw-cd)",101) else call netrw#ErrorMsg(s:ERROR,"tried using g:netrw_localcopycmd<".g:netrw_localcopycmd.">; it doesn't work!",80) @@ -11535,6 +11537,14 @@ fun! netrw#WinPath(path) return path endfun +" --------------------------------------------------------------------- +" s:StripTrailingSlash: removes trailing slashes from a path {{{2 +fun! s:StripTrailingSlash(path) + " remove trailing slash + return substitute(a:path, '[/\\]$', '', 'g') +endfun + + " --------------------------------------------------------------------- " s:NetrwBadd: adds marked files to buffer list or vice versa {{{2 " cb : bl2mf=0 add marked files to buffer list -- cgit From a90b1b7c6fcc0ee558312b34b190ef26667e771f Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Fri, 2 Aug 2024 19:50:09 +0200 Subject: vim-patch:c527d90: runtime(netrw): honor `g:netrw_alt{o,v}` for `:{S,H,V}explore` Make `:Sexplore` / `:Hexplore` / `:Vexplore` commands honor the user `&split{right,below}` settings (or netrw-specific `g:netrw_alt{o,v}`) instead of hardcoding a split direction. Similarly, update banged variants of the two latter commands to follow the inverted preference. closes: vim/vim#15417 https://github.com/vim/vim/commit/c527d90fae7210d6dc5cbdf7507f26a32455149b Co-authored-by: Ivan Shapovalov --- runtime/autoload/netrw.vim | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 44088f3b7f..0a9c13aad9 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -19,6 +19,7 @@ " 2024 Jul 22 by Vim Project: avoid endless recursion (#15318) " 2024 Jul 23 by Vim Project: escape filename before trying to delete it (#15330) " 2024 Jul 30 by Vim Project: handle mark-copy to same target directory (#12112) +" 2024 Aug 02 by Vim Project: honor g:netrw_alt{o,v} for :{S,H,V}explore (#15417) " }}} " Former Maintainer: Charles E Campbell " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim @@ -711,7 +712,6 @@ fun! netrw#Explore(indx,dosplit,style,...) " -or- file has been modified AND file not hidden when abandoned " -or- Texplore used if a:dosplit || (&modified && &hidden == 0 && &bufhidden != "hide") || a:style == 6 -" call Decho("case dosplit=".a:dosplit." modified=".&modified." a:style=".a:style.": dosplit or file has been modified",'~'.expand("")) call s:SaveWinVars() let winsz= g:netrw_winsize if a:indx > 0 @@ -719,57 +719,41 @@ fun! netrw#Explore(indx,dosplit,style,...) endif if a:style == 0 " Explore, Sexplore -" call Decho("style=0: Explore or Sexplore",'~'.expand("")) let winsz= (winsz > 0)? (winsz*winheight(0))/100 : -winsz if winsz == 0|let winsz= ""|endif - exe "noswapfile ".winsz."wincmd s" -" call Decho("exe noswapfile ".winsz."wincmd s",'~'.expand("")) + exe "noswapfile ".(g:netrw_alto ? "below " : "above ").winsz."wincmd s" - elseif a:style == 1 "Explore!, Sexplore! -" call Decho("style=1: Explore! or Sexplore!",'~'.expand("")) + elseif a:style == 1 " Explore!, Sexplore! let winsz= (winsz > 0)? (winsz*winwidth(0))/100 : -winsz if winsz == 0|let winsz= ""|endif - exe "keepalt noswapfile ".winsz."wincmd v" -" call Decho("exe keepalt noswapfile ".winsz."wincmd v",'~'.expand("")) + exe "keepalt noswapfile ".(g:netrw_altv ? "rightbelow " : "leftabove ").winsz."wincmd v" elseif a:style == 2 " Hexplore -" call Decho("style=2: Hexplore",'~'.expand("")) let winsz= (winsz > 0)? (winsz*winheight(0))/100 : -winsz if winsz == 0|let winsz= ""|endif - exe "keepalt noswapfile bel ".winsz."wincmd s" -" call Decho("exe keepalt noswapfile bel ".winsz."wincmd s",'~'.expand("")) + exe "keepalt noswapfile ".(g:netrw_alto ? "below " : "above ").winsz."wincmd s" elseif a:style == 3 " Hexplore! -" call Decho("style=3: Hexplore!",'~'.expand("")) let winsz= (winsz > 0)? (winsz*winheight(0))/100 : -winsz if winsz == 0|let winsz= ""|endif - exe "keepalt noswapfile abo ".winsz."wincmd s" -" call Decho("exe keepalt noswapfile abo ".winsz."wincmd s",'~'.expand("")) + exe "keepalt noswapfile ".(!g:netrw_alto ? "below " : "above ").winsz."wincmd s" elseif a:style == 4 " Vexplore -" call Decho("style=4: Vexplore",'~'.expand("")) let winsz= (winsz > 0)? (winsz*winwidth(0))/100 : -winsz if winsz == 0|let winsz= ""|endif - exe "keepalt noswapfile lefta ".winsz."wincmd v" -" call Decho("exe keepalt noswapfile lefta ".winsz."wincmd v",'~'.expand("")) + exe "keepalt noswapfile ".(g:netrw_altv ? "rightbelow " : "leftabove ").winsz."wincmd v" elseif a:style == 5 " Vexplore! -" call Decho("style=5: Vexplore!",'~'.expand("")) let winsz= (winsz > 0)? (winsz*winwidth(0))/100 : -winsz if winsz == 0|let winsz= ""|endif - exe "keepalt noswapfile rightb ".winsz."wincmd v" -" call Decho("exe keepalt noswapfile rightb ".winsz."wincmd v",'~'.expand("")) + exe "keepalt noswapfile ".(!g:netrw_altv ? "rightbelow " : "leftabove ").winsz."wincmd v" elseif a:style == 6 " Texplore call s:SaveBufVars() -" call Decho("style = 6: Texplore",'~'.expand("")) exe "keepalt tabnew ".fnameescape(curdir) -" call Decho("exe keepalt tabnew ".fnameescape(curdir),'~'.expand("")) call s:RestoreBufVars() endif call s:RestoreWinVars() -" else " Decho -" call Decho("case a:dosplit=".a:dosplit." AND modified=".&modified." AND a:style=".a:style." is not 6",'~'.expand("")) endif NetrwKeepj norm! 0 @@ -11544,7 +11528,6 @@ fun! s:StripTrailingSlash(path) return substitute(a:path, '[/\\]$', '', 'g') endfun - " --------------------------------------------------------------------- " s:NetrwBadd: adds marked files to buffer list or vice versa {{{2 " cb : bl2mf=0 add marked files to buffer list -- cgit From be9eaac7e8ee9961ffe1e5d5d25dfc3b7a83ba57 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sun, 4 Aug 2024 18:59:34 +0200 Subject: vim-patch:c5bdd66: runtime(zip): escape '[' on Unix as well Problem: After 6f1cbfc9ab483a09877e153ad130164875c40b1d fnameescape() is no longer called on the name of the file to be extracted. However, while spaces indeed don't need to be escaped, unzip treats '[' as a wildcard character, so it need to be escaped. Solution: Escape '[' on both MS-Windows and Unix. From the docs it seems '*' and '?' also need escaping, but they seem to actually work without escaping. fixes: neovim/neovim#29977 closes: vim/vim#15427 https://github.com/vim/vim/commit/c5bdd66558b14f04424a22d9714a9b7d0c277dac Co-authored-by: zeertzjq --- runtime/autoload/zip.vim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/zip.vim b/runtime/autoload/zip.vim index f77d729f03..e8973e3c80 100644 --- a/runtime/autoload/zip.vim +++ b/runtime/autoload/zip.vim @@ -9,6 +9,7 @@ " 2024 Jul 23 by Vim Project: fix 'x' command " 2024 Jul 24 by Vim Project: use delete() function " 2024 Jul 20 by Vim Project: fix opening remote zipfile +" 2024 Aug 04 by Vim Project: escape '[' in name of file to be extracted " License: Vim License (see vim's :help license) " Copyright: Copyright (C) 2005-2019 Charles E. Campbell {{{1 " Permission is hereby granted to use and distribute this code, @@ -218,8 +219,8 @@ fun! zip#Read(fname,mode) else let zipfile = substitute(a:fname,'^.\{-}zipfile://\(.\{-}\)::[^\\].*$','\1','') let fname = substitute(a:fname,'^.\{-}zipfile://.\{-}::\([^\\].*\)$','\1','') - let fname = substitute(fname, '[', '[[]', 'g') endif + let fname = substitute(fname, '[', '[[]', 'g') " sanity check if !executable(substitute(g:zip_unzipcmd,'\s\+.*$','','')) redraw! @@ -230,7 +231,7 @@ fun! zip#Read(fname,mode) endif " the following code does much the same thing as - " exe "keepj sil! r! ".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fnameescape(fname),1) + " exe "keepj sil! r! ".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fname,1) " but allows zipfile://... entries in quickfix lists let temp = tempname() let fn = expand('%:p') -- cgit From 6f5b904fb2481f910ef0c186280fb5d5c2cc0d70 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 6 Aug 2024 06:47:38 +0800 Subject: vim-patch:f0e9b72: runtime(zip): Fix for FreeBSD's unzip command Problem: Cannot browse zipfiles with the unzip program found on FreeBSD. Solution: Adjust command arguments. Unzip found on FreeBSD complain about missing argument with the zipinfo modifier '-Z -1'. Joining arguments seems to work for both implementations. Also change `:sil!` to `:sil` so that error messages are properly reported (per review of Christian Brabandt). related: vim/vim#15411 https://github.com/vim/vim/commit/f0e9b72c8fdd47b9b410a11edf7479953cb2aed9 Co-authored-by: Damien <141588647+xrandomname@users.noreply.github.com> --- runtime/autoload/zip.vim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/zip.vim b/runtime/autoload/zip.vim index e8973e3c80..8876ef08e6 100644 --- a/runtime/autoload/zip.vim +++ b/runtime/autoload/zip.vim @@ -1,6 +1,6 @@ " zip.vim: Handles browsing zipfiles " AUTOLOAD PORTION -" Date: Jul 30, 2024 +" Date: Aug 05, 2024 " Version: 33 " Maintainer: This runtime file is looking for a new maintainer. " Former Maintainer: Charles E Campbell @@ -8,8 +8,9 @@ " 2024 Jun 16 by Vim Project: handle whitespace on Windows properly (#14998) " 2024 Jul 23 by Vim Project: fix 'x' command " 2024 Jul 24 by Vim Project: use delete() function -" 2024 Jul 20 by Vim Project: fix opening remote zipfile +" 2024 Jul 30 by Vim Project: fix opening remote zipfile " 2024 Aug 04 by Vim Project: escape '[' in name of file to be extracted +" 2024 Aug 05 by Vim Project: workaround for the FreeBSD's unzip " License: Vim License (see vim's :help license) " Copyright: Copyright (C) 2005-2019 Charles E. Campbell {{{1 " Permission is hereby granted to use and distribute this code, @@ -131,8 +132,7 @@ fun! zip#Browse(zipfile) \ '" Select a file with cursor and press ENTER']) keepj $ -" call Decho("exe silent r! ".g:zip_unzipcmd." -l -- ".s:Escape(a:zipfile,1)) - exe "keepj sil! r! ".g:zip_unzipcmd." -Z -1 -- ".s:Escape(a:zipfile,1) + exe $"keepj sil r! {g:zip_unzipcmd} -Z1 -- {s:Escape(a:zipfile, 1)}" if v:shell_error != 0 redraw! echohl WarningMsg | echo "***warning*** (zip#Browse) ".fnameescape(a:zipfile)." is not a zip file" | echohl None @@ -235,7 +235,7 @@ fun! zip#Read(fname,mode) " but allows zipfile://... entries in quickfix lists let temp = tempname() let fn = expand('%:p') - exe "sil! !".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fname,1).' > '.temp + exe "sil !".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fname,1).' > '.temp sil exe 'keepalt file '.temp sil keepj e! sil exe 'keepalt file '.fnameescape(fn) -- cgit From 0bf9a574b5e3d738f323c497d7360f84e9c940c0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 7 Aug 2024 07:05:58 +0800 Subject: vim-patch:a63f66e: runtime(zip): clean up and remove comments Problem: zip plugin contains a lot of comments from the decho plugin Solution: Clean up and remove un-used comments https://github.com/vim/vim/commit/a63f66e953d811bb6d044e92fe338e533ad94ff5 Co-authored-by: Christian Brabandt --- runtime/autoload/zip.vim | 46 +--------------------------------------------- 1 file changed, 1 insertion(+), 45 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/zip.vim b/runtime/autoload/zip.vim index 8876ef08e6..de88b55907 100644 --- a/runtime/autoload/zip.vim +++ b/runtime/autoload/zip.vim @@ -11,6 +11,7 @@ " 2024 Jul 30 by Vim Project: fix opening remote zipfile " 2024 Aug 04 by Vim Project: escape '[' in name of file to be extracted " 2024 Aug 05 by Vim Project: workaround for the FreeBSD's unzip +" 2024 Aug 05 by Vim Project: clean-up and make it work with shellslash on Windows " License: Vim License (see vim's :help license) " Copyright: Copyright (C) 2005-2019 Charles E. Campbell {{{1 " Permission is hereby granted to use and distribute this code, @@ -36,7 +37,6 @@ if v:version < 702 endif let s:keepcpo= &cpo set cpo&vim -"DechoTabOn let s:zipfile_escape = ' ?&;\' let s:ERROR = 2 @@ -136,14 +136,12 @@ fun! zip#Browse(zipfile) if v:shell_error != 0 redraw! echohl WarningMsg | echo "***warning*** (zip#Browse) ".fnameescape(a:zipfile)." is not a zip file" | echohl None -" call inputsave()|call input("Press to continue")|call inputrestore() keepj sil! %d let eikeep= &ei set ei=BufReadCmd,FileReadCmd exe "keepj r ".fnameescape(a:zipfile) let &ei= eikeep keepj 1d -" call Dret("zip#Browse") return endif @@ -156,55 +154,43 @@ fun! zip#Browse(zipfile) endif let &report= repkeep -" call Dret("zip#Browse") endfun " --------------------------------------------------------------------- " ZipBrowseSelect: {{{2 fun! s:ZipBrowseSelect() - " call Dfunc("ZipBrowseSelect() zipfile<".((exists("b:zipfile"))? b:zipfile : "n/a")."> curfile<".expand("%").">") let repkeep= &report set report=10 let fname= getline(".") if !exists("b:zipfile") -" call Dret("ZipBrowseSelect : b:zipfile doesn't exist!") return endif " sanity check if fname =~ '^"' let &report= repkeep -" call Dret("ZipBrowseSelect") return endif if fname =~ '/$' redraw! echohl Error | echo "***error*** (zip#Browse) Please specify a file, not a directory" | echohl None -" call inputsave()|call input("Press to continue")|call inputrestore() let &report= repkeep -" call Dret("ZipBrowseSelect") return endif -" call Decho("fname<".fname.">") - " get zipfile to the new-window let zipfile = b:zipfile let curfile = expand("%") -" call Decho("zipfile<".zipfile.">") -" call Decho("curfile<".curfile.">") noswapfile new if !exists("g:zip_nomax") || g:zip_nomax == 0 wincmd _ endif let s:zipfile_{winnr()}= curfile -" call Decho("exe e ".fnameescape("zipfile://".zipfile.'::'.fname)) exe "noswapfile e ".fnameescape("zipfile://".zipfile.'::'.fname) filetype detect let &report= repkeep -" call Dret("ZipBrowseSelect : s:zipfile_".winnr()."<".s:zipfile_{winnr()}.">") endfun " --------------------------------------------------------------------- @@ -225,7 +211,6 @@ fun! zip#Read(fname,mode) if !executable(substitute(g:zip_unzipcmd,'\s\+.*$','','')) redraw! echohl Error | echo "***error*** (zip#Read) sorry, your system doesn't appear to have the ".g:zip_unzipcmd." program" | echohl None -" call inputsave()|call input("Press to continue")|call inputrestore() let &report= repkeep return endif @@ -252,7 +237,6 @@ endfun " --------------------------------------------------------------------- " zip#Write: {{{2 fun! zip#Write(fname) -" call Dfunc("zip#Write(fname<".a:fname.">) zipfile_".winnr()."<".s:zipfile_{winnr()}.">") let repkeep= &report set report=10 @@ -260,36 +244,28 @@ fun! zip#Write(fname) if !executable(substitute(g:zip_zipcmd,'\s\+.*$','','')) redraw! echohl Error | echo "***error*** (zip#Write) sorry, your system doesn't appear to have the ".g:zip_zipcmd." program" | echohl None -" call inputsave()|call input("Press to continue")|call inputrestore() let &report= repkeep -" call Dret("zip#Write") return endif if !exists("*mkdir") redraw! echohl Error | echo "***error*** (zip#Write) sorry, mkdir() doesn't work on your system" | echohl None -" call inputsave()|call input("Press to continue")|call inputrestore() let &report= repkeep -" call Dret("zip#Write") return endif let curdir= getcwd() let tmpdir= tempname() -" call Decho("orig tempname<".tmpdir.">") if tmpdir =~ '\.' let tmpdir= substitute(tmpdir,'\.[^.]*$','','e') endif -" call Decho("tmpdir<".tmpdir.">") call mkdir(tmpdir,"p") " attempt to change to the indicated directory if s:ChgDir(tmpdir,s:ERROR,"(zip#Write) cannot cd to temporary directory") let &report= repkeep -" call Dret("zip#Write") return endif -" call Decho("current directory now: ".getcwd()) " place temporary files under .../_ZIPVIM_/ if isdirectory("_ZIPVIM_") @@ -297,7 +273,6 @@ fun! zip#Write(fname) endif call mkdir("_ZIPVIM_") cd _ZIPVIM_ -" call Decho("current directory now: ".getcwd()) if has("unix") let zipfile = substitute(a:fname,'zipfile://\(.\{-}\)::[^\\].*$','\1','') @@ -306,21 +281,17 @@ fun! zip#Write(fname) let zipfile = substitute(a:fname,'^.\{-}zipfile://\(.\{-}\)::[^\\].*$','\1','') let fname = substitute(a:fname,'^.\{-}zipfile://.\{-}::\([^\\].*\)$','\1','') endif -" call Decho("zipfile<".zipfile.">") -" call Decho("fname <".fname.">") if fname =~ '/' let dirpath = substitute(fname,'/[^/]\+$','','e') if has("win32unix") && executable("cygpath") let dirpath = substitute(system("cygpath ".s:Escape(dirpath,0)),'\n','','e') endif -" call Decho("mkdir(dirpath<".dirpath.">,p)") call mkdir(dirpath,"p") endif if zipfile !~ '/' let zipfile= curdir.'/'.zipfile endif -" call Decho("zipfile<".zipfile."> fname<".fname.">") exe "w! ".fnameescape(fname) if has("win32unix") && executable("cygpath") @@ -331,17 +302,14 @@ fun! zip#Write(fname) let fname = substitute(fname, '[', '[[]', 'g') endif -" call Decho(g:zip_zipcmd." -u ".s:Escape(fnamemodify(zipfile,":p"),0)." ".s:Escape(fname,0)) call system(g:zip_zipcmd." -u ".s:Escape(fnamemodify(zipfile,":p"),0)." ".s:Escape(fname,0)) if v:shell_error != 0 redraw! echohl Error | echo "***error*** (zip#Write) sorry, unable to update ".zipfile." with ".fname | echohl None -" call inputsave()|call input("Press to continue")|call inputrestore() elseif s:zipfile_{winnr()} =~ '^\a\+://' " support writing zipfiles across a network let netzipfile= s:zipfile_{winnr()} -" call Decho("handle writing <".zipfile."> across network as <".netzipfile.">") 1split|enew let binkeep= &binary let eikeep = &ei @@ -362,36 +330,30 @@ fun! zip#Write(fname) setlocal nomod let &report= repkeep -" call Dret("zip#Write") endfun " --------------------------------------------------------------------- " zip#Extract: extract a file from a zip archive {{{2 fun! zip#Extract() -" call Dfunc("zip#Extract()") let repkeep= &report set report=10 let fname= getline(".") -" call Decho("fname<".fname.">") " sanity check if fname =~ '^"' let &report= repkeep -" call Dret("zip#Extract") return endif if fname =~ '/$' redraw! echohl Error | echo "***error*** (zip#Extract) Please specify a file, not a directory" | echohl None let &report= repkeep -" call Dret("zip#Extract") return endif " extract the file mentioned under the cursor call system($"{g:zip_extractcmd} {shellescape(b:zipfile)} {shellescape(fname)}") -" call Decho("zipfile<".b:zipfile.">") if v:shell_error != 0 echohl Error | echo "***error*** ".g:zip_extractcmd." ".b:zipfile." ".fname.": failed!" | echohl NONE elseif !filereadable(fname) @@ -403,7 +365,6 @@ fun! zip#Extract() " restore option let &report= repkeep -" call Dret("zip#Extract") endfun " --------------------------------------------------------------------- @@ -428,8 +389,6 @@ endfun " --------------------------------------------------------------------- " ChgDir: {{{2 fun! s:ChgDir(newdir,errlvl,errmsg) -" call Dfunc("ChgDir(newdir<".a:newdir."> errlvl=".a:errlvl." errmsg<".a:errmsg.">)") - try exe "cd ".fnameescape(a:newdir) catch /^Vim\%((\a\+)\)\=:E344/ @@ -441,12 +400,9 @@ fun! s:ChgDir(newdir,errlvl,errmsg) elseif a:errlvl == s:ERROR echohl Error | echo "***error*** ".a:errmsg | echohl NONE endif -" call inputsave()|call input("Press to continue")|call inputrestore() -" call Dret("ChgDir 1") return 1 endtry -" call Dret("ChgDir 0") return 0 endfun -- cgit From 303b3e153d5786fa53c7e5b8bdde3b1c7c318b5e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 7 Aug 2024 07:06:27 +0800 Subject: vim-patch:120c0dd: runtime(zip): use :echomsg instead of :echo Problem: zip plugin uses :echo which does not store messages Solution: use :echomsg instead of :echo so that messages are stored in the message history https://github.com/vim/vim/commit/120c0dd815fa3b44df0fa477f7f3313e4a69c652 Co-authored-by: Christian Brabandt --- runtime/autoload/zip.vim | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/zip.vim b/runtime/autoload/zip.vim index de88b55907..d22e2e0141 100644 --- a/runtime/autoload/zip.vim +++ b/runtime/autoload/zip.vim @@ -31,7 +31,7 @@ endif let g:loaded_zip= "v33" if v:version < 702 echohl WarningMsg - echo "***warning*** this version of zip needs vim 7.2 or later" + echomsg "***warning*** this version of zip needs vim 7.2 or later" echohl Normal finish endif @@ -95,7 +95,7 @@ fun! zip#Browse(zipfile) endif if !executable(g:zip_unzipcmd) redraw! - echohl Error | echo "***error*** (zip#Browse) unzip not available on your system" + echohl Error | echomsg "***error*** (zip#Browse) unzip not available on your system" let &report= repkeep return endif @@ -103,7 +103,7 @@ fun! zip#Browse(zipfile) if a:zipfile !~# '^\a\+://' " if it's an url, don't complain, let url-handlers such as vim do its thing redraw! - echohl Error | echo "***error*** (zip#Browse) File not readable<".a:zipfile.">" | echohl None + echohl Error | echomsg "***error*** (zip#Browse) File not readable<".a:zipfile.">" | echohl None endif let &report= repkeep return @@ -135,7 +135,7 @@ fun! zip#Browse(zipfile) exe $"keepj sil r! {g:zip_unzipcmd} -Z1 -- {s:Escape(a:zipfile, 1)}" if v:shell_error != 0 redraw! - echohl WarningMsg | echo "***warning*** (zip#Browse) ".fnameescape(a:zipfile)." is not a zip file" | echohl None + echohl WarningMsg | echomsg "***warning*** (zip#Browse) ".fnameescape(a:zipfile)." is not a zip file" | echohl None keepj sil! %d let eikeep= &ei set ei=BufReadCmd,FileReadCmd @@ -173,7 +173,7 @@ fun! s:ZipBrowseSelect() endif if fname =~ '/$' redraw! - echohl Error | echo "***error*** (zip#Browse) Please specify a file, not a directory" | echohl None + echohl Error | echomsg "***error*** (zip#Browse) Please specify a file, not a directory" | echohl None let &report= repkeep return endif @@ -210,7 +210,7 @@ fun! zip#Read(fname,mode) " sanity check if !executable(substitute(g:zip_unzipcmd,'\s\+.*$','','')) redraw! - echohl Error | echo "***error*** (zip#Read) sorry, your system doesn't appear to have the ".g:zip_unzipcmd." program" | echohl None + echohl Error | echomsg "***error*** (zip#Read) sorry, your system doesn't appear to have the ".g:zip_unzipcmd." program" | echohl None let &report= repkeep return endif @@ -243,13 +243,13 @@ fun! zip#Write(fname) " sanity checks if !executable(substitute(g:zip_zipcmd,'\s\+.*$','','')) redraw! - echohl Error | echo "***error*** (zip#Write) sorry, your system doesn't appear to have the ".g:zip_zipcmd." program" | echohl None + echohl Error | echomsg "***error*** (zip#Write) sorry, your system doesn't appear to have the ".g:zip_zipcmd." program" | echohl None let &report= repkeep return endif if !exists("*mkdir") redraw! - echohl Error | echo "***error*** (zip#Write) sorry, mkdir() doesn't work on your system" | echohl None + echohl Error | echomsg "***error*** (zip#Write) sorry, mkdir() doesn't work on your system" | echohl None let &report= repkeep return endif @@ -305,7 +305,7 @@ fun! zip#Write(fname) call system(g:zip_zipcmd." -u ".s:Escape(fnamemodify(zipfile,":p"),0)." ".s:Escape(fname,0)) if v:shell_error != 0 redraw! - echohl Error | echo "***error*** (zip#Write) sorry, unable to update ".zipfile." with ".fname | echohl None + echohl Error | echomsg "***error*** (zip#Write) sorry, unable to update ".zipfile." with ".fname | echohl None elseif s:zipfile_{winnr()} =~ '^\a\+://' " support writing zipfiles across a network @@ -347,7 +347,7 @@ fun! zip#Extract() endif if fname =~ '/$' redraw! - echohl Error | echo "***error*** (zip#Extract) Please specify a file, not a directory" | echohl None + echohl Error | echomsg "***error*** (zip#Extract) Please specify a file, not a directory" | echohl None let &report= repkeep return endif @@ -355,11 +355,11 @@ fun! zip#Extract() " extract the file mentioned under the cursor call system($"{g:zip_extractcmd} {shellescape(b:zipfile)} {shellescape(fname)}") if v:shell_error != 0 - echohl Error | echo "***error*** ".g:zip_extractcmd." ".b:zipfile." ".fname.": failed!" | echohl NONE + echohl Error | echomsg "***error*** ".g:zip_extractcmd." ".b:zipfile." ".fname.": failed!" | echohl NONE elseif !filereadable(fname) - echohl Error | echo "***error*** attempted to extract ".fname." but it doesn't appear to be present!" + echohl Error | echomsg "***error*** attempted to extract ".fname." but it doesn't appear to be present!" else - echo "***note*** successfully extracted ".fname + echomsg "***note*** successfully extracted ".fname endif " restore option @@ -394,11 +394,11 @@ fun! s:ChgDir(newdir,errlvl,errmsg) catch /^Vim\%((\a\+)\)\=:E344/ redraw! if a:errlvl == s:NOTE - echo "***note*** ".a:errmsg + echomsg "***note*** ".a:errmsg elseif a:errlvl == s:WARNING - echohl WarningMsg | echo "***warning*** ".a:errmsg | echohl NONE + echohl WarningMsg | echomsg "***warning*** ".a:errmsg | echohl NONE elseif a:errlvl == s:ERROR - echohl Error | echo "***error*** ".a:errmsg | echohl NONE + echohl Error | echomsg "***error*** ".a:errmsg | echohl NONE endif return 1 endtry -- cgit From 11c57c25ef9b413088014cdb23636a440cd917c2 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 7 Aug 2024 07:07:03 +0800 Subject: vim-patch:33836d3: runtime(zip): remove test for fnameescape Problem: zip plugin tests for fnameescape() function Solution: Remove the check, fnameescape() has been available since 7.1.299, it should nowadays always be available https://github.com/vim/vim/commit/33836d38b82aa926a2a2b3f945a0139f373f7e56 Co-authored-by: Christian Brabandt --- runtime/autoload/zip.vim | 6 ------ 1 file changed, 6 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/zip.vim b/runtime/autoload/zip.vim index d22e2e0141..cf70135186 100644 --- a/runtime/autoload/zip.vim +++ b/runtime/autoload/zip.vim @@ -87,12 +87,6 @@ fun! zip#Browse(zipfile) set report=10 " sanity checks - if !exists("*fnameescape") - if &verbose > 1 - echoerr "the zip plugin is not available (your vim doesn't support fnameescape())" - endif - return - endif if !executable(g:zip_unzipcmd) redraw! echohl Error | echomsg "***error*** (zip#Browse) unzip not available on your system" -- cgit From 92981c8e0bea4a2ef23665df61aa820ed0a23eb3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 7 Aug 2024 07:07:29 +0800 Subject: vim-patch:19636be: runtime(zip): refactor save and restore of options Problem: zip plugin has no way to set/restore option values Solution: Add the SetSaneOpts() and RestoreOpts() functions, so options that cause issues are set to sane values and restored back to their initial values later on. (this affects the 'shellslash' option on windows, which also changes how the shellescape() function works) https://github.com/vim/vim/commit/19636be55e023cb726389107e9e7d62049b6fd58 Co-authored-by: Christian Brabandt --- runtime/autoload/zip.vim | 74 ++++++++++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 30 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/zip.vim b/runtime/autoload/zip.vim index cf70135186..7e833fe5ad 100644 --- a/runtime/autoload/zip.vim +++ b/runtime/autoload/zip.vim @@ -83,14 +83,13 @@ fun! zip#Browse(zipfile) return endif - let repkeep= &report - set report=10 + let dict = s:SetSaneOpts() " sanity checks if !executable(g:zip_unzipcmd) redraw! echohl Error | echomsg "***error*** (zip#Browse) unzip not available on your system" - let &report= repkeep + call s:RestoreOpts(dict) return endif if !filereadable(a:zipfile) @@ -99,7 +98,7 @@ fun! zip#Browse(zipfile) redraw! echohl Error | echomsg "***error*** (zip#Browse) File not readable<".a:zipfile.">" | echohl None endif - let &report= repkeep + call s:RestoreOpts(dict) return endif if &ma != 1 @@ -136,6 +135,7 @@ fun! zip#Browse(zipfile) exe "keepj r ".fnameescape(a:zipfile) let &ei= eikeep keepj 1d + call s:RestoreOpts(dict) return endif @@ -147,28 +147,28 @@ fun! zip#Browse(zipfile) noremap :call ZipBrowseSelect() endif - let &report= repkeep + call s:RestoreOpts(dict) endfun " --------------------------------------------------------------------- " ZipBrowseSelect: {{{2 fun! s:ZipBrowseSelect() - let repkeep= &report - set report=10 + let dict = s:SetSaneOpts() let fname= getline(".") if !exists("b:zipfile") + call s:RestoreOpts(dict) return endif " sanity check if fname =~ '^"' - let &report= repkeep + call s:RestoreOpts(dict) return endif if fname =~ '/$' redraw! echohl Error | echomsg "***error*** (zip#Browse) Please specify a file, not a directory" | echohl None - let &report= repkeep + call s:RestoreOpts(dict) return endif @@ -184,14 +184,13 @@ fun! s:ZipBrowseSelect() exe "noswapfile e ".fnameescape("zipfile://".zipfile.'::'.fname) filetype detect - let &report= repkeep + call s:RestoreOpts(dict) endfun " --------------------------------------------------------------------- " zip#Read: {{{2 fun! zip#Read(fname,mode) - let repkeep= &report - set report=10 + let dict = s:SetSaneOpts() if has("unix") let zipfile = substitute(a:fname,'zipfile://\(.\{-}\)::[^\\].*$','\1','') @@ -205,7 +204,7 @@ fun! zip#Read(fname,mode) if !executable(substitute(g:zip_unzipcmd,'\s\+.*$','','')) redraw! echohl Error | echomsg "***error*** (zip#Read) sorry, your system doesn't appear to have the ".g:zip_unzipcmd." program" | echohl None - let &report= repkeep + call s:RestoreOpts(dict) return endif @@ -225,26 +224,25 @@ fun! zip#Read(fname,mode) " cleanup set nomod - let &report= repkeep + call s:RestoreOpts(dict) endfun " --------------------------------------------------------------------- " zip#Write: {{{2 fun! zip#Write(fname) - let repkeep= &report - set report=10 + let dict = s:SetSaneOpts() " sanity checks if !executable(substitute(g:zip_zipcmd,'\s\+.*$','','')) redraw! echohl Error | echomsg "***error*** (zip#Write) sorry, your system doesn't appear to have the ".g:zip_zipcmd." program" | echohl None - let &report= repkeep + call s:RestoreOpts(dict) return endif if !exists("*mkdir") redraw! echohl Error | echomsg "***error*** (zip#Write) sorry, mkdir() doesn't work on your system" | echohl None - let &report= repkeep + call s:RestoreOpts(dict) return endif @@ -257,7 +255,7 @@ fun! zip#Write(fname) " attempt to change to the indicated directory if s:ChgDir(tmpdir,s:ERROR,"(zip#Write) cannot cd to temporary directory") - let &report= repkeep + call s:RestoreOpts(dict) return endif @@ -323,26 +321,25 @@ fun! zip#Write(fname) call delete(tmpdir, "rf") setlocal nomod - let &report= repkeep + call s:RestoreOpts(dict) endfun " --------------------------------------------------------------------- " zip#Extract: extract a file from a zip archive {{{2 fun! zip#Extract() - let repkeep= &report - set report=10 + let dict = s:SetSaneOpts() let fname= getline(".") " sanity check if fname =~ '^"' - let &report= repkeep + call s:RestoreOpts(dict) return endif if fname =~ '/$' redraw! echohl Error | echomsg "***error*** (zip#Extract) Please specify a file, not a directory" | echohl None - let &report= repkeep + call s:RestoreOpts(dict) return endif @@ -357,7 +354,7 @@ fun! zip#Extract() endif " restore option - let &report= repkeep + call s:RestoreOpts(dict) endfun @@ -373,15 +370,11 @@ fun! s:Escape(fname,isfilt) else let qnameq= g:zip_shq.escape(a:fname,g:zip_shq).g:zip_shq endif - if exists("+shellslash") && &shellslash && &shell =~ "cmd.exe" - " renormalize directory separator on Windows - let qnameq=substitute(qnameq, '/', '\\', 'g') - endif return qnameq endfun " --------------------------------------------------------------------- -" ChgDir: {{{2 +" s:ChgDir: {{{2 fun! s:ChgDir(newdir,errlvl,errmsg) try exe "cd ".fnameescape(a:newdir) @@ -400,6 +393,27 @@ fun! s:ChgDir(newdir,errlvl,errmsg) return 0 endfun +" --------------------------------------------------------------------- +" s:SetSaneOpts: {{{2 +fun! s:SetSaneOpts() + let dict = {} + let dict.report = &report + let dict.shellslash = &shellslash + + let &report = 10 + let &shellslash = 0 + + return dict +endfun + +" --------------------------------------------------------------------- +" s:RestoreOpts: {{{2 +fun! s:RestoreOpts(dict) + for [key, val] in items(a:dict) + exe $"let &{key} = {val}" + endfor +endfun + " ------------------------------------------------------------------------ " Modelines And Restoration: {{{1 let &cpo= s:keepcpo -- cgit From 025920b330c4dc14ef1df780794cf27a4e504e94 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 7 Aug 2024 07:10:41 +0800 Subject: vim-patch:a336d8f: runtime(zip): increment base version of zip plugin Problem: the zip plugin version is still v33 Solution: increment the version to v34 https://github.com/vim/vim/commit/a336d8f21e4cce877e23d47db238801a5a406992 Co-authored-by: Christian Brabandt --- runtime/autoload/zip.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/zip.vim b/runtime/autoload/zip.vim index 7e833fe5ad..5e56086484 100644 --- a/runtime/autoload/zip.vim +++ b/runtime/autoload/zip.vim @@ -1,7 +1,7 @@ " zip.vim: Handles browsing zipfiles " AUTOLOAD PORTION " Date: Aug 05, 2024 -" Version: 33 +" Version: 34 " Maintainer: This runtime file is looking for a new maintainer. " Former Maintainer: Charles E Campbell " Last Change: @@ -28,7 +28,7 @@ if &cp || exists("g:loaded_zip") finish endif -let g:loaded_zip= "v33" +let g:loaded_zip= "v34" if v:version < 702 echohl WarningMsg echomsg "***warning*** this version of zip needs vim 7.2 or later" -- cgit From 221c489edd40e3c9042503e501596ac9fa8e38dc Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 7 Aug 2024 07:11:11 +0800 Subject: vim-patch:8d52926: runtime(zip): add a generic Message function Problem: the zip plugin duplicates a lot of code for displaying warnings/errors Solution: refactor common code into a generic Mess() function https://github.com/vim/vim/commit/8d52926857ec7f08a9bee8f96470748cecf58002 Co-authored-by: Christian Brabandt --- runtime/autoload/zip.vim | 57 ++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 29 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/zip.vim b/runtime/autoload/zip.vim index 5e56086484..ced3a57c20 100644 --- a/runtime/autoload/zip.vim +++ b/runtime/autoload/zip.vim @@ -29,12 +29,6 @@ if &cp || exists("g:loaded_zip") finish endif let g:loaded_zip= "v34" -if v:version < 702 - echohl WarningMsg - echomsg "***warning*** this version of zip needs vim 7.2 or later" - echohl Normal - finish -endif let s:keepcpo= &cpo set cpo&vim @@ -64,8 +58,22 @@ if !exists("g:zip_extractcmd") let g:zip_extractcmd= g:zip_unzipcmd endif +" --------------------------------------------------------------------- +" required early +" s:Mess: {{{2 +fun! s:Mess(group, msg) + redraw! + exe "echohl " . a:group + echomsg a:msg + echohl Normal +endfun + +if v:version < 702 + call s:Mess('WarningMsg', "***warning*** this version of zip needs vim 7.2 or later") + finish +endif if !dist#vim#IsSafeExecutable('zip', g:zip_unzipcmd) - echoerr "Warning: NOT executing " .. g:zip_unzipcmd .. " from current directory!" + call s:Mess('Error', "Warning: NOT executing " .. g:zip_unzipcmd .. " from current directory!") finish endif @@ -87,16 +95,14 @@ fun! zip#Browse(zipfile) " sanity checks if !executable(g:zip_unzipcmd) - redraw! - echohl Error | echomsg "***error*** (zip#Browse) unzip not available on your system" + call s:Mess('Error', "***error*** (zip#Browse) unzip not available on your system") call s:RestoreOpts(dict) return endif if !filereadable(a:zipfile) if a:zipfile !~# '^\a\+://' " if it's an url, don't complain, let url-handlers such as vim do its thing - redraw! - echohl Error | echomsg "***error*** (zip#Browse) File not readable<".a:zipfile.">" | echohl None + call s:Mess('Error', "***error*** (zip#Browse) File not readable <".a:zipfile.">") endif call s:RestoreOpts(dict) return @@ -127,8 +133,7 @@ fun! zip#Browse(zipfile) exe $"keepj sil r! {g:zip_unzipcmd} -Z1 -- {s:Escape(a:zipfile, 1)}" if v:shell_error != 0 - redraw! - echohl WarningMsg | echomsg "***warning*** (zip#Browse) ".fnameescape(a:zipfile)." is not a zip file" | echohl None + call s:Mess('WarningMsg', "***warning*** (zip#Browse) ".fnameescape(a:zipfile)." is not a zip file") keepj sil! %d let eikeep= &ei set ei=BufReadCmd,FileReadCmd @@ -166,8 +171,7 @@ fun! s:ZipBrowseSelect() return endif if fname =~ '/$' - redraw! - echohl Error | echomsg "***error*** (zip#Browse) Please specify a file, not a directory" | echohl None + call s:Mess('Error', "***error*** (zip#Browse) Please specify a file, not a directory") call s:RestoreOpts(dict) return endif @@ -202,8 +206,7 @@ fun! zip#Read(fname,mode) let fname = substitute(fname, '[', '[[]', 'g') " sanity check if !executable(substitute(g:zip_unzipcmd,'\s\+.*$','','')) - redraw! - echohl Error | echomsg "***error*** (zip#Read) sorry, your system doesn't appear to have the ".g:zip_unzipcmd." program" | echohl None + call s:Mess('Error', "***error*** (zip#Read) sorry, your system doesn't appear to have the ".g:zip_unzipcmd." program") call s:RestoreOpts(dict) return endif @@ -234,14 +237,12 @@ fun! zip#Write(fname) " sanity checks if !executable(substitute(g:zip_zipcmd,'\s\+.*$','','')) - redraw! - echohl Error | echomsg "***error*** (zip#Write) sorry, your system doesn't appear to have the ".g:zip_zipcmd." program" | echohl None + call s:Mess('Error', "***error*** (zip#Write) sorry, your system doesn't appear to have the ".g:zip_zipcmd." program") call s:RestoreOpts(dict) return endif if !exists("*mkdir") - redraw! - echohl Error | echomsg "***error*** (zip#Write) sorry, mkdir() doesn't work on your system" | echohl None + call s:Mess('Error', "***error*** (zip#Write) sorry, mkdir() doesn't work on your system") call s:RestoreOpts(dict) return endif @@ -296,8 +297,7 @@ fun! zip#Write(fname) call system(g:zip_zipcmd." -u ".s:Escape(fnamemodify(zipfile,":p"),0)." ".s:Escape(fname,0)) if v:shell_error != 0 - redraw! - echohl Error | echomsg "***error*** (zip#Write) sorry, unable to update ".zipfile." with ".fname | echohl None + call s:Mess('Error', "***error*** (zip#Write) sorry, unable to update ".zipfile." with ".fname) elseif s:zipfile_{winnr()} =~ '^\a\+://' " support writing zipfiles across a network @@ -337,8 +337,7 @@ fun! zip#Extract() return endif if fname =~ '/$' - redraw! - echohl Error | echomsg "***error*** (zip#Extract) Please specify a file, not a directory" | echohl None + call s:Mess('Error', "***error*** (zip#Extract) Please specify a file, not a directory") call s:RestoreOpts(dict) return endif @@ -346,9 +345,9 @@ fun! zip#Extract() " extract the file mentioned under the cursor call system($"{g:zip_extractcmd} {shellescape(b:zipfile)} {shellescape(fname)}") if v:shell_error != 0 - echohl Error | echomsg "***error*** ".g:zip_extractcmd." ".b:zipfile." ".fname.": failed!" | echohl NONE + call s:Mess('Error', "***error*** ".g:zip_extractcmd." ".b:zipfile." ".fname.": failed!") elseif !filereadable(fname) - echohl Error | echomsg "***error*** attempted to extract ".fname." but it doesn't appear to be present!" + call s:Mess('Error', "***error*** attempted to extract ".fname." but it doesn't appear to be present!") else echomsg "***note*** successfully extracted ".fname endif @@ -383,9 +382,9 @@ fun! s:ChgDir(newdir,errlvl,errmsg) if a:errlvl == s:NOTE echomsg "***note*** ".a:errmsg elseif a:errlvl == s:WARNING - echohl WarningMsg | echomsg "***warning*** ".a:errmsg | echohl NONE + call s:Mess("WarningMsg", "***warning*** ".a:errmsg) elseif a:errlvl == s:ERROR - echohl Error | echomsg "***error*** ".a:errmsg | echohl NONE + call s:Mess("Error", "***error*** ".a:errmsg) endif return 1 endtry -- cgit From 450d49660f52d915f78da3b0aeb21d9d658f98bd Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 7 Aug 2024 07:15:59 +0800 Subject: vim-patch:afea6b9: runtime(zip): use defer to restore old settings Problem: RestoreOpts() plugin called too often Solution: use :defer to have the RestoreOpts() function called when the function returns automatically https://github.com/vim/vim/commit/afea6b946827e964271eb19579946a7f88d2f329 Co-authored-by: Christian Brabandt --- runtime/autoload/zip.vim | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/zip.vim b/runtime/autoload/zip.vim index ced3a57c20..d0d6863329 100644 --- a/runtime/autoload/zip.vim +++ b/runtime/autoload/zip.vim @@ -92,11 +92,11 @@ fun! zip#Browse(zipfile) endif let dict = s:SetSaneOpts() + defer s:RestoreOpts(dict) " sanity checks if !executable(g:zip_unzipcmd) call s:Mess('Error', "***error*** (zip#Browse) unzip not available on your system") - call s:RestoreOpts(dict) return endif if !filereadable(a:zipfile) @@ -104,7 +104,6 @@ fun! zip#Browse(zipfile) " if it's an url, don't complain, let url-handlers such as vim do its thing call s:Mess('Error', "***error*** (zip#Browse) File not readable <".a:zipfile.">") endif - call s:RestoreOpts(dict) return endif if &ma != 1 @@ -140,7 +139,6 @@ fun! zip#Browse(zipfile) exe "keepj r ".fnameescape(a:zipfile) let &ei= eikeep keepj 1d - call s:RestoreOpts(dict) return endif @@ -152,27 +150,24 @@ fun! zip#Browse(zipfile) noremap :call ZipBrowseSelect() endif - call s:RestoreOpts(dict) endfun " --------------------------------------------------------------------- " ZipBrowseSelect: {{{2 fun! s:ZipBrowseSelect() let dict = s:SetSaneOpts() + defer s:RestoreOpts(dict) let fname= getline(".") if !exists("b:zipfile") - call s:RestoreOpts(dict) return endif " sanity check if fname =~ '^"' - call s:RestoreOpts(dict) return endif if fname =~ '/$' call s:Mess('Error', "***error*** (zip#Browse) Please specify a file, not a directory") - call s:RestoreOpts(dict) return endif @@ -188,13 +183,13 @@ fun! s:ZipBrowseSelect() exe "noswapfile e ".fnameescape("zipfile://".zipfile.'::'.fname) filetype detect - call s:RestoreOpts(dict) endfun " --------------------------------------------------------------------- " zip#Read: {{{2 fun! zip#Read(fname,mode) let dict = s:SetSaneOpts() + defer s:RestoreOpts(dict) if has("unix") let zipfile = substitute(a:fname,'zipfile://\(.\{-}\)::[^\\].*$','\1','') @@ -207,7 +202,6 @@ fun! zip#Read(fname,mode) " sanity check if !executable(substitute(g:zip_unzipcmd,'\s\+.*$','','')) call s:Mess('Error', "***error*** (zip#Read) sorry, your system doesn't appear to have the ".g:zip_unzipcmd." program") - call s:RestoreOpts(dict) return endif @@ -227,23 +221,21 @@ fun! zip#Read(fname,mode) " cleanup set nomod - call s:RestoreOpts(dict) endfun " --------------------------------------------------------------------- " zip#Write: {{{2 fun! zip#Write(fname) let dict = s:SetSaneOpts() + defer s:RestoreOpts(dict) " sanity checks if !executable(substitute(g:zip_zipcmd,'\s\+.*$','','')) call s:Mess('Error', "***error*** (zip#Write) sorry, your system doesn't appear to have the ".g:zip_zipcmd." program") - call s:RestoreOpts(dict) return endif if !exists("*mkdir") call s:Mess('Error', "***error*** (zip#Write) sorry, mkdir() doesn't work on your system") - call s:RestoreOpts(dict) return endif @@ -256,7 +248,6 @@ fun! zip#Write(fname) " attempt to change to the indicated directory if s:ChgDir(tmpdir,s:ERROR,"(zip#Write) cannot cd to temporary directory") - call s:RestoreOpts(dict) return endif @@ -321,7 +312,6 @@ fun! zip#Write(fname) call delete(tmpdir, "rf") setlocal nomod - call s:RestoreOpts(dict) endfun " --------------------------------------------------------------------- @@ -329,16 +319,15 @@ endfun fun! zip#Extract() let dict = s:SetSaneOpts() + defer s:RestoreOpts(dict) let fname= getline(".") " sanity check if fname =~ '^"' - call s:RestoreOpts(dict) return endif if fname =~ '/$' call s:Mess('Error', "***error*** (zip#Extract) Please specify a file, not a directory") - call s:RestoreOpts(dict) return endif @@ -352,9 +341,6 @@ fun! zip#Extract() echomsg "***note*** successfully extracted ".fname endif - " restore option - call s:RestoreOpts(dict) - endfun " --------------------------------------------------------------------- -- cgit From de680775454ac3718637314ceb45be97d64edde4 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sat, 17 Aug 2024 11:35:37 +0200 Subject: vim-patch:7c75411: runtime(netrw): ErrorMsg() may throw E121 Move variables declaration related: vim/vim#15501 https://github.com/vim/vim/commit/7c754110ff8e0d666d422f1644bc356c8fee7392 Co-authored-by: Damien <141588647+xrandomname@users.noreply.github.com> --- runtime/autoload/netrw.vim | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 0a9c13aad9..1042585177 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -20,6 +20,7 @@ " 2024 Jul 23 by Vim Project: escape filename before trying to delete it (#15330) " 2024 Jul 30 by Vim Project: handle mark-copy to same target directory (#12112) " 2024 Aug 02 by Vim Project: honor g:netrw_alt{o,v} for :{S,H,V}explore (#15417) +" 2024 Aug 15 by Vim Project: style changes, prevent E121 (#15501) " }}} " Former Maintainer: Charles E Campbell " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim @@ -63,11 +64,6 @@ if exists("s:needspatches") endif let g:loaded_netrw = "v173" -if !exists("s:NOTE") - let s:NOTE = 0 - let s:WARNING = 1 - let s:ERROR = 2 -endif let s:keepcpo= &cpo setl cpo&vim @@ -221,6 +217,11 @@ if !exists("s:LONGLIST") call s:NetrwInit("s:MAXLIST" ,4) endif +let s:NOTE = 0 +let s:WARNING = 1 +let s:ERROR = 2 +call s:NetrwInit("g:netrw_errorlvl", s:NOTE) + " --------------------------------------------------------------------- " Default option values: {{{2 let g:netrw_localcopycmdopt = "" @@ -346,7 +347,6 @@ call s:NetrwInit("s:didstarstar",0) call s:NetrwInit("g:netrw_dirhistcnt" , 0) call s:NetrwInit("g:netrw_decompress" , '{ ".gz" : "gunzip", ".bz2" : "bunzip2", ".zip" : "unzip", ".tar" : "tar -xf", ".xz" : "unxz" }') call s:NetrwInit("g:netrw_dirhistmax" , 10) -call s:NetrwInit("g:netrw_errorlvl" , s:NOTE) call s:NetrwInit("g:netrw_fastbrowse" , 1) call s:NetrwInit("g:netrw_ftp_browse_reject", '^total\s\+\d\+$\|^Trying\s\+\d\+.*$\|^KERBEROS_V\d rejected\|^Security extensions not\|No such file\|: connect to address [0-9a-fA-F:]*: No route to host$') if !exists("g:netrw_ftp_list_cmd") -- cgit From 68eceb80584ff5cca9ea2a6badbbceccb9151730 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sat, 17 Aug 2024 11:35:59 +0200 Subject: vim-patch:b4d1164: runtime(netrw): Error popup not always used Problem: g:netrw_use_errorwindow=2 does not work without +balloon_eval. Solution: Check for popup_atcursor(). related: vim/vim#15501 https://github.com/vim/vim/commit/b4d11644254ec6e29aed93a9fdcde2160163aefd Co-authored-by: Damien <141588647+xrandomname@users.noreply.github.com> --- runtime/autoload/netrw.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 1042585177..c2950aa076 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -101,7 +101,7 @@ fun! netrw#ErrorMsg(level,msg,errnum) endif " call Decho("level=".level,'~'.expand("")) - if g:netrw_use_errorwindow == 2 && (v:version > 802 || (v:version == 802 && has("patch486"))) + if g:netrw_use_errorwindow == 2 && exists("*popup_atcursor") " use popup window if type(a:msg) == 3 let msg = [level]+a:msg -- cgit From 550ddef36637803ad51c4ba84efaa26c600a1c44 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sat, 17 Aug 2024 11:38:02 +0200 Subject: vim-patch:1fbccc1: runtime(netrw): Drop committed trace lines closes: vim/vim#15501 https://github.com/vim/vim/commit/1fbccc1e9694e5e6162dff112b49a093eac770ee Co-authored-by: Damien <141588647+xrandomname@users.noreply.github.com> --- runtime/autoload/netrw.vim | 51 ---------------------------------------------- 1 file changed, 51 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index c2950aa076..08676884d5 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -12712,54 +12712,3 @@ unlet s:keepcpo " Modelines: {{{1 " =============== " vim:ts=8 fdm=marker -" doing autoload/netrw.vim version v172g ~57 -" varname value=0 ~1 -" varname value=0 ~1 -" varname value=1 ~1 -" varname value=2 ~1 -" varname value=3 ~1 -" varname value=4 ~1 -" varname value=2 ~1 -" varname value=-q -O ~1 -" varname value=curl -T ~1 -" varname value=keepj ~1 -" varname value=rcp ~1 -" varname value=rsync ~1 -" varname value=/ ~1 -" varname value=scp -q ~1 -" varname value=sftp ~1 -" varname value=ssh ~1 -" varname value=0 ~1 -" varname value=1 ~1 -" varname value=1 ~1 -" varname value=0 ~1 -" varname value=noma nomod nonu nobl nowrap ro nornu ~1 -" varname value=-1 ~1 -" varname value=1 ~1 -" varname value=gzip ~1 -" varname value=ctags ~1 -" varname value=2 ~1 -" (netrw) COMBAK: cuc=0 cul=0 initialization of s:netrw_cu[cl] -" varname value=/cygdrive ~1 -" varname value=0 ~1 -" varname value=0 ~1 -" varname value={ ".gz" : "gunzip", ".bz2" : "bunzip2", ".zip" : "unzip", ".tar" : "tar -xf", ".xz" : "unxz" } ~1 -" varname value=10 ~1 -" varname value=0 ~1 -" varname value=1 ~1 -" varname value=^total\s\+\d\+$\|^Trying\s\+\d\+.*$\|^KERBEROS_V\d rejected\|^Security extensions not\|No such file\|: connect to address [0-9a-fA-F:]*: No route to host$ ~1 -" varname value=binary ~1 -" varname value=1 ~1 -" varname value=1 ~1 -" varname value= ~1 -" varname value=mkdir ~1 -" varname value=mkdir ~1 -" varname value=0 ~1 -" varname value=*./[\~ ~1 -" varname value=32 ~1 -" varname value=1 ~1 -" varname value=ssh USEPORT HOSTNAME mkdir ~1 -" varname value=1 ~1 -" varname value=0 ~1 -" varname value=chmod PERM FILENAME ~1 -" varname value=0 ~1 -- cgit From d1bdeacb00186ba72fa61f3c7f2951fd018ae21d Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sat, 17 Aug 2024 22:45:45 +0200 Subject: vim-patch:8e25d91: runtime(dist): verify that executable is in $PATH Otherwise, if the executable to be verified does not exist, this would cause a false-positive in the 'IsSafeExecutable()' check, because 'exepath(executable)' returns an empty string and 'fnamemodify('', ':p:h')' returns the current directory and as a result the 'IsSafeExecutable()' returns false (for the wrong reason). https://github.com/vim/vim/commit/8e25d91cb7bb4dc171cb4e95b1bb79a39400a13a Co-authored-by: Christian Brabandt --- runtime/autoload/dist/vim.vim | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'runtime/autoload') diff --git a/runtime/autoload/dist/vim.vim b/runtime/autoload/dist/vim.vim index 021244c93b..d519406530 100644 --- a/runtime/autoload/dist/vim.vim +++ b/runtime/autoload/dist/vim.vim @@ -18,6 +18,10 @@ endif if !has('vim9script') function dist#vim#IsSafeExecutable(filetype, executable) let cwd = getcwd() + if empty(exepath(a:executable)) + echomsg a:executable .. " not found in $PATH" + return v:false + endif return get(g:, a:filetype .. '_exec', get(g:, 'plugin_exec', 0)) && \ (fnamemodify(exepath(a:executable), ':p:h') !=# cwd \ || (split($PATH, has('win32') ? ';' : ':')->index(cwd) != -1 && -- cgit From 6f7bb02e7f7b8ff8fe4d67a433cd3a2250df7a11 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 21 Aug 2024 07:35:27 +0800 Subject: vim-patch:9.1.0686: zip-plugin has problems with special characters (#30108) Problem: zip-plugin has problems with special characters (user202729) Solution: escape '*?[\' on Unix and handle those chars a bit differently on MS-Windows, add a test, check before overwriting files runtime(zip): small fixes for zip plugin This does the following: - verify the unzip plugin is executable when loading the autoload plugin - handle extracting file names with '[*?\' in its name correctly by escaping those characters for the unzip command (and handle those characters a bit differently on MS-Windows, since the quoting is different) - verify, that the extract plugin is not overwriting a file (could cause a hang, because unzip asking for confirmation) - add a test zip file which contains those special file names fixes: vim/vim#15505 closes: vim/vim#15519 https://github.com/vim/vim/commit/7790ea0c680a9f951a86066e5940ec16b2333c9a Co-authored-by: Christian Brabandt --- runtime/autoload/zip.vim | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/zip.vim b/runtime/autoload/zip.vim index d0d6863329..f113be6b6b 100644 --- a/runtime/autoload/zip.vim +++ b/runtime/autoload/zip.vim @@ -1,6 +1,6 @@ " zip.vim: Handles browsing zipfiles " AUTOLOAD PORTION -" Date: Aug 05, 2024 +" Date: Aug 18, 2024 " Version: 34 " Maintainer: This runtime file is looking for a new maintainer. " Former Maintainer: Charles E Campbell @@ -12,6 +12,7 @@ " 2024 Aug 04 by Vim Project: escape '[' in name of file to be extracted " 2024 Aug 05 by Vim Project: workaround for the FreeBSD's unzip " 2024 Aug 05 by Vim Project: clean-up and make it work with shellslash on Windows +" 2024 Aug 18 by Vim Project: correctly handle special globbing chars " License: Vim License (see vim's :help license) " Copyright: Copyright (C) 2005-2019 Charles E. Campbell {{{1 " Permission is hereby granted to use and distribute this code, @@ -72,6 +73,11 @@ if v:version < 702 call s:Mess('WarningMsg', "***warning*** this version of zip needs vim 7.2 or later") finish endif +" sanity checks +if !executable(g:zip_unzipcmd) + call s:Mess('Error', "***error*** (zip#Browse) unzip not available on your system") + finish +endif if !dist#vim#IsSafeExecutable('zip', g:zip_unzipcmd) call s:Mess('Error', "Warning: NOT executing " .. g:zip_unzipcmd .. " from current directory!") finish @@ -198,7 +204,7 @@ fun! zip#Read(fname,mode) let zipfile = substitute(a:fname,'^.\{-}zipfile://\(.\{-}\)::[^\\].*$','\1','') let fname = substitute(a:fname,'^.\{-}zipfile://.\{-}::\([^\\].*\)$','\1','') endif - let fname = substitute(fname, '[', '[[]', 'g') + let fname = fname->substitute('[', '[[]', 'g')->escape('?*\\') " sanity check if !executable(substitute(g:zip_unzipcmd,'\s\+.*$','','')) call s:Mess('Error', "***error*** (zip#Read) sorry, your system doesn't appear to have the ".g:zip_unzipcmd." program") @@ -330,9 +336,24 @@ fun! zip#Extract() call s:Mess('Error', "***error*** (zip#Extract) Please specify a file, not a directory") return endif + if filereadable(fname) + call s:Mess('Error', "***error*** (zip#Extract) <" .. fname .."> already exists in directory, not overwriting!") + return + endif + let target = fname->substitute('\[', '[[]', 'g') + if &shell =~ 'cmd' && (has("win32") || has("win64")) + let target = target + \ ->substitute('[?*]', '[&]', 'g') + \ ->substitute('[\\]', '?', 'g') + \ ->shellescape() + " there cannot be a file name with '\' in its name, unzip replaces it by _ + let fname = fname->substitute('[\\?*]', '_', 'g') + else + let target = target->escape('*?\\')->shellescape() + endif " extract the file mentioned under the cursor - call system($"{g:zip_extractcmd} {shellescape(b:zipfile)} {shellescape(fname)}") + call system($"{g:zip_extractcmd} -o {shellescape(b:zipfile)} {target}") if v:shell_error != 0 call s:Mess('Error', "***error*** ".g:zip_extractcmd." ".b:zipfile." ".fname.": failed!") elseif !filereadable(fname) -- cgit From 3bd7492a69a0bf00b366a46dc09d5035b9f784e4 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 22 Aug 2024 05:58:22 +0800 Subject: vim-patch:bc29ea6: runtime(zip): simplify condition to detect MS-Windows (#30115) related: vim/vim#15519 https://github.com/vim/vim/commit/bc29ea62861052b35781031173a67d7d577be068 Co-authored-by: Christian Brabandt --- runtime/autoload/zip.vim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/zip.vim b/runtime/autoload/zip.vim index f113be6b6b..172de98d36 100644 --- a/runtime/autoload/zip.vim +++ b/runtime/autoload/zip.vim @@ -1,6 +1,6 @@ " zip.vim: Handles browsing zipfiles " AUTOLOAD PORTION -" Date: Aug 18, 2024 +" Date: 2024 Aug 21 " Version: 34 " Maintainer: This runtime file is looking for a new maintainer. " Former Maintainer: Charles E Campbell @@ -13,6 +13,7 @@ " 2024 Aug 05 by Vim Project: workaround for the FreeBSD's unzip " 2024 Aug 05 by Vim Project: clean-up and make it work with shellslash on Windows " 2024 Aug 18 by Vim Project: correctly handle special globbing chars +" 2024 Aug 21 by Vim Project: simplify condition to detect MS-Windows " License: Vim License (see vim's :help license) " Copyright: Copyright (C) 2005-2019 Charles E. Campbell {{{1 " Permission is hereby granted to use and distribute this code, @@ -341,7 +342,7 @@ fun! zip#Extract() return endif let target = fname->substitute('\[', '[[]', 'g') - if &shell =~ 'cmd' && (has("win32") || has("win64")) + if &shell =~ 'cmd' && has("win32") let target = target \ ->substitute('[?*]', '[&]', 'g') \ ->substitute('[\\]', '?', 'g') -- cgit From 916237d9b531e946de4a6eb1d62ac0a484d585d6 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Thu, 22 Aug 2024 21:25:14 +0200 Subject: vim-patch:38cfa2b: runtime(netrw): Fix `mf`-selected entry highlighting closes: vim/vim#15551 https://github.com/vim/vim/commit/38cfa2b6623c64e748be17739799da36ca2d76bf Co-authored-by: yasuda --- runtime/autoload/netrw.vim | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 08676884d5..f67133b67e 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -21,6 +21,7 @@ " 2024 Jul 30 by Vim Project: handle mark-copy to same target directory (#12112) " 2024 Aug 02 by Vim Project: honor g:netrw_alt{o,v} for :{S,H,V}explore (#15417) " 2024 Aug 15 by Vim Project: style changes, prevent E121 (#15501) +" 2024 Aug 22 by Vim Project: fix mf-selection highlight (#15551) " }}} " Former Maintainer: Charles E Campbell " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim @@ -6824,11 +6825,7 @@ fun! s:NetrwMarkFile(islocal,fname) let ykeep = @@ let curbufnr= bufnr("%") - if a:fname =~ '^\a' - let leader= '\<' - else - let leader= '' - endif + let leader= '\(^\|\s\)\zs' if a:fname =~ '\a$' let trailer = '\>[@=|\/\*]\=\ze\%( \|\t\|$\)' else -- cgit From 8db8793503511c13c8da9e6fd9c9d0468e42f67b Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Thu, 22 Aug 2024 21:25:33 +0200 Subject: vim-patch:c75dad0: runtime(netrw): Change line on `mx` if command output exists closes: vim/vim#15550 https://github.com/vim/vim/commit/c75dad017726ae78d6d2a68d1d6cfa12e7bd29f3 Co-authored-by: yasuda --- runtime/autoload/netrw.vim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index f67133b67e..cb71d2e110 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -22,6 +22,7 @@ " 2024 Aug 02 by Vim Project: honor g:netrw_alt{o,v} for :{S,H,V}explore (#15417) " 2024 Aug 15 by Vim Project: style changes, prevent E121 (#15501) " 2024 Aug 22 by Vim Project: fix mf-selection highlight (#15551) +" 2024 Aug 22 by Vim Project: adjust echo output of mx command (#15550) " }}} " Former Maintainer: Charles E Campbell " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim @@ -7434,7 +7435,13 @@ fun! s:NetrwMarkFileExe(islocal,enbloc) NetrwKeepj call netrw#ErrorMsg(s:ERROR,"command<".xcmd."> failed, aborting",54) break else - echo ret + if ret !=# '' + echo "\n" + " skip trailing new line + echo ret[0:-2] + else + echo ret + endif endif endfor -- cgit From 60ea0467411d8452b0af75836aec377cbe781fbc Mon Sep 17 00:00:00 2001 From: wzy <32936898+Freed-Wu@users.noreply.github.com> Date: Mon, 2 Sep 2024 20:43:23 +0800 Subject: feat(clipboard): try cygutils, clip on Windows #30215 --- runtime/autoload/provider/clipboard.vim | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'runtime/autoload') diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim index 82e0953196..58d3d4550f 100644 --- a/runtime/autoload/provider/clipboard.vim +++ b/runtime/autoload/provider/clipboard.vim @@ -140,6 +140,18 @@ function! provider#clipboard#Executable() abort let s:copy['*'] = s:copy['+'] let s:paste['*'] = s:paste['+'] return 'win32yank' + elseif executable('putclip') && executable('getclip') + let s:copy['+'] = ['putclip'] + let s:paste['+'] = ['getclip'] + let s:copy['*'] = s:copy['+'] + let s:paste['*'] = s:paste['+'] + return 'putclip' + elseif executable('clip') && executable('powershell') + let s:copy['+'] = ['clip'] + let s:paste['+'] = ['powershell', '-NoProfile', '-NoLogo', '-Command', 'Get-Clipboard'] + let s:copy['*'] = s:copy['+'] + let s:paste['*'] = s:paste['+'] + return 'clip' elseif executable('termux-clipboard-set') let s:copy['+'] = ['termux-clipboard-set'] let s:paste['+'] = ['termux-clipboard-get'] -- cgit From 51088b67cb1e9363df98cfc8f3bbd6caad03cc5d Mon Sep 17 00:00:00 2001 From: Gregory Anders <8965202+gpanders@users.noreply.github.com> Date: Wed, 4 Sep 2024 19:32:52 -0500 Subject: vim-patch:150b507: runtime(hcl,terraform): Add runtime files for HCL and Terraform (#30266) closes: vim/vim#15618 https://github.com/vim/vim/commit/150b5078ac886519083576124090489c3a21bd3b --- runtime/autoload/hcl.vim | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 runtime/autoload/hcl.vim (limited to 'runtime/autoload') diff --git a/runtime/autoload/hcl.vim b/runtime/autoload/hcl.vim new file mode 100644 index 0000000000..2215fc8f27 --- /dev/null +++ b/runtime/autoload/hcl.vim @@ -0,0 +1,40 @@ +" Language: HCL +" Maintainer: Gregory Anders +" Last Change: 2024-09-03 +" Based on: https://github.com/hashivim/vim-terraform + +function! hcl#indentexpr(lnum) + " Beginning of the file should have no indent + if a:lnum == 0 + return 0 + endif + + " Usual case is to continue at the same indent as the previous non-blank line. + let prevlnum = prevnonblank(a:lnum-1) + let thisindent = indent(prevlnum) + + " If that previous line is a non-comment ending in [ { (, increase the + " indent level. + let prevline = getline(prevlnum) + if prevline !~# '^\s*\(#\|//\)' && prevline =~# '[\[{\(]\s*$' + let thisindent += &shiftwidth + endif + + " If the current line ends a block, decrease the indent level. + let thisline = getline(a:lnum) + if thisline =~# '^\s*[\)}\]]' + let thisindent -= &shiftwidth + endif + + " If the previous line starts a block comment /*, increase by one + if prevline =~# '/\*' + let thisindent += 1 + endif + + " If the previous line ends a block comment */, decrease by one + if prevline =~# '\*/' + let thisindent -= 1 + endif + + return thisindent +endfunction -- cgit From 5e7933693bd87fc5e39e9680cac2a5e17775bfb9 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sun, 15 Sep 2024 19:31:06 +0200 Subject: vim-patch:0f5effb: runtime(netrw): delete confirmation not strict enough fixes: vim/vim#15680 https://github.com/vim/vim/commit/0f5effbd1fb58128be677aa577d3d0ab2fc9527a Co-authored-by: Christian Brabandt --- runtime/autoload/netrw.vim | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index cb71d2e110..c38529d0e5 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -23,6 +23,7 @@ " 2024 Aug 15 by Vim Project: style changes, prevent E121 (#15501) " 2024 Aug 22 by Vim Project: fix mf-selection highlight (#15551) " 2024 Aug 22 by Vim Project: adjust echo output of mx command (#15550) +" 2024 Sep 15 by Vim Project: more strict confirmation dialog (#15680) " }}} " Former Maintainer: Charles E Campbell " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim @@ -11275,7 +11276,7 @@ fun! s:NetrwLocalRm(path) range let ok= s:NetrwLocalRmFile(a:path,fname,all) if ok =~# 'q\%[uit]' || ok == "no" break - elseif ok =~# 'a\%[ll]' + elseif ok =~# '^a\%[ll]$' let all= 1 endif endfor @@ -11304,7 +11305,7 @@ fun! s:NetrwLocalRm(path) range let ok= s:NetrwLocalRmFile(a:path,curword,all) if ok =~# 'q\%[uit]' || ok == "no" break - elseif ok =~# 'a\%[ll]' + elseif ok =~# '^a\%[ll]$' let all= 1 endif let ctr= ctr + 1 @@ -11351,12 +11352,12 @@ fun! s:NetrwLocalRmFile(path,fname,all) " call Decho("response: ok<".ok.">",'~'.expand("")) let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e') " call Decho("response: ok<".ok."> (after sub)",'~'.expand("")) - if ok =~# 'a\%[ll]' + if ok =~# '^a\%[ll]$' let all= 1 endif endif - if all || ok =~# 'y\%[es]' || ok == "" + if all || ok =~# '^y\%[es]$' || ok == "" let ret= s:NetrwDelete(rmfile) " call Decho("errcode=".v:shell_error." ret=".ret,'~'.expand("")) endif @@ -11372,13 +11373,13 @@ fun! s:NetrwLocalRmFile(path,fname,all) if ok == "" let ok="no" endif - if ok =~# 'a\%[ll]' + if ok =~# '^a\%[ll]$' let all= 1 endif endif let rmfile= substitute(rmfile,'[\/]$','','e') - if all || ok =~# 'y\%[es]' || ok == "" + if all || ok =~# '^y\%[es]$' || ok == "" if delete(rmfile,"rf") call netrw#ErrorMsg(s:ERROR,"unable to delete directory <".rmfile.">!",103) endif -- cgit From 82f329a41d0de3bf66a2d91dbcc8769e8549491e Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Thu, 19 Sep 2024 18:55:36 +0200 Subject: vim-patch:c18a9d5: runtime(netrw): using inefficient highlight pattern for 'mf' Fixes E872 too many '(' in highlight pattern for `mf` selection fixup for vim/vim#15551 closes: vim/vim#15700 https://github.com/vim/vim/commit/c18a9d5835456e0e47e943b673d631caaebdbea3 Co-authored-by: yasuda --- runtime/autoload/netrw.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index c38529d0e5..386438852b 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -24,6 +24,7 @@ " 2024 Aug 22 by Vim Project: fix mf-selection highlight (#15551) " 2024 Aug 22 by Vim Project: adjust echo output of mx command (#15550) " 2024 Sep 15 by Vim Project: more strict confirmation dialog (#15680) +" 2024 Sep 19 by Vim Project: mf-selection highlight uses wrong pattern (#15700) " }}} " Former Maintainer: Charles E Campbell " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim @@ -6827,7 +6828,7 @@ fun! s:NetrwMarkFile(islocal,fname) let ykeep = @@ let curbufnr= bufnr("%") - let leader= '\(^\|\s\)\zs' + let leader= '\%(^\|\s\)\zs' if a:fname =~ '\a$' let trailer = '\>[@=|\/\*]\=\ze\%( \|\t\|$\)' else -- cgit From 881a58787d2dab37ad912f76f78a04771b500d1f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 21 Sep 2024 20:16:28 +0800 Subject: vim-patch:e6b01cf: runtime(dist): do not output a message if executable is not found (#30451) closes: vim/vim#15705 https://github.com/vim/vim/commit/e6b01cfe01a2722ec55a011ae04c4c404e88f924 Co-authored-by: Christian Brabandt --- runtime/autoload/dist/vim.vim | 1 - 1 file changed, 1 deletion(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/dist/vim.vim b/runtime/autoload/dist/vim.vim index d519406530..bb858c5732 100644 --- a/runtime/autoload/dist/vim.vim +++ b/runtime/autoload/dist/vim.vim @@ -19,7 +19,6 @@ if !has('vim9script') function dist#vim#IsSafeExecutable(filetype, executable) let cwd = getcwd() if empty(exepath(a:executable)) - echomsg a:executable .. " not found in $PATH" return v:false endif return get(g:, a:filetype .. '_exec', get(g:, 'plugin_exec', 0)) && -- cgit From 423176db565cc182dac8b9562ccb23605f96fa2d Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Mon, 23 Sep 2024 08:28:05 +0200 Subject: vim-patch:be551da: runtime(netrw): remove extraneous closing bracket fixes: vim/vim#15717 closes: vim/vim#15718 https://github.com/vim/vim/commit/be551dacb87a0542afd8b5c17b89e6749f2dc355 Co-authored-by: Peter Aronoff --- runtime/autoload/netrw.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 386438852b..a96364fb4b 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -25,6 +25,7 @@ " 2024 Aug 22 by Vim Project: adjust echo output of mx command (#15550) " 2024 Sep 15 by Vim Project: more strict confirmation dialog (#15680) " 2024 Sep 19 by Vim Project: mf-selection highlight uses wrong pattern (#15700) +" 2024 Sep 21 by Vim Project: remove extraneous closing bracket (#15718) " }}} " Former Maintainer: Charles E Campbell " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim @@ -4183,7 +4184,7 @@ fun! s:NetrwGetBuffer(islocal,dirname) endif " call Decho(" NetrwTreeListing: bufnum#".bufnum,'~'.expand("")) if !bufexists(bufnum) - call remove(s:netrwbuf,"NetrwTreeListing"]) + call remove(s:netrwbuf,"NetrwTreeListing") let bufnum= -1 endif elseif bufnr("NetrwTreeListing") != -1 -- cgit From 2f2f434613d624cba9a7276f6dc2f3031142afd6 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Tue, 1 Oct 2024 07:00:12 +0200 Subject: vim-patch:85f054a: runtime(java): Recognise the CommonMark form (///) of Javadoc comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Complement "g:java_ignore_javadoc" with "g:java_ignore_html" and "g:java_ignore_markdown" to allow selectively disabling the recognition of HTML and CommonMark respectively. (Note that this is not a preview feature.) ======================== LIMITATION ======================== According to the syntactical details of JEP 467: > Any leading whitespace and the three initial / characters > are removed from each line. > > The lines are shifted left, by removing leading whitespace > characters, until the non-blank line with the least > leading whitespace has no remaining leading whitespace. > > Additional leading whitespace and any trailing whitespace > in each line is preserved, because it may be significant. the following example: ------------------------------------------------------------ /// A summary sentence. /// A list: /// - Item A. /// - Item B. /// /// Some code span, starting here ` /// 1 + 2 ` and ending at the previous \`. ------------------------------------------------------------ should be interpreted as if it were written thus: ------------------------------------------------------------ ///A summary sentence. /// A list: /// - Item A. /// - Item B. /// /// Some code span, starting here ` /// 1 + 2 ` and ending at the previous \`. ------------------------------------------------------------ Since automatic line rewriting will not be pursued, parts of such comments having significant whitespace may be ‘wrongly’ highlighted. For convenience, a &fex function is defined to ‘correct’ it: g:javaformat#RemoveCommonMarkdownWhitespace() (:help ft-java-plugin). References: https://openjdk.org/jeps/467 https://spec.commonmark.org/0.31.2 closes: vim/vim#15740 https://github.com/vim/vim/commit/85f054aa3f0fb9530712d0897e3c8ba29946fad4 Co-authored-by: Aliaksei Budavei <0x000c70@gmail.com> Co-authored-by: Tim Pope --- runtime/autoload/javaformat.vim | 92 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 runtime/autoload/javaformat.vim (limited to 'runtime/autoload') diff --git a/runtime/autoload/javaformat.vim b/runtime/autoload/javaformat.vim new file mode 100644 index 0000000000..4d7d32cf19 --- /dev/null +++ b/runtime/autoload/javaformat.vim @@ -0,0 +1,92 @@ +" Vim formatting plugin file +" Language: Java +" Maintainer: Aliaksei Budavei <0x000c70 AT gmail DOT com> +" Repository: https://github.com/zzzyxwvut/java-vim.git +" Last Change: 2024 Sep 26 + +" Documented in ":help ft-java-plugin". +if &cp || exists("g:loaded_javaformat") || exists("g:java_ignore_javadoc") || exists("g:java_ignore_markdown") + finish +endif + +let g:loaded_javaformat = 1 + +"""" STRIVE TO REMAIN COMPATIBLE FOR AT LEAST VIM 7.0. + +function! javaformat#RemoveCommonMarkdownWhitespace() abort + if mode() != 'n' + return 0 + endif + + let pattern = '\(^\s*///\)\(\s*\)\(.*\)' + + " E121 for v:numbermax before v8.2.2388. + " E15 for expr-<< before v8.2.5003. + let common = 0x7fffffff + let comments = [] + + for n in range(v:lnum, (v:lnum + v:count - 1)) + let parts = matchlist(getline(n), pattern) + let whitespace = get(parts, 2, '') + let nonwhitespace = get(parts, 3, '') + + if !empty(whitespace) + let common = min([common, strlen(whitespace)]) + elseif !empty(nonwhitespace) || empty(parts) + " No whitespace prefix or not a Markdown comment. + return 0 + endif + + call add(comments, [whitespace, parts[1], nonwhitespace]) + endfor + + let cursor = v:lnum + + for line in comments + call setline(cursor, join(line[1 :], strpart(line[0], common))) + let cursor += 1 + endfor + + return 0 +endfunction + +" See ":help vim9-mix". +if !has("vim9script") + finish +endif + +def! g:javaformat#RemoveCommonMarkdownWhitespace(): number + if mode() != 'n' + return 0 + endif + + const pattern: string = '\(^\s*///\)\(\s*\)\(.*\)' + var common: number = v:numbermax + var comments: list> = [] + + for n in range(v:lnum, (v:lnum + v:count - 1)) + const parts: list = matchlist(getline(n), pattern) + const whitespace: string = get(parts, 2, '') + const nonwhitespace: string = get(parts, 3, '') + + if !empty(whitespace) + common = min([common, strlen(whitespace)]) + elseif !empty(nonwhitespace) || empty(parts) + # No whitespace prefix or not a Markdown comment. + return 0 + endif + + add(comments, [whitespace, parts[1], nonwhitespace]) + endfor + + var cursor: number = v:lnum + + for line in comments + setline(cursor, join(line[1 :], strpart(line[0], common))) + cursor += 1 + endfor + + return 0 +enddef + +" vim: fdm=syntax sw=4 ts=8 noet sta -- cgit