runtime(netrw): upstream snapshot of v175

Relevant commits:
- release: netrw v175
- fix: prevent netrw to load into the built-in terminal
- fix: restore correctly cpo settings
- fix(docs): mispelled original authors name
- chore: move viml files to new formatting standard

fixes: #16463
closes: #16465

Signed-off-by: Luca Saccarola <github.e41mv@aleeas.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Luca Saccarola
2025-01-18 17:36:02 +01:00
committed by Christian Brabandt
parent 87f65f3857
commit d402ba81e2
6 changed files with 502 additions and 503 deletions

View File

@ -35,7 +35,7 @@ if exists("s:needspatches")
endfor
endif
let g:loaded_netrw = "v174"
let g:loaded_netrw = "v175"
let s:keepcpo= &cpo
setl cpo&vim

View File

@ -1,7 +1,7 @@
" Maintainer: Luca Saccarola <github.e41mv@aleeas.com>
" Former Maintainer: Charles E Campbell
" Upstream: <https://github.com/saccarosium/netrw.vim>
" Copyright: Copyright (C) 1999-2007 Charles E. Campbell {{{1
" Copyright: Copyright (C) 1999-2007 Charles E. Campbell {{{
" 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,
@ -9,13 +9,13 @@
" 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.
" of this software. }}}
" Load Once: {{{1
if exists("g:loaded_netrwSettings") || &cp
if &cp || exists("g:loaded_netrwSettings")
finish
endif
let g:loaded_netrwSettings = "v174"
let g:loaded_netrwSettings = "v175"
if v:version < 700
echohl WarningMsg
echo "***warning*** this version of netrwSettings needs vim 7.0"
@ -23,13 +23,15 @@ if v:version < 700
finish
endif
" ---------------------------------------------------------------------
" NetrwSettings: {{{1
fun! netrwSettings#NetrwSettings()
" NetrwSettings: {{{
function! netrwSettings#NetrwSettings()
" this call is here largely just to insure that netrw has been loaded
call netrw#WinPath("")
if !exists("g:loaded_netrw")
echohl WarningMsg | echomsg "***sorry*** netrw needs to be loaded prior to using NetrwSettings" | echohl None
echohl WarningMsg
echomsg "***sorry*** netrw needs to be loaded prior to using NetrwSettings"
echohl None
return
endif
@ -209,17 +211,16 @@ fun! netrwSettings#NetrwSettings()
nnoremap <buffer> <silent> <leftmouse> <leftmouse> :call NetrwSettingHelp()<cr>
let tmpfile= tempname()
exe 'au BufWriteCmd Netrw\ Settings silent w! '.tmpfile.'|so '.tmpfile.'|call delete("'.tmpfile.'")|set nomod'
endfun
endfunction
" ---------------------------------------------------------------------
" NetrwSettingHelp: {{{2
fun! NetrwSettingHelp()
" call Dfunc("NetrwSettingHelp()")
" }}}
" NetrwSettingHelp: {{{
function! NetrwSettingHelp()
let curline = getline(".")
if curline =~ '='
let varhelp = substitute(curline,'^\s*let ','','e')
let varhelp = substitute(varhelp,'\s*=.*$','','e')
" call Decho("trying help ".varhelp)
try
exe "he ".varhelp
catch /^Vim\%((\a\+)\)\=:E149/
@ -234,9 +235,8 @@ fun! NetrwSettingHelp()
else
he netrw-browse-var
endif
" call Dret("NetrwSettingHelp")
endfun
endfunction
" ---------------------------------------------------------------------
" Modelines: {{{1
" vim:ts=8 fdm=marker
" }}}
" vim:ts=8 sts=4 sw=4 et fdm=marker

View File

