Skip to content

Commit

Permalink
fix(keys): buffer-local nop mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jun 6, 2024
1 parent 0c1ec52 commit ff90417
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lua/lazy/core/handler/keys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,19 @@ 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() == "<nop>")
end

---@param keys LazyKeys
function M:_add(keys)
local lhs = keys.lhs
local opts = M.opts(keys)

---@param buf? number
local function add(buf)
if type(keys.rhs) == "string" and (keys.rhs == "" or keys.rhs:lower() == "<nop>") then
if M.is_nop(keys) then
return self:_set(keys, buf)
end

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ff90417

Please sign in to comment.