]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(netrw): upstream snapshot of v181
authorLuca Saccarola <github.e41mv@aleeas.com>
Sat, 7 Jun 2025 15:35:18 +0000 (17:35 +0200)
committerChristian Brabandt <cb@256bit.org>
Sat, 7 Jun 2025 15:35:18 +0000 (17:35 +0200)
closes: #17461

Signed-off-by: Luca Saccarola <github.e41mv@aleeas.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/pi_netrw.txt
runtime/doc/tags
runtime/pack/dist/opt/netrw/autoload/netrw.vim
runtime/pack/dist/opt/netrw/autoload/netrw/msg.vim
runtime/pack/dist/opt/netrw/autoload/netrw/os.vim
runtime/pack/dist/opt/netrw/autoload/netrwSettings.vim
runtime/pack/dist/opt/netrw/doc/netrw.txt
runtime/pack/dist/opt/netrw/plugin/netrwPlugin.vim

index 00799911ed608765df423c716753297835fe01a1..ad5bc2d9b730ddc30d5756268a966600c79b5565 100644 (file)
@@ -2557,12 +2557,6 @@ your browsing preferences.  (see also: |netrw-settings|)
                                    |g:netrw_maxfilenamelen|, which affects
                                    local file long listing.
 
-  *g:netrw_errorlvl*           =0: error levels greater than or equal to
-                                   this are permitted to be displayed
-                                   0: notes
-                                   1: warnings
-                                   2: errors
-
   *g:netrw_fastbrowse*         =0: slow speed directory browsing;
                                    never re-uses directory listings;
                                    always obtains directory listings.