@ -12,7 +12,7 @@
" let g:netrw_list_hide = netrw_gitignore#Hide()
" let g:netrw_list_hide = netrw_gitignore#Hide() . 'more,hide,patterns'
"
" Copyright: Copyright (C) 2013 Bruno Sutic {{{1
" Copyright: Copyright (C) 2013 Bruno Sutic {{{
" 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,
@ -20,7 +20,10 @@
" 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.
" of this software. }}}
function! netrw_gitignore#Hide(...)
return substitute(substitute(system('git ls-files --other --ignored --exclude-standard --directory'), '\n', ',', 'g'), ',$', '', '')
endfunction
" vim:ts=8 sts=4 sw=4 et fdm=marker

View File

@ -1,7 +1,7 @@
*netrw.txt*
------------------------------------------------
NETRW REFERENCE MANUAL by Charles E.Cambell
NETRW REFERENCE MANUAL by Charles E. Campbell
------------------------------------------------
Original Author: Charles E. Campbell

View File

@ -1,7 +1,7 @@
" Maintainer: Luca Saccarola <github.e41mv@aleeas.com>
" Former Maintainer: Charles E Campbell
" Upstream: <https://github.com/saccarosium/netrw.vim>
" Copyright: Copyright (C) 1999-2021 Charles E. Campbell {{{1
" Copyright: Copyright (C) 1999-2021 Charles E. Campbell {{{
" 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,
@ -9,25 +9,25 @@
" *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.
" resulting from the use of this software. }}}
" Load Once: {{{1
if &cp || exists("g:loaded_netrwPlugin")
finish
endif
let g:loaded_netrwPlugin = "v174"
let g:loaded_netrwPlugin = "v175"
let s:keepcpo = &cpo
set cpo&vim
"DechoRemOn
" ---------------------------------------------------------------------
" Public Interface: {{{1
" Commands Launch/URL: {{{
" Commands Launch/URL {{{2
command -complete=shellcmd -nargs=1 Launch call netrw#Launch(trim(<q-args>))
command -complete=file -nargs=1 Open call netrw#Open(trim(<q-args>))
" " }}}
" Local Browsing Autocmds: {{{2
" }}}
" Local Browsing Autocmds: {{{
augroup FileExplorer
au!
au BufLeave * if &ft != "netrw"|let w:netrw_prvfile= expand("%:p")|endif
@ -38,7 +38,9 @@ augroup FileExplorer
endif
augroup END
" Network Browsing Reading Writing: {{{2
" }}}
" Network Browsing Reading Writing: {{{
augroup Network
au!
au BufReadCmd file://* call netrw#FileUrlEdit(expand("<amatch>"))
@ -53,28 +55,36 @@ augroup Network
endtry
augroup END
" Commands: :Nread, :Nwrite, :NetUserPass {{{2
com! -count=1 -nargs=* Nread let s:svpos= winsaveview()<bar>call netrw#NetRead(<count>,<f-args>)<bar>call winrestview(s:svpos)
com! -range=% -nargs=* Nwrite let s:svpos= winsaveview()<bar><line1>,<line2>call netrw#NetWrite(<f-args>)<bar>call winrestview(s:svpos)
com! -nargs=* NetUserPass call NetUserPass(<f-args>)
com! -nargs=* Nsource let s:svpos= winsaveview()<bar>call netrw#NetSource(<f-args>)<bar>call winrestview(s:svpos)
com! -nargs=? Ntree call netrw#SetTreetop(1,<q-args>)
" }}}
" Commands: :Nread, :Nwrite, :NetUserPass {{{
" Commands: :Explore, :Sexplore, Hexplore, Vexplore, Lexplore {{{2
com! -nargs=* -bar -bang -count=0 -complete=dir Explore call netrw#Explore(<count>,0,0+<bang>0,<q-args>)
com! -nargs=* -bar -bang -count=0 -complete=dir Sexplore call netrw#Explore(<count>,1,0+<bang>0,<q-args>)
com! -nargs=* -bar -bang -count=0 -complete=dir Hexplore call netrw#Explore(<count>,1,2+<bang>0,<q-args>)
com! -nargs=* -bar -bang -count=0 -complete=dir Vexplore call netrw#Explore(<count>,1,4+<bang>0,<q-args>)
com! -nargs=* -bar -count=0 -complete=dir Texplore call netrw#Explore(<count>,0,6 ,<q-args>)
com! -nargs=* -bar -bang Nexplore call netrw#Explore(-1,0,0,<q-args>)
com! -nargs=* -bar -bang Pexplore call netrw#Explore(-2,0,0,<q-args>)
com! -nargs=* -bar -bang -count=0 -complete=dir Lexplore call netrw#Lexplore(<count>,<bang>0,<q-args>)
command! -count=1 -nargs=* Nread let s:svpos= winsaveview()<bar>call netrw#NetRead(<count>,<f-args>)<bar>call winrestview(s:svpos)
command! -range=% -nargs=* Nwrite let s:svpos= winsaveview()<bar><line1>,<line2>call netrw#NetWrite(<f-args>)<bar>call winrestview(s:svpos)
command! -nargs=* NetUserPass call NetUserPass(<f-args>)
command! -nargs=* Nsource let s:svpos= winsaveview()<bar>call netrw#NetSource(<f-args>)<bar>call winrestview(s:svpos)
command! -nargs=? Ntree call netrw#SetTreetop(1,<q-args>)
" Commands: NetrwSettings {{{2
com! -nargs=0 NetrwSettings call netrwSettings#NetrwSettings()
com! -bang NetrwClean call netrw#Clean(<bang>0)
" }}}
" Commands: :Explore, :Sexplore, Hexplore, Vexplore, Lexplore {{{
command! -nargs=* -bar -bang -count=0 -complete=dir Explore call netrw#Explore(<count>, 0, 0+<bang>0, <q-args>)
command! -nargs=* -bar -bang -count=0 -complete=dir Sexplore call netrw#Explore(<count>, 1, 0+<bang>0, <q-args>)
command! -nargs=* -bar -bang -count=0 -complete=dir Hexplore call netrw#Explore(<count>, 1, 2+<bang>0, <q-args>)
command! -nargs=* -bar -bang -count=0 -complete=dir Vexplore call netrw#Explore(<count>, 1, 4+<bang>0, <q-args>)
command! -nargs=* -bar -count=0 -complete=dir Texplore call netrw#Explore(<count>, 0, 6, <q-args>)
command! -nargs=* -bar -bang -count=0 -complete=dir Lexplore call netrw#Lexplore(<count>, <bang>0, <q-args>)
command! -nargs=* -bar -bang Nexplore call netrw#Explore(-1, 0, 0, <q-args>)
command! -nargs=* -bar -bang Pexplore call netrw#Explore(-2, 0, 0, <q-args>)
" }}}
" Commands: NetrwSettings {{{
command! -nargs=0 NetrwSettings call netrwSettings#NetrwSettings()
command! -bang NetrwClean call netrw#Clean(<bang>0)
" }}}
" Maps: {{{
" Maps:
if !exists("g:netrw_nogx")
if maparg('gx','n') == ""
if !hasmapto('<Plug>NetrwBrowseX')
@ -89,6 +99,7 @@ if !exists("g:netrw_nogx")
xno <silent> <Plug>NetrwBrowseXVis :<c-u>call netrw#BrowseXVis()<cr>
endif
endif
if exists("g:netrw_usetab") && g:netrw_usetab
if maparg('<c-tab>','n') == ""
nmap <unique> <c-tab> <Plug>NetrwShrink
@ -96,62 +107,50 @@ if exists("g:netrw_usetab") && g:netrw_usetab
nno <silent> <Plug>NetrwShrink :call netrw#Shrink()<cr>
endif
" ---------------------------------------------------------------------
" LocalBrowse: invokes netrw#LocalBrowseCheck() on directory buffers {{{2
fun! s:LocalBrowse(dirname)
" Unfortunate interaction -- only DechoMsg debugging calls can be safely used here.
" Otherwise, the BufEnter event gets triggered when attempts to write to
" the DBG buffer are made.
" }}}
" LocalBrowse: invokes netrw#LocalBrowseCheck() on directory buffers {{{
function! s:LocalBrowse(dirname)
" do not trigger in the terminal
" https://github.com/vim/vim/issues/16463
if &buftype ==# 'terminal'
return
endif
if !exists("s:vimentered")
" If s:vimentered doesn't exist, then the VimEnter event hasn't fired. It will,
" and so s:VimEnter() will then be calling this routine, but this time with s:vimentered defined.
" call Dfunc("s:LocalBrowse(dirname<".a:dirname.">) (s:vimentered doesn't exist)")
" call Dret("s:LocalBrowse")
return
endif
" call Dfunc("s:LocalBrowse(dirname<".a:dirname.">) (s:vimentered=".s:vimentered.")")
if has("amiga")
" The check against '' is made for the Amiga, where the empty
" string is the current directory and not checking would break
" things such as the help command.
" call Decho("(LocalBrowse) dirname<".a:dirname."> (isdirectory, amiga)")
if a:dirname != '' && isdirectory(a:dirname)
sil! call netrw#LocalBrowseCheck(a:dirname)
if exists("w:netrw_bannercnt") && line('.') < w:netrw_bannercnt
exe w:netrw_bannercnt
endif
endif
elseif isdirectory(a:dirname)
" call Decho("(LocalBrowse) dirname<".a:dirname."> ft=".&ft." (isdirectory, not amiga)")
" call Dredir("LocalBrowse ft last set: ","verbose set ft")
" Jul 13, 2021: for whatever reason, preceding the following call with
" a sil! causes an unbalanced if-endif vim error
call netrw#LocalBrowseCheck(a:dirname)
if exists("w:netrw_bannercnt") && line('.') < w:netrw_bannercnt
exe w:netrw_bannercnt
endif
else
" not a directory, ignore it
" call Decho("(LocalBrowse) dirname<".a:dirname."> not a directory, ignoring...")
endif
endfunction
" call Dret("s:LocalBrowse")
endfun
" ---------------------------------------------------------------------
" s:VimEnter: after all vim startup stuff is done, this function is called. {{{2
" }}}
" s:VimEnter: after all vim startup stuff is done, this function is called. {{{
" Its purpose: to look over all windows and run s:LocalBrowse() on
" them, which checks if they're directories and will create a directory
" listing when appropriate.
" It also sets s:vimentered, letting s:LocalBrowse() know that s:VimEnter()
" has already been called.
fun! s:VimEnter(dirname)
" call Dfunc("s:VimEnter(dirname<".a:dirname.">) expand(%)<".expand("%").">")
function! s:VimEnter(dirname)
if has('nvim') || v:version < 802
" Johann Höchtl: reported that the call range... line causes an E488: Trailing characters
" error with neovim. I suspect its because neovim hasn't updated with recent
@ -168,55 +167,48 @@ fun! s:VimEnter(dirname)
let s:vimentered = 1
call range(1, winnr('$'))->map({_, v -> win_execute(win_getid(v), 'call expand("%:p")->s:LocalBrowse()')})
endif
" call Dret("s:VimEnter")
endfun
endfunction
" ---------------------------------------------------------------------
" NetrwStatusLine: {{{1
fun! NetrwStatusLine()
" let g:stlmsg= "Xbufnr=".w:netrw_explore_bufnr." bufnr=".bufnr("%")." Xline#".w:netrw_explore_line." line#".line(".")
" }}}
" NetrwStatusLine: {{{
function! NetrwStatusLine()
if !exists("w:netrw_explore_bufnr") || w:netrw_explore_bufnr != bufnr("%") || !exists("w:netrw_explore_line") || w:netrw_explore_line != line(".") || !exists("w:netrw_explore_list")
let &stl= s:netrw_explore_stl
if exists("w:netrw_explore_bufnr")|unlet w:netrw_explore_bufnr|endif
if exists("w:netrw_explore_line")|unlet w:netrw_explore_line|endif
unlet! w:netrw_explore_bufnr w:netrw_explore_line
return ""
else
return "Match ".w:netrw_explore_mtchcnt." of ".w:netrw_explore_listlen
endif
endfun
endfunction
" ------------------------------------------------------------------------
" NetUserPass: set username and password for subsequent ftp transfer {{{1
" }}}
" NetUserPass: set username and password for subsequent ftp transfer {{{
" Usage: :call NetUserPass() -- will prompt for userid and password
" :call NetUserPass("uid") -- will prompt for password
" :call NetUserPass("uid","password") -- sets global userid and password
fun! NetUserPass(...)
function! NetUserPass(...)
" get/set userid
if a:0 == 0
" call Dfunc("NetUserPass(a:0<".a:0.">)")
if !exists("g:netrw_uid") || g:netrw_uid == ""
" via prompt
let g:netrw_uid= input('Enter username: ')
endif
else " from command line
" call Dfunc("NetUserPass(a:1<".a:1.">) {")
let g:netrw_uid= a:1
endif
" get password
if a:0 <= 1 " via prompt
" call Decho("a:0=".a:0." case <=1:")
let g:netrw_passwd= inputsecret("Enter Password: ")
else " from command line
" call Decho("a:0=".a:0." case >1: a:2<".a:2.">")
let g:netrw_passwd=a:2
endif
" call Dret("NetUserPass")
endfun
endfunction
" }}}
" ------------------------------------------------------------------------
" Modelines And Restoration: {{{1
let &cpo= s:keepcpo
unlet s:keepcpo
" vim:ts=8 sts=2 sw=2 et fdm=marker
" vim:ts=8 sts=4 sw=4 et fdm=marker

View File

@ -7,7 +7,10 @@ if exists("b:current_syntax")
finish
endif
" Directory List Syntax Highlighting: {{{1
let b:current_syntax = "netrwlist"
" Directory List Syntax Highlighting: {{{
syn cluster NetrwGroup contains=netrwHide,netrwSortBy,netrwSortSeq,netrwQuickHelp,netrwVersion,netrwCopyTgt
syn cluster NetrwTreeGroup contains=netrwDir,netrwSymLink,netrwExe
@ -48,9 +51,9 @@ syn match netrwCmdNote ".\{-}\ze " contained contains=@NoSpell
syn match netrwVersion "(netrw.*)" contained contains=@NoSpell
syn match netrwLink "-->" contained skipwhite
" -----------------------------
" Special filetype highlighting {{{1
" -----------------------------
" }}}
" Special filetype highlighting {{{
if exists("g:netrw_special_syntax") && g:netrw_special_syntax
if exists("+suffixes") && &suffixes != ""
let suflist= join(split(&suffixes,','))
@ -77,8 +80,9 @@ if exists("g:netrw_special_syntax") && g:netrw_special_syntax
syn match netrwTmp "\<tmp\(\S\+ \)*\S\+\>\|\(\S\+ \)*\S*tmp\>" contains=netrwTreeBar,@NoSpell
endif
" ---------------------------------------------------------------------
" Highlighting Links: {{{1
" }}}
" Highlighting Links: {{{
if !exists("did_drchip_netrwlist_syntax")
let did_drchip_netrwlist_syntax= 1
hi default link netrwClassify Function
@ -127,6 +131,7 @@ endif
redir => s:netrwgray
sil hi netrwGray
redir END
if s:netrwgray !~ 'guifg'
if has("gui") && has("gui_running")
if &bg == "dark"
@ -139,7 +144,6 @@ endif
endif
endif
" Current Syntax: {{{1
let b:current_syntax = "netrwlist"
" ---------------------------------------------------------------------
" vim: ts=8 fdm=marker
" }}}
" vim:ts=8 sts=4 sw=4 et fdm=marker