diff --git a/lua/lazy/core/handler/keys.lua b/lua/lazy/core/handler/keys.lua index a6e9475..57fbc18 100644 --- a/lua/lazy/core/handler/keys.lua +++ b/lua/lazy/core/handler/keys.lua @@ -102,6 +102,11 @@ function M.opts(keys) return opts end +---@param keys LazyKeys +function M.is_nop(keys) + return type(keys.rhs) == "string" and (keys.rhs == "" or keys.rhs:lower() == "") +end + ---@param keys LazyKeys function M:_add(keys) local lhs = keys.lhs @@ -109,7 +114,7 @@ function M:_add(keys) ---@param buf? number local function add(buf) - if type(keys.rhs) == "string" and (keys.rhs == "" or keys.rhs:lower() == "") then + if M.is_nop(keys) then return self:_set(keys, buf) end @@ -147,7 +152,7 @@ function M:_add(keys) vim.api.nvim_create_autocmd("FileType", { pattern = keys.ft, callback = function(event) - if self.active[keys.id] then + if self.active[keys.id] and not M.is_nop(keys) then add(event.buf) else -- Only create the mapping if its managed by lazy