runtime(openPlugin): add <Plug>-mappings
vim9script <scriptcmd> 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 <Plug> 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 <mwoods.online.ie@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/runtime/plugin/openPlugin.vim b/runtime/plugin/openPlugin.vim
index ff9c5a3..b7274aa 100644
--- a/runtime/plugin/openPlugin.vim
+++ b/runtime/plugin/openPlugin.vim
@@ -3,7 +3,7 @@
# Vim runtime support library
#
# Maintainer: The Vim Project <https://github.com/vim/vim>
-# Last Change: 2025 Jun 11
+# Last Change: 2025 Jun 22
if exists("g:loaded_openPlugin") || &cp
finish
@@ -34,10 +34,12 @@
enddef
if maparg('gx', 'n') == ""
- nnoremap <unique> gx <scriptcmd>vim9.Open(GetWordUnderCursor())<CR>
+ nnoremap <Plug>(open-word-under-cursor) <scriptcmd>vim9.Open(GetWordUnderCursor())<CR>
+ nmap gx <Plug>(open-word-under-cursor)
endif
if maparg('gx', 'x') == ""
- xnoremap <unique> gx <scriptcmd>vim9.Open(getregion(getpos('v'), getpos('.'), { type: mode() })->join())<CR>
+ xnoremap <Plug>(open-word-under-cursor) <scriptcmd>vim9.Open(getregion(getpos('v'), getpos('.'), { type: mode() })->join())<CR>
+ xmap gx <Plug>(open-word-under-cursor)
endif
endif