index 0955709153bf265f29f6af623e31b985e63ba98d..afa4a058f414c21436a59f2e59f4fd3d2c89fa9e 100644 (file)
@@ -7720,7 +7720,6 @@ g:netrw_dav_cmd   pi_netrw.txt    /*g:netrw_dav_cmd*
 g:netrw_decompress     pi_netrw.txt    /*g:netrw_decompress*
 g:netrw_dirhistmax     pi_netrw.txt    /*g:netrw_dirhistmax*
 g:netrw_dynamic_maxfilenamelen pi_netrw.txt    /*g:netrw_dynamic_maxfilenamelen*
-g:netrw_errorlvl       pi_netrw.txt    /*g:netrw_errorlvl*
 g:netrw_fastbrowse     pi_netrw.txt    /*g:netrw_fastbrowse*
 g:netrw_fetch_cmd      pi_netrw.txt    /*g:netrw_fetch_cmd*
 g:netrw_ffkeep pi_netrw.txt    /*g:netrw_ffkeep*
index 228f4706393741b778c6a8d9a23d9ef13052846c..0e019e10b726bdff54632ef47803a6f5362c68b5 100644 (file)
@@ -19,7 +19,7 @@ if &cp || exists("g:loaded_netrw")
     finish
 endif
 
-let g:loaded_netrw = "v180"
+let g:loaded_netrw = "v181"
 
 if !has("patch-9.1.1054") && !has('nvim')
     echoerr 'netrw needs Vim v9.1.1054'
@@ -46,39 +46,10 @@ setl cpo&vim
 "          (this function can optionally take a list of messages)
 "  Mar 03, 2025 : max errnum currently is 107
 function! netrw#ErrorMsg(level, msg, errnum)
-    if a:level < g:netrw_errorlvl
-        return
-    endif
-
-    if a:level == 1
-        let level = "**warning** (netrw) "
-    elseif a:level == 2
-        let level = "**error** (netrw) "
-    else
-        let level = "**note** (netrw) "
-    endif
-
     if has('nvim')
-        call v:lua.vim.notify(level . a:msg, a:level + 2)
+        call v:lua.vim.notify(a:msg, a:level + 2)
     else
-        " (optional) netrw will show messages using echomsg.  Even if the
-        " message doesn't appear, at least it'll be recallable via :messages
-        "   redraw!
-        if a:level == s:WARNING
-            echohl WarningMsg
-        elseif a:level == s:ERROR
-            echohl ErrorMsg
-        endif
-
-        if type(a:msg) == 3
-            for msg in a:msg
-                echomsg level.msg
-            endfor
-        else
-            echomsg level.a:msg
-        endif
-
-        echohl None
+        call netrw#msg#Notify(a:level, a:msg)
     endif
 endfunction
 
@@ -114,7 +85,7 @@ endif
 let s:NOTE    = 0
 let s:WARNING = 1
 let s:ERROR   = 2
-call s:NetrwInit("g:netrw_errorlvl", s:NOTE)
+let g:_netrw_log = {'NOTE': 0, 'WARN': 1, 'ERROR': 2}
 
 let s:has_balloon = !has('nvim') &&
             \ has("balloon_eval") &&
@@ -325,42 +296,31 @@ if exists("g:netrw_local_copycmd")
   let g:netrw_localcopycmd= g:netrw_local_copycmd
   call netrw#ErrorMsg(s:NOTE,"g:netrw_local_copycmd is deprecated in favor of g:netrw_localcopycmd",84)
 endif
+
 if !exists("g:netrw_localcmdshell")
   let g:netrw_localcmdshell= ""
 endif
+
 if !exists("g:netrw_localcopycmd")
-  if has("win32")
-    if g:netrw_cygwin
-      let g:netrw_localcopycmd= "cp"
-    else
-      let g:netrw_localcopycmd   = expand("$COMSPEC", v:true)
-      call s:NetrwInit("g:netrw_localcopycmdopt"," /c copy")
+    let g:netrw_localcopycmd = 'cp'
+    let g:netrw_localcopycmdopt = ''
+
+    if has("win32") && !g:netrw_cygwin
+        let g:netrw_localcopycmd   = expand("$COMSPEC", v:true)
+        let g:netrw_localcopycmdopt = '/c copy'
     endif
-  elseif has("unix") || has("macunix")
-    let g:netrw_localcopycmd= "cp"
-  else
-    let g:netrw_localcopycmd= ""
-  endif
 endif
+
 if !exists("g:netrw_localcopydircmd")
-  if has("win32")
-    if g:netrw_cygwin
-      let g:netrw_localcopydircmd   = "cp"
-      call s:NetrwInit("g:netrw_localcopydircmdopt"," -R")
-    else
-      let g:netrw_localcopydircmd   = expand("$COMSPEC", v:true)
-      call s:NetrwInit("g:netrw_localcopydircmdopt"," /c xcopy /e /c /h /i /k")
-    endif
-  elseif has("unix")
-    let g:netrw_localcopydircmd   = "cp"
-    call s:NetrwInit("g:netrw_localcopydircmdopt"," -R")
-  elseif has("macunix")
-    let g:netrw_localcopydircmd   = "cp"
-    call s:NetrwInit("g:netrw_localcopydircmdopt"," -R")
-  else
-    let g:netrw_localcopydircmd= ""
-  endif
+    let g:netrw_localcopydircmd = 'cp'
+    let g:netrw_localcopydircmdopt = '-R'
+
+    if has("win32") && !g:netrw_cygwin
+        let g:netrw_localcopydircmd   = "cp"
+        call s:NetrwInit("g:netrw_localcopydircmdopt", "-R")
+    endif
 endif
+
 if exists("g:netrw_local_mkdir")
   let g:netrw_localmkdir= g:netrw_local_mkdir
   call netrw#ErrorMsg(s:NOTE,"g:netrw_local_mkdir is deprecated in favor of g:netrw_localmkdir",87)
@@ -6208,24 +6168,18 @@ fun! s:NetrwMarkFileCopy(islocal,...)
   " sanity check
   if !exists("s:netrwmarkfilelist_{curbufnr}") || empty(s:netrwmarkfilelist_{curbufnr})
     NetrwKeepj call netrw#ErrorMsg(2,"there are no marked files in this window (:help netrw-mf)",66)
-    "   call Dret("s:NetrwMarkFileCopy")
     return
   endif
-  "  call Decho("sanity chk passed: s:netrwmarkfilelist_".curbufnr."<".string(s:netrwmarkfilelist_{curbufnr}),'~'.expand("<slnum>"))
 
   if !exists("s:netrwmftgt")
     NetrwKeepj call netrw#ErrorMsg(s:ERROR,"your marked file target is empty! (:help netrw-mt)",67)
-    "   call Dret("s:NetrwMarkFileCopy 0")
     return 0
   endif
-  "  call Decho("sanity chk passed: s:netrwmftgt<".s:netrwmftgt.">",'~'.expand("<slnum>"))
 
   if a:islocal &&  s:netrwmftgt_islocal
     " Copy marked files, local directory to local directory
-    "   call Decho("copy from local to local",'~'.expand("<slnum>"))
     if !executable(g:netrw_localcopycmd)
       call netrw#ErrorMsg(s:ERROR,"g:netrw_localcopycmd<".g:netrw_localcopycmd."> not executable on your system, aborting",91)
-      "    call Dfunc("s:NetrwMarkFileMove : g:netrw_localcopycmd<".g:netrw_localcopycmd."> n/a!")
       return
     endif
 
@@ -6233,17 +6187,14 @@ fun! s:NetrwMarkFileCopy(islocal,...)
     if simplify(s:netrwmftgt) ==# simplify(b:netrw_curdir)
       if len(s:netrwmarkfilelist_{bufnr('%')}) == 1
         " only one marked file
-        "     call Decho("case: only one marked file",'~'.expand("<slnum>"))
         let args    = netrw#os#Escape(b:netrw_curdir.s:netrwmarkfilelist_{bufnr('%')}[0])
         let oldname = s:netrwmarkfilelist_{bufnr('%')}[0]
       elseif a:0 == 1
-        "     call Decho("case: handling one input argument",'~'.expand("<slnum>"))
         " this happens when the next case was used to recursively call s:NetrwMarkFileCopy()
         let args    = netrw#os#Escape(b:netrw_curdir.a:1)
         let oldname = a:1
       else
         " copy multiple marked files inside the same directory
-        "     call Decho("case: handling a multiple marked files",'~'.expand("<slnum>"))
         let s:recursive= 1
         for oldname in s:netrwmarkfilelist_{bufnr("%")}
           let ret= s:NetrwMarkFileCopy(a:islocal,oldname)
@@ -6253,59 +6204,49 @@ fun! s:NetrwMarkFileCopy(islocal,...)
         endfor
         unlet s:recursive
         call s:NetrwUnmarkList(curbufnr,curdir)
-        "     call Dret("s:NetrwMarkFileCopy ".ret)
         return ret
       endif
 
       call inputsave()
-      let newname= input("Copy ".oldname." to : ",oldname,"file")
+      let newname= input(printf("Copy %s to: ", oldname), oldname, 'file')
       call inputrestore()
-      if newname == ""
-        "     call Dret("s:NetrwMarkFileCopy 0")
+
+      if empty(newname)
         return 0
       endif
-      let args= netrw#os#Escape(oldname)
+
+      let args = netrw#os#Escape(oldname)
       let tgt = netrw#os#Escape(s:netrwmftgt.'/'.newname)
     else
-      let args= join(map(deepcopy(s:netrwmarkfilelist_{bufnr('%')}),"netrw#os#Escape(b:netrw_curdir.\"/\".v:val)"))
+      let args = join(map(deepcopy(s:netrwmarkfilelist_{bufnr('%')}),"netrw#os#Escape(b:netrw_curdir.\"/\".v:val)"))
       let tgt = netrw#os#Escape(s:netrwmftgt)
     endif
+
     if !g:netrw_cygwin && has("win32")
-      let args= substitute(args,'/','\\','g')
+      let args = substitute(args,'/','\\','g')
       let tgt = substitute(tgt, '/','\\','g')
     endif
+
     if args =~ "'" |let args= substitute(args,"'\\(.*\\)'",'\1','')|endif
     if tgt  =~ "'" |let tgt = substitute(tgt ,"'\\(.*\\)'",'\1','')|endif
     if args =~ '//'|let args= substitute(args,'//','/','g')|endif
     if tgt  =~ '//'|let tgt = substitute(tgt ,'//','/','g')|endif
-    "   call Decho("args   <".args.">",'~'.expand("<slnum>"))
-    "   call Decho("tgt    <".tgt.">",'~'.expand("<slnum>"))
+
+    let copycmd = g:netrw_localcopycmd
+    let copycmdopt = g:netrw_localcopycmdopt
+
     if isdirectory(s:NetrwFile(args))
-      "    call Decho("args<".args."> is a directory",'~'.expand("<slnum>"))
-      let copycmd= g:netrw_localcopydircmd
-      "    call Decho("using copydircmd<".copycmd.">",'~'.expand("<slnum>"))
-      if !g:netrw_cygwin && has("win32")
+      let copycmd = g:netrw_localcopydircmd
+      let copycmdopt = g:netrw_localcopydircmdopt
+      if has('win32') && !g:netrw_cygwin
         " window's xcopy doesn't copy a directory to a target properly.  Instead, it copies a directory's
         " contents to a target.  One must append the source directory name to the target to get xcopy to
         " do the right thing.
         let tgt= tgt.'\'.substitute(a:1,'^.*[\\/]','','')
-        "     call Decho("modified tgt for xcopy",'~'.expand("<slnum>"))
       endif
-    else
-      let copycmd= g:netrw_localcopycmd
     endif
-    if g:netrw_localcopycmd =~ '\s'
-      let copycmd     = substitute(copycmd,'\s.*$','','')
-      let copycmdargs = substitute(copycmd,'^.\{-}\(\s.*\)$','\1','')
-      let copycmd     = netrw#fs#WinPath(copycmd).copycmdargs
-    else
-      let copycmd = netrw#fs#WinPath(copycmd)
-    endif
-    "   call Decho("args   <".args.">",'~'.expand("<slnum>"))
-    "   call Decho("tgt    <".tgt.">",'~'.expand("<slnum>"))
-    "   call Decho("copycmd<".copycmd.">",'~'.expand("<slnum>"))
-    "   call Decho("system(".copycmd." '".args."' '".tgt."')",'~'.expand("<slnum>"))
-    call system(copycmd.g:netrw_localcopycmdopt." '".args."' '".tgt."'")
+
+    call system(printf("%s %s '%s' '%s'", copycmd, copycmdopt, args, tgt))
     if v:shell_error != 0
       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)
index 75a5330e628c4d2c1d33dcd4a6c3cf80b231d7fb..8144a45a3db9535f9ace2cb12e387dc47d2ab24f 100644 (file)
@@ -27,4 +27,33 @@ function! netrw#msg#Deprecate(name, version, alternatives)
     call add(s:deprecation_msgs, a:name)
 endfunction
 
+" netrw#msg#Notify: {{{
+"   Usage: netrw#ErrorMsg(g:_netrw_log, 'some message')
+"          netrw#ErrorMsg(g:_netrw_log, ["message1","message2",...],error-number)
+"          (this function can optionally take a list of messages)
+function! netrw#msg#Notify(level, msg)
+    if has('nvim')
+        call v:lua.vim.notify(level . a:msg, a:level + 2)
+        return
+    endif
+
+    if a:level == g:_netrw_log.WARN
+        echohl WarningMsg
+    elseif a:level == g:_netrw_log.ERROR
+        echohl ErrorMsg
+    endif
+
+    if type(a:msg) == v:t_list
+        for msg in a:msg
+            echomsg msg
+        endfor
+    else
+        echomsg a:msg
+    endif
+
+    echohl None
+endfunction
+
+" }}}
+
 " vim:ts=8 sts=4 sw=4 et fdm=marker
index 1ab1bd03886823f3b3b3b3aecc2332dc009e0d91..23d48e0d57ec6755932aa5a234440ea4f5da3bbc 100644 (file)
@@ -37,7 +37,7 @@ endfunction
 
 function! netrw#os#Open(file) abort
     if has('nvim')
-        call luaeval('vim.ui.open(_A[1]) and nil', [a:file])
+        call luaeval('vim.ui.open(_A) and nil', a:file)
     else
         call dist#vim9#Open(a:file)
     endif
index 20428d621b14ce7d16dda690f87f4b62b7503a4c..98e4b52cddab0a93e66efb02bb39fb2e4588fa6d 100644 (file)
@@ -15,7 +15,7 @@ if &cp || exists("g:loaded_netrwSettings")
     finish
 endif
 
-let g:loaded_netrwSettings = "v180"
+let g:loaded_netrwSettings = "v181"
 
 " NetrwSettings: {{{
 
@@ -124,7 +124,6 @@ function! netrwSettings#NetrwSettings()
         put = '\" let g:netrw_dynamic_maxfilenamelen= (not defined)'
     endif
     put = 'let g:netrw_dirhistmax = '.g:netrw_dirhistmax
-    put = 'let g:netrw_errorlvl = '.g:netrw_errorlvl
     put = 'let g:netrw_fastbrowse = '.g:netrw_fastbrowse
     let fnameescline= line("$")
     put = 'let g:netrw_fname_escape = '.string(g:netrw_fname_escape)
index 5655acffa3dfb75ec818d3e80a2b7c3232b04388..59d1a2e3a7f79331c7e394aede4e4f341cc23768 100644 (file)
@@ -2557,12 +2557,6 @@ your browsing preferences.  (see also: |netrw-settings|)
                                    |g:netrw_maxfilenamelen|, which affects
                                    local file long listing.
 
-  *g:netrw_errorlvl*           =0: error levels greater than or equal to
-                                   this are permitted to be displayed
-                                   0: notes
-                                   1: warnings
-                                   2: errors
-
   *g:netrw_fastbrowse*         =0: slow speed directory browsing;
                                    never re-uses directory listings;
                                    always obtains directory listings.
index 178eecc288aba34055981e10374ac1a8d1c716c1..eaa97b8bc856a01122a254c55c440a8afe7e21af 100644 (file)
@@ -15,7 +15,7 @@ if &cp || exists("g:loaded_netrwPlugin")
     finish
 endif
 
-let g:loaded_netrwPlugin = "v180"
+let g:loaded_netrwPlugin = "v181"
 
 let s:keepcpo = &cpo
 set cpo&vim