From c1e020b7f3457d3a14e7dda72a4f6ebf06e8f91d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 31 Oct 2024 18:54:53 +0800 Subject: vim-patch:3d7e567: runtime(netrw): simplify gx file handling It did not work very well, at least on Debian 12, and I am not sure Git Bash and WSL, for example, were taken care of as maintenance stalled. The whole logic was somewhat convoluted with some parts repeatedly invoking failed commands. The file handling was outdated, for example, nowadays Netscape is rarely used, and also opinionated, for example mainly Microsoft Paint and Gimp for Image files. Instead, let's use (xdg-)open and similar commands on other systems which respects the user's preferences. closes: vim/vim#15721 https://github.com/vim/vim/commit/3d7e567ea7392e43a90a6ffb3cd49b71a7b59d1a Co-authored-by: Konfekt Co-authored-by: Luca Saccarola <96259932+saccarosium@users.noreply.github.com> --- runtime/plugin/netrwPlugin.vim | 84 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) (limited to 'runtime/plugin') diff --git a/runtime/plugin/netrwPlugin.vim b/runtime/plugin/netrwPlugin.vim index c70e6518ff..59fb7e727e 100644 --- a/runtime/plugin/netrwPlugin.vim +++ b/runtime/plugin/netrwPlugin.vim @@ -1,9 +1,10 @@ " netrwPlugin.vim: Handles file transfer and remote directory listing across a network " PLUGIN SECTION " Maintainer: This runtime file is looking for a new maintainer. -" Date: Feb 09, 2021 +" Date: Sep 09, 2021 " Last Change: " 2024 May 08 by Vim Project: cleanup legacy Win9X checks +" 2024 Oct 27 by Vim Project: cleanup gx mapping " Former Maintainer: Charles E Campbell " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim " Copyright: Copyright (C) 1999-2021 Charles E. Campbell {{{1 @@ -31,6 +32,87 @@ set cpo&vim " --------------------------------------------------------------------- " Public Interface: {{{1 +" Commands Launch/URL {{{2 +" surpress output of command; use bang for GUI applications + +" set up redirection (avoids browser messages) +" by default, g:netrw_suppress_gx_mesg is true +if get(g:, ':netrw_suppress_gx_mesg', 1) + if &srr =~# "%s" + let s:redir = printf(&srr, has("win32") ? "nul" : "/dev/null") + else + let s:redir= &srr .. (has("win32") ? "nul" : "/dev/null") + endif +else + let s:redir= "" +endif + +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() 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() 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() 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 !'.. + \ (( =~? '\v<\f+\.(exe|com|bat|cmd)>') ? + \ 'cmd.exe /c start "" /b' trim() : + \ 'nohup ' trim() s:redir '&') + \ | redraw! + else + command -complete=shellcmd -nargs=1 -bang Launch + \ exe ':silent ! nohup' trim() s:redir '&' | redraw! + endif +elseif has('win32') + command -complete=shellcmd -nargs=1 -bang Launch + \ exe 'silent !'.. (&shell =~? '\' ? '' : 'cmd.exe /c') + \ 'start /b ' trim() 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' + else + s:cmd = '' + endif + function s:Open(cmd, file) + if empty(a:cmd) && !exists('g:netrw_browsex_viewer') + echoerr "No program to open this path found. See :help Open for more information." + else + Launch cmd shellescape(a:file, 1) + endif + endfunction + command -complete=file -nargs=1 Open call s:Open(s:cmd, ) +endif + +if !exists('g:netrw_regex_url') + let g:netrw_regex_url = '\%(\%(http\|ftp\|irc\)s\?\|file\)://\S\{-}' +endif + +" " }}} " Local Browsing Autocmds: {{{2 augroup FileExplorer au! -- cgit From 64bca57dc6822eac9d97ab6e946fb387df9e9ae3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 31 Oct 2024 18:55:18 +0800 Subject: vim-patch:7c96776: runtime(netrw): fix syntax error in netrwPlugin.vim https://github.com/vim/vim/commit/7c96776729a671b7c5f6be81bc29d860920ea1c1 Co-authored-by: Christian Brabandt --- runtime/plugin/netrwPlugin.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'runtime/plugin') diff --git a/runtime/plugin/netrwPlugin.vim b/runtime/plugin/netrwPlugin.vim index 59fb7e727e..3cf9082aa6 100644 --- a/runtime/plugin/netrwPlugin.vim +++ b/runtime/plugin/netrwPlugin.vim @@ -36,8 +36,8 @@ set cpo&vim " surpress output of command; use bang for GUI applications " set up redirection (avoids browser messages) -" by default, g:netrw_suppress_gx_mesg is true -if get(g:, ':netrw_suppress_gx_mesg', 1) +" by default if not set, g:netrw_suppress_gx_mesg is true +if get(g:, 'netrw_suppress_gx_mesg', 1) if &srr =~# "%s" let s:redir = printf(&srr, has("win32") ? "nul" : "/dev/null") else @@ -96,7 +96,7 @@ if exists(':Launch') == 2 elseif executable('open') let s:cmd = 'open' else - s:cmd = '' + let s:cmd = '' endif function s:Open(cmd, file) if empty(a:cmd) && !exists('g:netrw_browsex_viewer') -- cgit From 2ce26010a6627cfb1207c554d8989c017e106d34 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 31 Oct 2024 18:55:39 +0800 Subject: vim-patch:7019788: runtime(netrw): improve netrw's open-handling further closes: vim/vim#15956 https://github.com/vim/vim/commit/70197885a8957071e4ab6816141ce6e8026635c6 Co-authored-by: Enno --- runtime/plugin/netrwPlugin.vim | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) (limited to 'runtime/plugin') diff --git a/runtime/plugin/netrwPlugin.vim b/runtime/plugin/netrwPlugin.vim index 3cf9082aa6..b46ee39f74 100644 --- a/runtime/plugin/netrwPlugin.vim +++ b/runtime/plugin/netrwPlugin.vim @@ -35,17 +35,18 @@ set cpo&vim " Commands Launch/URL {{{2 " surpress output of command; use bang for GUI applications -" 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" - let s:redir = printf(&srr, has("win32") ? "nul" : "/dev/null") - else - let s:redir= &srr .. (has("win32") ? "nul" : "/dev/null") +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 -else - let s:redir= "" -endif + return '' +endfunc if has('unix') if has('win32unix') @@ -60,26 +61,26 @@ if has('unix') " 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() s:redir | redraw! + \ exe 'silent !start "" //b' trim() 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() s:redir | redraw! + \ exe 'silent !cmd //c start "" //b' trim() 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 !'.. \ (( =~? '\v<\f+\.(exe|com|bat|cmd)>') ? \ 'cmd.exe /c start "" /b' trim() : - \ 'nohup ' trim() s:redir '&') + \ 'nohup ' trim() s:redir() '&') \ | redraw! else command -complete=shellcmd -nargs=1 -bang Launch - \ exe ':silent ! nohup' trim() s:redir '&' | redraw! + \ exe ':silent ! nohup' trim() s:redir() '&' | redraw! endif elseif has('win32') command -complete=shellcmd -nargs=1 -bang Launch \ exe 'silent !'.. (&shell =~? '\' ? '' : 'cmd.exe /c') - \ 'start /b ' trim() s:redir | redraw! + \ 'start /b ' trim() s:redir() | redraw! endif if exists(':Launch') == 2 " Git Bash @@ -95,17 +96,15 @@ if exists(':Launch') == 2 " MacOS elseif executable('open') let s:cmd = 'open' - else - let s:cmd = '' endif - function s:Open(cmd, file) - if empty(a:cmd) && !exists('g:netrw_browsex_viewer') + 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 - Launch cmd shellescape(a:file, 1) + exe 'Launch' s:cmd shellescape(a:file, 1) endif endfunction - command -complete=file -nargs=1 Open call s:Open(s:cmd, ) + command -complete=file -nargs=1 Open call s:Open() endif if !exists('g:netrw_regex_url') -- cgit From 122cd35e4dac32a89179dcba171e8ad80c0828a3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 31 Oct 2024 18:55:59 +0800 Subject: vim-patch:d69ffbe: runtime(netrw): add missing change for s:redir() Somehow, that change got lost in commit 70197885 https://github.com/vim/vim/commit/d69ffbe4bc2196c4fc2b9377167a9a194213a686 Co-authored-by: Christian Brabandt --- runtime/plugin/netrwPlugin.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'runtime/plugin') diff --git a/runtime/plugin/netrwPlugin.vim b/runtime/plugin/netrwPlugin.vim index b46ee39f74..c31eed525e 100644 --- a/runtime/plugin/netrwPlugin.vim +++ b/runtime/plugin/netrwPlugin.vim @@ -5,6 +5,7 @@ " Last Change: " 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 " Former Maintainer: Charles E Campbell " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim " Copyright: Copyright (C) 1999-2021 Charles E. Campbell {{{1 @@ -53,7 +54,7 @@ if has('unix') " 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() s:redir | redraw! + \ exe 'silent ! cygstart --hide' trim() 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 -- cgit From 35e07a24a329fdd7f35640843c9bc983185ca04e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 31 Oct 2024 18:59:44 +0800 Subject: 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 Co-authored-by: Aliaksei Budavei <0x000c70@gmail.com> --- runtime/plugin/netrwPlugin.vim | 81 ++---------------------------------------- 1 file changed, 3 insertions(+), 78 deletions(-) (limited to 'runtime/plugin') 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() 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() 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() 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 !'.. - \ (( =~? '\v<\f+\.(exe|com|bat|cmd)>') ? - \ 'cmd.exe /c start "" /b' trim() : - \ 'nohup ' trim() s:redir() '&') - \ | redraw! - else - command -complete=shellcmd -nargs=1 -bang Launch - \ exe ':silent ! nohup' trim() s:redir() '&' | redraw! - endif -elseif has('win32') - command -complete=shellcmd -nargs=1 -bang Launch - \ exe 'silent !'.. (&shell =~? '\' ? '' : 'cmd.exe /c') - \ 'start /b ' trim() 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() -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()) +command -complete=file -nargs=1 Open call netrw#Open(trim()) " " }}} " Local Browsing Autocmds: {{{2 augroup FileExplorer -- cgit From baf74ef9755e19781f52c3884023321c0198a3b5 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Mon, 4 Nov 2024 21:54:34 +0100 Subject: vim-patch:59834ba: runtime(matchparen): Add matchparen_disable_cursor_hl config option Set the "matchparen_disable_cursor_hl" config variable to disable highlighting the cursor with the MatchParen highlighting group. closes: vim/vim#15984 https://github.com/vim/vim/commit/59834ba6df10dc48565bf55ac6c8e8a4aa40210b Co-authored-by: Matteo Landi --- runtime/plugin/matchparen.vim | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'runtime/plugin') diff --git a/runtime/plugin/matchparen.vim b/runtime/plugin/matchparen.vim index 2899612dce..661a34b578 100644 --- a/runtime/plugin/matchparen.vim +++ b/runtime/plugin/matchparen.vim @@ -17,6 +17,9 @@ endif if !exists("g:matchparen_insert_timeout") let g:matchparen_insert_timeout = 60 endif +if !exists("g:matchparen_disable_cursor_hl") + let g:matchparen_disable_cursor_hl = 0 +endif let s:has_matchaddpos = exists('*matchaddpos') @@ -189,10 +192,18 @@ func s:Highlight_Matching_Pair() " If a match is found setup match highlighting. if m_lnum > 0 && m_lnum >= stoplinetop && m_lnum <= stoplinebottom if s:has_matchaddpos - call add(w:matchparen_ids, matchaddpos('MatchParen', [[c_lnum, c_col - before], [m_lnum, m_col]], 10)) + if !g:matchparen_disable_cursor_hl + call add(w:matchparen_ids, matchaddpos('MatchParen', [[c_lnum, c_col - before], [m_lnum, m_col]], 10)) + else + call add(w:matchparen_ids, matchaddpos('MatchParen', [[m_lnum, m_col]], 10)) + endif else - exe '3match MatchParen /\(\%' . c_lnum . 'l\%' . (c_col - before) . - \ 'c\)\|\(\%' . m_lnum . 'l\%' . m_col . 'c\)/' + if !g:matchparen_disable_cursor_hl + exe '3match MatchParen /\(\%' . c_lnum . 'l\%' . (c_col - before) . + \ 'c\)\|\(\%' . m_lnum . 'l\%' . m_col . 'c\)/' + else + exe '3match MatchParen /\(\%' . m_lnum . 'l\%' . m_col . 'c\)/' + endif call add(w:matchparen_ids, 3) endif let w:paren_hl_on = 1 -- cgit