mirror of
https://github.com/vim/vim
synced 2025-07-15 08:41:54 +00:00
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>
This commit is contained in:
committed by
Christian Brabandt
parent
46b02602d6
commit
c877057e81
@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user