mirror of
https://github.com/neovim/neovim.git
synced 2026-04-27 09:44:07 +00:00
Merge pull request #35736 from tomtomjhj/vim-2328a39
vim-patch: netrw plugin updates
This commit is contained in:
16623
runtime/pack/dist/opt/netrw/autoload/netrw.vim
vendored
16623
runtime/pack/dist/opt/netrw/autoload/netrw.vim
vendored
File diff suppressed because it is too large
Load Diff
196
runtime/pack/dist/opt/netrw/autoload/netrw/fs.vim
vendored
Normal file
196
runtime/pack/dist/opt/netrw/autoload/netrw/fs.vim
vendored
Normal file
@@ -0,0 +1,196 @@
|
||||
" FUNCTIONS IN THIS FILE ARE MEANT TO BE USED BY NETRW.VIM AND NETRW.VIM ONLY.
|
||||
" THESE FUNCTIONS DON'T COMMIT TO ANY BACKWARDS COMPATIBILITY. SO CHANGES AND
|
||||
" BREAKAGES IF USED OUTSIDE OF NETRW.VIM ARE EXPECTED.
|
||||
|
||||
let s:slash = !exists('+shellslash') || &shellslash ? '/' : '\'
|
||||
|
||||
" netrw#fs#PathJoin: Appends a new part to a path taking different systems into consideration {{{
|
||||
|
||||
function! netrw#fs#PathJoin(...)
|
||||
let path = ""
|
||||
|
||||
for arg in a:000
|
||||
if empty(path)
|
||||
let path = arg
|
||||
else
|
||||
let path .= s:slash . arg
|
||||
endif
|
||||
endfor
|
||||
|
||||
return path
|
||||
endfunction
|
||||
|
||||
" }}}
|
||||
" netrw#fs#ComposePath: Appends a new part to a path taking different systems into consideration {{{
|
||||
|
||||
function! netrw#fs#ComposePath(base, subdir)
|
||||
if has('amiga')
|
||||
let ec = a:base[strdisplaywidth(a:base)-1]
|
||||
if ec != '/' && ec != ':'
|
||||
let ret = a:base . '/' . a:subdir
|
||||
else
|
||||
let ret = a:base.a:subdir
|
||||
endif
|
||||
|
||||
" COMBAK: test on windows with changing to root directory: :e C:/
|
||||
elseif a:subdir =~ '^\a:[/\\]\([^/\\]\|$\)' && has('win32')
|
||||
let ret = a:subdir
|
||||
|
||||
elseif a:base =~ '^\a:[/\\]\([^/\\]\|$\)' && has('win32')
|
||||
if a:base =~ '[/\\]$'
|
||||
let ret = a:base . a:subdir
|
||||
else
|
||||
let ret = a:base . '/' . a:subdir
|
||||
endif
|
||||
|
||||
elseif a:base =~ '^\a\{3,}://'
|
||||
let urlbase = substitute(a:base, '^\(\a\+://.\{-}/\)\(.*\)$', '\1', '')
|
||||
let curpath = substitute(a:base, '^\(\a\+://.\{-}/\)\(.*\)$', '\2', '')
|
||||
if a:subdir == '../'
|
||||
if curpath =~ '[^/]/[^/]\+/$'
|
||||
let curpath = substitute(curpath, '[^/]\+/$', '', '')
|
||||
else
|
||||
let curpath = ''
|
||||
endif
|
||||
let ret = urlbase.curpath
|
||||
else
|
||||
let ret = urlbase.curpath.a:subdir
|
||||
endif
|
||||
|
||||
else
|
||||
let ret = substitute(a:base . '/' .a:subdir, '//', '/', 'g')
|
||||
if a:base =~ '^//'
|
||||
" keeping initial '//' for the benefit of network share listing support
|
||||
let ret = '/' . ret
|
||||
endif
|
||||
let ret = simplify(ret)
|
||||
endif
|
||||
|
||||
return ret
|
||||
endfunction
|
||||
|
||||
" }}}
|
||||
" netrw#fs#AbsPath: returns the full path to a directory and/or file {{{
|
||||
|
||||
function! netrw#fs#AbsPath(path)
|
||||
let path = a:path->substitute(s:slash . '$', '', 'e')
|
||||
|
||||
" Nothing to do
|
||||
if isabsolutepath(path)
|
||||
return path
|
||||
endif
|
||||
|
||||
return path->fnamemodify(':p')->substitute(s:slash . '$', '', 'e')
|
||||
endfunction
|
||||
|
||||
" }}}
|
||||
" netrw#fs#Dirname: {{{
|
||||
|
||||
function netrw#fs#Dirname(path)
|
||||
" Keep a slash as directory recognition pattern
|
||||
return netrw#fs#AbsPath(a:path) . s:slash
|
||||
endfunction
|
||||
|
||||
" }}}
|
||||
" netrw#fs#Cwd: get the current directory. {{{
|
||||
" Change backslashes to forward slashes, if any.
|
||||
" If doesc is true, escape certain troublesome characters
|
||||
|
||||
function! netrw#fs#Cwd(doesc)
|
||||
let curdir = substitute(getcwd(), '\\', '/', 'ge')
|
||||
|
||||
if curdir !~ '[\/]$'
|
||||
let curdir .= '/'
|
||||
endif
|
||||
|
||||
if a:doesc
|
||||
let curdir = fnameescape(curdir)
|
||||
endif
|
||||
|
||||
return curdir
|
||||
endfunction
|
||||
|
||||
" }}}
|
||||
" netrw#fs#Glob: does glob() if local, remote listing otherwise {{{
|
||||
" direntry: this is the name of the directory. Will be fnameescape'd to prevent wildcard handling by glob()
|
||||
" expr : this is the expression to follow the directory. Will use netrw#fs#ComposePath()
|
||||
" pare =1: remove the current directory from the resulting glob() filelist
|
||||
" =0: leave the current directory in the resulting glob() filelist
|
||||
|
||||
function! netrw#fs#Glob(direntry, expr, pare)
|
||||
if netrw#CheckIfRemote()
|
||||
keepalt 1sp
|
||||
keepalt enew
|
||||
let keep_liststyle = w:netrw_liststyle
|
||||
let w:netrw_liststyle = s:THINLIST
|
||||
if s:NetrwRemoteListing() == 0
|
||||
keepj keepalt %s@/@@
|
||||
let filelist = getline(1,$)
|
||||
q!
|
||||
else
|
||||
" remote listing error -- leave treedict unchanged
|
||||
let filelist = w:netrw_treedict[a:direntry]
|
||||
endif
|
||||
let w:netrw_liststyle = keep_liststyle
|
||||
else
|
||||
let path= netrw#fs#ComposePath(fnameescape(a:direntry), a:expr)
|
||||
if has("win32")
|
||||
" escape [ so it is not detected as wildcard character, see :h wildcard
|
||||
let path = substitute(path, '[', '[[]', 'g')
|
||||
endif
|
||||
let filelist = glob(path, 0, 1, 1)
|
||||
if a:pare
|
||||
let filelist = map(filelist,'substitute(v:val, "^.*/", "", "")')
|
||||
endif
|
||||
endif
|
||||
|
||||
return filelist
|
||||
endfunction
|
||||
|
||||
" }}}
|
||||
" netrw#fs#WinPath: tries to insure that the path is windows-acceptable, whether cygwin is used or not {{{
|
||||
|
||||
function! netrw#fs#WinPath(path)
|
||||
if (!g:netrw_cygwin || &shell !~ '\%(\<bash\>\|\<zsh\>\)\%(\.exe\)\=$') && has("win32")
|
||||
" remove cygdrive prefix, if present
|
||||
let path = substitute(a:path, g:netrw_cygdrive . '/\(.\)', '\1:', '')
|
||||
" remove trailing slash (Win95)
|
||||
let path = substitute(path, '\(\\\|/\)$', '', 'g')
|
||||
" remove escaped spaces
|
||||
let path = substitute(path, '\ ', ' ', 'g')
|
||||
" convert slashes to backslashes
|
||||
let path = substitute(path, '/', '\', 'g')
|
||||
else
|
||||
let path = a:path
|
||||
endif
|
||||
|
||||
return path
|
||||
endfunction
|
||||
|
||||
" }}}
|
||||
" netrw#fs#Remove: deletes a file. {{{
|
||||
" Uses Steve Hall's idea to insure that Windows paths stay
|
||||
" acceptable. No effect on Unix paths.
|
||||
|
||||
function! netrw#fs#Remove(path)
|
||||
let path = netrw#fs#WinPath(a:path)
|
||||
|
||||
if !g:netrw_cygwin && has("win32") && exists("+shellslash")
|
||||
let sskeep = &shellslash
|
||||
setl noshellslash
|
||||
let result = delete(path)
|
||||
let &shellslash = sskeep
|
||||
else
|
||||
let result = delete(path)
|
||||
endif
|
||||
|
||||
if result < 0
|
||||
call netrw#msg#Notify('WARNING', printf('delete("%s") failed!', path))
|
||||
endif
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
" }}}
|
||||
|
||||
" vim:ts=8 sts=4 sw=4 et fdm=marker
|
||||
70
runtime/pack/dist/opt/netrw/autoload/netrw/msg.vim
vendored
Normal file
70
runtime/pack/dist/opt/netrw/autoload/netrw/msg.vim
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
" FUNCTIONS IN THIS FILE ARE MEANT TO BE USED BY NETRW.VIM AND NETRW.VIM ONLY.
|
||||
" THESE FUNCTIONS DON'T COMMIT TO ANY BACKWARDS COMPATIBILITY. SO CHANGES AND
|
||||
" BREAKAGES IF USED OUTSIDE OF NETRW.VIM ARE EXPECTED.
|
||||
|
||||
let s:deprecation_msgs = []
|
||||
function! netrw#msg#Deprecate(name, version, alternatives)
|
||||
" If running on neovim use vim.deprecate
|
||||
if has('nvim')
|
||||
let s:alternative = a:alternatives->get('nvim', v:null)
|
||||
call v:lua.vim.deprecate(a:name, s:alternative, a:version, "netrw", v:false)
|
||||
return
|
||||
endif
|
||||
|
||||
" If we did notify for something only do it once
|
||||
if s:deprecation_msgs->index(a:name) >= 0
|
||||
return
|
||||
endif
|
||||
|
||||
let s:alternative = a:alternatives->get('vim', v:null)
|
||||
echohl WarningMsg
|
||||
echomsg s:alternative != v:null
|
||||
\ ? printf('%s is deprecated, use %s instead.', a:name, s:alternative)
|
||||
\ : printf('%s is deprecated.', a:name)
|
||||
echomsg printf('Feature will be removed in netrw %s', a:version)
|
||||
echohl None
|
||||
|
||||
call add(s:deprecation_msgs, a:name)
|
||||
endfunction
|
||||
|
||||
" netrw#msg#Notify: {{{
|
||||
" Usage: netrw#msg#Notify('ERROR'|'WARNING'|'NOTE', 'some message')
|
||||
" netrw#msg#Notify('ERROR'|'WARNING'|'NOTE', ["message1","message2",...])
|
||||
" (this function can optionally take a list of messages)
|
||||
function! netrw#msg#Notify(level, msg)
|
||||
if has('nvim')
|
||||
" Convert string to corresponding vim.log.level value
|
||||
if a:level ==# 'ERROR'
|
||||
let level = 4
|
||||
elseif a:level ==# 'WARNING'
|
||||
let level = 3
|
||||
elseif a:level ==# 'NOTE'
|
||||
let level = 2
|
||||
endif
|
||||
call v:lua.vim.notify(a:msg, level)
|
||||
return
|
||||
endif
|
||||
|
||||
if a:level ==# 'WARNING'
|
||||
echohl WarningMsg
|
||||
elseif a:level ==# 'ERROR'
|
||||
echohl ErrorMsg
|
||||
else
|
||||
echoerr printf('"%s" is not a valid level', a:level)
|
||||
return
|
||||
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
|
||||
48
runtime/pack/dist/opt/netrw/autoload/netrw/os.vim
vendored
Normal file
48
runtime/pack/dist/opt/netrw/autoload/netrw/os.vim
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
" FUNCTIONS IN THIS FILE ARE MEANT TO BE USED BY NETRW.VIM AND NETRW.VIM ONLY.
|
||||
" THESE FUNCTIONS DON'T COMMIT TO ANY BACKWARDS COMPATIBILITY. SO CHANGES AND
|
||||
" BREAKAGES IF USED OUTSIDE OF NETRW.VIM ARE EXPECTED.
|
||||
|
||||
" netrw#os#Execute: executes a string using "!" {{{
|
||||
|
||||
function! netrw#os#Execute(cmd)
|
||||
if has("win32") && exepath(&shell) !~? '\v[\/]?(cmd|pwsh|powershell)(\.exe)?$' && !g:netrw_cygwin
|
||||
let savedShell=[&shell,&shellcmdflag,&shellxquote,&shellxescape,&shellquote,&shellpipe,&shellredir,&shellslash]
|
||||
set shell& shellcmdflag& shellxquote& shellxescape&
|
||||
set shellquote& shellpipe& shellredir& shellslash&
|
||||
try
|
||||
execute a:cmd
|
||||
finally
|
||||
let [&shell,&shellcmdflag,&shellxquote,&shellxescape,&shellquote,&shellpipe,&shellredir,&shellslash] = savedShell
|
||||
endtry
|
||||
else
|
||||
execute a:cmd
|
||||
endif
|
||||
|
||||
if v:shell_error
|
||||
call netrw#msg#Notify('ERROR', "shell signalled an error")
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" }}}
|
||||
" netrw#os#Escape: shellescape(), or special windows handling {{{
|
||||
|
||||
function! netrw#os#Escape(string, ...)
|
||||
return has('win32') && empty($SHELL) && &shellslash
|
||||
\ ? printf('"%s"', substitute(a:string, '"', '""', 'g'))
|
||||
\ : shellescape(a:string, a:0 > 0 ? a:1 : 0)
|
||||
endfunction
|
||||
|
||||
" }}}
|
||||
" netrw#os#Open: open file with os viewer (eg. xdg-open) {{{
|
||||
|
||||
function! netrw#os#Open(file) abort
|
||||
if has('nvim')
|
||||
call luaeval('vim.ui.open(_A) and nil', a:file)
|
||||
else
|
||||
call dist#vim9#Open(a:file)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" }}}
|
||||
|
||||
" vim:ts=8 sts=4 sw=4 et fdm=marker
|
||||
43
runtime/pack/dist/opt/netrw/doc/netrw.txt
vendored
43
runtime/pack/dist/opt/netrw/doc/netrw.txt
vendored
@@ -426,15 +426,6 @@ preferences. Most such settings are described below, in
|
||||
*g:netrw_silent* =0 : transfers done normally
|
||||
=1 : transfers done silently
|
||||
|
||||
*g:netrw_use_errorwindow* =2: messages from netrw will use a popup window
|
||||
Move the mouse and pause to remove the popup window.
|
||||
=1 : messages from netrw will use a separate one
|
||||
line window. This window provides reliable
|
||||
delivery of messages.
|
||||
=0 : (default) messages from netrw will use echoerr ;
|
||||
messages don't always seem to show up this
|
||||
way, but one doesn't have to quit the window.
|
||||
|
||||
*g:netrw_cygwin* =1 assume scp under windows is from cygwin. Also
|
||||
permits network browsing to use ls with time and
|
||||
size sorting (default if windows)
|
||||
@@ -1125,7 +1116,6 @@ QUICK REFERENCE: MAPS *netrw-browse-maps* {{{2
|
||||
|
||||
*netrw-quickcom* *netrw-quickcoms*
|
||||
QUICK REFERENCE: COMMANDS *netrw-explore-cmds* *netrw-browse-cmds* {{{2
|
||||
:NetrwClean[!]............................................|netrw-clean|
|
||||
:Ntree....................................................|netrw-ntree|
|
||||
:Explore[!] [dir] Explore directory of current file......|netrw-explore|
|
||||
:Hexplore[!] [dir] Horizontal Split & Explore.............|netrw-explore|
|
||||
@@ -1436,20 +1426,6 @@ With a "dirname", the specified directory name is used.
|
||||
The "gn" map will take the word below the cursor and use that for
|
||||
changing the top of the tree listing.
|
||||
|
||||
|
||||
NETRW CLEAN *netrw-clean* *:NetrwClean* {{{2
|
||||
|
||||
With :NetrwClean one may easily remove netrw from one's home directory;
|
||||
more precisely, from the first directory on your |'runtimepath'|.
|
||||
|
||||
With :NetrwClean!, netrw will attempt to remove netrw from all directories on
|
||||
your |'runtimepath'|. Of course, you have to have write/delete permissions
|
||||
correct to do this.
|
||||
|
||||
With either form of the command, netrw will first ask for confirmation
|
||||
that the removal is in fact what you want to do. If netrw doesn't have
|
||||
permission to remove a file, it will issue an error message.
|
||||
|
||||
*netrw-curdir*
|
||||
DELETING BOOKMARKS *netrw-mB* {{{2
|
||||
|
||||
@@ -2557,12 +2533,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.
|
||||
@@ -2740,11 +2710,6 @@ your browsing preferences. (see also: |netrw-settings|)
|
||||
rightmouse : remove file/directory
|
||||
=0: disables mouse maps
|
||||
|
||||
*g:netrw_nobeval* doesn't exist (default)
|
||||
If this variable exists, then balloon
|
||||
evaluation will be suppressed
|
||||
(see |'ballooneval'|)
|
||||
|
||||
*g:netrw_sizestyle* not defined: actual bytes (default)
|
||||
="b" : actual bytes (default)
|
||||
="h" : human-readable (ex. 5k, 4m, 3g)
|
||||
@@ -2886,14 +2851,6 @@ your browsing preferences. (see also: |netrw-settings|)
|
||||
such as listing, file removal, etc.
|
||||
default: ssh
|
||||
|
||||
*g:netrw_suppress_gx_mesg* =1 : browsers sometimes produce messages
|
||||
which are normally unwanted intermixed
|
||||
with the page.
|
||||
However, when using links, for example,
|
||||
those messages are what the browser produces.
|
||||
By setting this option to 0, netrw will not
|
||||
suppress browser messages.
|
||||
|
||||
*g:netrw_tmpfile_escape* =' &;'
|
||||
escape() is applied to all temporary files
|
||||
to escape these characters.
|
||||
|
||||
@@ -15,7 +15,7 @@ if &cp || exists("g:loaded_netrwPlugin")
|
||||
finish
|
||||
endif
|
||||
|
||||
let g:loaded_netrwPlugin = "v175"
|
||||
let g:loaded_netrwPlugin = "v184"
|
||||
|
||||
let s:keepcpo = &cpo
|
||||
set cpo&vim
|
||||
@@ -54,7 +54,7 @@ augroup END
|
||||
|
||||
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=* NetUserPass call netrw#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>)
|
||||
|
||||
@@ -143,39 +143,17 @@ function! s:VimEnter(dirname)
|
||||
endfunction
|
||||
|
||||
" }}}
|
||||
" NetrwStatusLine: {{{
|
||||
" Deprecated: {{{
|
||||
|
||||
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
|
||||
unlet! w:netrw_explore_bufnr w:netrw_explore_line
|
||||
return ""
|
||||
function NetUserPass(...)
|
||||
call netrw#msg#Deprecate('NetUserPass', 'v185', {
|
||||
\ 'vim': 'netrw#NetUserPass()',
|
||||
\ 'nvim': 'netrw#NetUserPass()'
|
||||
\})
|
||||
if a:0
|
||||
call netrw#NetUserPass(a:000)
|
||||
else
|
||||
return "Match ".w:netrw_explore_mtchcnt." of ".w:netrw_explore_listlen
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" }}}
|
||||
" 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
|
||||
function! NetUserPass(...)
|
||||
" get/set userid
|
||||
if a:0 == 0
|
||||
if !exists("g:netrw_uid") || g:netrw_uid == ""
|
||||
" via prompt
|
||||
let g:netrw_uid= input('Enter username: ')
|
||||
endif
|
||||
else " from command line
|
||||
let g:netrw_uid= a:1
|
||||
endif
|
||||
|
||||
" get password
|
||||
if a:0 <= 1 " via prompt
|
||||
let g:netrw_passwd= inputsecret("Enter Password: ")
|
||||
else " from command line
|
||||
let g:netrw_passwd=a:2
|
||||
call netrw#NetUserPass()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
Reference in New Issue
Block a user