mirror of https://github.com/folke/lazy.nvim.git
fix(keys): buffer-local nop mappings
This commit is contained in:
parent
0c1ec520af
commit
ff90417808
|
@ -102,6 +102,11 @@ function M.opts(keys)
|
||||||
return opts
|
return opts
|
||||||
end
|
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
|
---@param keys LazyKeys
|
||||||
function M:_add(keys)
|
function M:_add(keys)
|
||||||
local lhs = keys.lhs
|
local lhs = keys.lhs
|
||||||
|
@ -109,7 +114,7 @@ function M:_add(keys)
|
||||||
|
|
||||||
---@param buf? number
|
---@param buf? number
|
||||||
local function add(buf)
|
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)
|
return self:_set(keys, buf)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -147,7 +152,7 @@ function M:_add(keys)
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
pattern = keys.ft,
|
pattern = keys.ft,
|
||||||
callback = function(event)
|
callback = function(event)
|
||||||
if self.active[keys.id] then
|
if self.active[keys.id] and not M.is_nop(keys) then
|
||||||
add(event.buf)
|
add(event.buf)
|
||||||
else
|
else
|
||||||
-- Only create the mapping if its managed by lazy
|
-- Only create the mapping if its managed by lazy
|
||||||
|
|
Loading…
Reference in New Issue