diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-10-31 18:59:44 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2024-10-31 18:59:49 +0800 |
commit | 35e07a24a329fdd7f35640843c9bc983185ca04e (patch) | |
tree | 26640010a0b3b782aa94c47cb2dfe2fe749c71ab /runtime/plugin | |
parent | d618fd39214abf8904bee20cec87b76859e79047 (diff) | |
download | rneovim-35e07a24a329fdd7f35640843c9bc983185ca04e.tar.gz rneovim-35e07a24a329fdd7f35640843c9bc983185ca04e.tar.bz2 rneovim-35e07a24a329fdd7f35640843c9bc983185ca04e.zip |
vim-patch:8b0fa7a: runtime(netrw): make :Launch/Open autoloadable
fixes: vim/vim#15959
closes: vim/vim#15962
https://github.com/vim/vim/commit/8b0fa7a565d8aec306e5755307d182fa7d81e65f
Co-authored-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Aliaksei Budavei <0x000c70@gmail.com>
Diffstat (limited to 'runtime/plugin')
-rw-r--r-- | runtime/plugin/netrwPlugin.vim | 81 |
1 files changed, 3 insertions, 78 deletions
diff --git a/runtime/plugin/netrwPlugin.vim b/runtime/plugin/netrwPlugin.vim index c31eed525e..775b650e71 100644 --- a/runtime/plugin/netrwPlugin.vim +++ b/runtime/plugin/netrwPlugin.vim @@ -6,6 +6,7 @@ " 2024 May 08 by Vim Project: cleanup legacy Win9X checks " 2024 Oct 27 by Vim Project: cleanup gx mapping " 2024 Oct 28 by Vim Project: further improvements +" 2024 Oct 31 by Vim Project: use autoloaded functions " Former Maintainer: Charles E Campbell " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim " Copyright: Copyright (C) 1999-2021 Charles E. Campbell {{{1 @@ -34,84 +35,8 @@ set cpo&vim " Public Interface: {{{1 " Commands Launch/URL {{{2 -" surpress output of command; use bang for GUI applications - -func s:redir() - " set up redirection (avoids browser messages) - " by default if not set, g:netrw_suppress_gx_mesg is true - if get(g:, 'netrw_suppress_gx_mesg', 1) - if &srr =~# "%s" - return printf(&srr, has("win32") ? "nul" : "/dev/null") - else - return &srr .. (has("win32") ? "nul" : "/dev/null") - endif - endif - return '' -endfunc - -if has('unix') - if has('win32unix') - " If cygstart provided, then assume Cygwin and use cygstart --hide; see man cygstart. - if executable('cygstart') - command -complete=shellcmd -nargs=1 -bang Launch - \ exe 'silent ! cygstart --hide' trim(<q-args>) s:redir() | redraw! - elseif !empty($MSYSTEM) && executable('start') - " MSYS2/Git Bash comes by default without cygstart; see - " https://www.msys2.org/wiki/How-does-MSYS2-differ-from-Cygwin - " Instead it provides /usr/bin/start script running `cmd.exe //c start` - " Adding "" //b` sets void title, hides cmd window and blocks path conversion - " of /b to \b\ " by MSYS2; see https://www.msys2.org/docs/filesystem-paths/ - command -complete=shellcmd -nargs=1 -bang Launch - \ exe 'silent !start "" //b' trim(<q-args>) s:redir() | redraw! - else - " imitate /usr/bin/start script for other environments and hope for the best - command -complete=shellcmd -nargs=1 -bang Launch - \ exe 'silent !cmd //c start "" //b' trim(<q-args>) s:redir() | redraw! - endif - elseif exists('$WSL_DISTRO_NAME') " use cmd.exe to start GUI apps in WSL - command -complete=shellcmd -nargs=1 -bang Launch execute ':silent !'.. - \ ((<q-args> =~? '\v<\f+\.(exe|com|bat|cmd)>') ? - \ 'cmd.exe /c start "" /b' trim(<q-args>) : - \ 'nohup ' trim(<q-args>) s:redir() '&') - \ | redraw! - else - command -complete=shellcmd -nargs=1 -bang Launch - \ exe ':silent ! nohup' trim(<q-args>) s:redir() '&' | redraw! - endif -elseif has('win32') - command -complete=shellcmd -nargs=1 -bang Launch - \ exe 'silent !'.. (&shell =~? '\<cmd\.exe\>' ? '' : 'cmd.exe /c') - \ 'start /b ' trim(<q-args>) s:redir() | redraw! -endif -if exists(':Launch') == 2 - " Git Bash - if has('win32unix') - " start suffices - let s:cmd = '' - " Windows / WSL - elseif executable('explorer.exe') - let s:cmd = 'explorer.exe' - " Linux / BSD - elseif executable('xdg-open') - let s:cmd = 'xdg-open' - " MacOS - elseif executable('open') - let s:cmd = 'open' - endif - function s:Open(file) - if !exists('s:cmd') && !exists('g:netrw_browsex_viewer') - echoerr "No program to open this path found. See :help Open for more information." - else - exe 'Launch' s:cmd shellescape(a:file, 1) - endif - endfunction - command -complete=file -nargs=1 Open call s:Open(<q-args>) -endif - -if !exists('g:netrw_regex_url') - let g:netrw_regex_url = '\%(\%(http\|ftp\|irc\)s\?\|file\)://\S\{-}' -endif - +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 augroup FileExplorer |