]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(openPlugin): add <Plug>-mappings
authorMark Woods <mwoods.online.ie@gmail.com>
Sun, 22 Jun 2025 18:12:16 +0000 (20:12 +0200)
committerChristian Brabandt <cb@256bit.org>
Sun, 22 Jun 2025 18:20:23 +0000 (20:20 +0200)
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>
runtime/plugin/openPlugin.vim

index ff9c5a38579918dfd49f052651d6bb7d16ff00fe..b7274aadda4d90967ebbca775ce0507052d23abc 100644 (file)
@@ -3,7 +3,7 @@ vim9script
 # 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 @@ if !no_gx
   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