aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-07-05 16:31:45 +0800
committerGitHub <noreply@github.com>2023-07-05 16:31:45 +0800
commitdf297e3c2bd743616371db73467a3f08d2b96d9b (patch)
tree6f89c896142a3ba498903b2f168d45b6493479df
parent317038e7cb11d3db3f3b4679e260de4e119c210c (diff)
downloadrneovim-df297e3c2bd743616371db73467a3f08d2b96d9b.tar.gz
rneovim-df297e3c2bd743616371db73467a3f08d2b96d9b.tar.bz2
rneovim-df297e3c2bd743616371db73467a3f08d2b96d9b.zip
fix(runtime): don't set gx mapping if already mapped (#24262)
This matches netrw's use of maparg().
-rw-r--r--runtime/plugin/nvim.lua16
1 files changed, 10 insertions, 6 deletions
diff --git a/runtime/plugin/nvim.lua b/runtime/plugin/nvim.lua
index 33d399e577..e3d4625c3b 100644
--- a/runtime/plugin/nvim.lua
+++ b/runtime/plugin/nvim.lua
@@ -36,9 +36,13 @@ local function do_open(uri)
vim.notify(err, vim.log.levels.ERROR)
end
end
-vim.keymap.set({ 'n' }, 'gx', function()
- do_open(vim.fn.expand('<cfile>'))
-end, { desc = gx_desc })
-vim.keymap.set({ 'x' }, 'gx', function()
- do_open(get_visual_selection())
-end, { desc = gx_desc })
+if vim.fn.maparg('gx', 'n') == '' then
+ vim.keymap.set({ 'n' }, 'gx', function()
+ do_open(vim.fn.expand('<cfile>'))
+ end, { desc = gx_desc })
+end
+if vim.fn.maparg('gx', 'x') == '' then
+ vim.keymap.set({ 'x' }, 'gx', function()
+ do_open(get_visual_selection())
+ end, { desc = gx_desc })
+end