From: Mark Woods Date: Sun, 22 Jun 2025 18:12:16 +0000 (+0200) Subject: runtime(openPlugin): add -mappings X-Git-Tag: v9.1.1475~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c877057e8181783000c7050a955b42f4ccf365e1;p=thirdparty%2Fvim.git runtime(openPlugin): add -mappings vim9script mappings relying on imports cannot be evaluated outside of the script file with the imports, so do not work with plugins like vim-which-key, which applies the mappings using feedkeys(). Using mappings is one way to address this, and has the added benefit of reading like a description for users finding the mappings. related: #17563 Signed-off-by: Mark Woods Signed-off-by: Christian Brabandt --- diff --git a/runtime/plugin/openPlugin.vim b/runtime/plugin/openPlugin.vim index ff9c5a3857..b7274aadda 100644 --- a/runtime/plugin/openPlugin.vim +++ b/runtime/plugin/openPlugin.vim @@ -3,7 +3,7 @@ vim9script # Vim runtime support library # # Maintainer: The Vim Project -# Last Change: 2025 Jun 11 +# Last Change: 2025 Jun 22 if exists("g:loaded_openPlugin") || &cp finish @@ -34,10 +34,12 @@ if !no_gx enddef if maparg('gx', 'n') == "" - nnoremap gx vim9.Open(GetWordUnderCursor()) + nnoremap (open-word-under-cursor) vim9.Open(GetWordUnderCursor()) + nmap gx (open-word-under-cursor) endif if maparg('gx', 'x') == "" - xnoremap gx vim9.Open(getregion(getpos('v'), getpos('.'), { type: mode() })->join()) + xnoremap (open-word-under-cursor) vim9.Open(getregion(getpos('v'), getpos('.'), { type: mode() })->join()) + xmap gx (open-word-under-cursor) endif endif