From a9b9a4b3a2dcc1e81828cfd74bfb61193b014b67 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 21 Jan 2024 11:10:24 +0100 Subject: [PATCH] fix(keys): make sure we don't delete the global mapping when executing an ft keymap. See #1241 --- lua/lazy/core/handler/keys.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/lazy/core/handler/keys.lua b/lua/lazy/core/handler/keys.lua index 6ca2c50..815fcbb 100644 --- a/lua/lazy/core/handler/keys.lua +++ b/lua/lazy/core/handler/keys.lua @@ -163,7 +163,11 @@ end -- mapping when needed ---@param keys LazyKeys function M:_del(keys) - pcall(vim.keymap.del, keys.mode, keys.lhs) + pcall(vim.keymap.del, keys.mode, keys.lhs, { + -- NOTE: for buffer-local mappings, we only delete the mapping for the current buffer + -- So the mapping could still exist in other buffers + buffer = keys.ft and true or nil, + }) -- make sure to create global mappings when needed -- buffer-local mappings are managed by lazy if not keys.ft then