runtime(netrw): make :Launch/Open autoloadable

fixes: #15959
closes: #15962

Co-authored-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Konfekt <Konfekt@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/runtime/plugin/netrwPlugin.vim b/runtime/plugin/netrwPlugin.vim
index c31eed5..775b650 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 @@
 " 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