fix(keys): properly deal with ft list for keys. Fixes #1448

This commit is contained in:
Folke Lemaitre 2024-05-21 22:10:49 +02:00
parent 9895337d1f
commit 82cf974e09
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 8 additions and 5 deletions

View File

@ -163,11 +163,14 @@ end
function M:_del(keys) function M:_del(keys)
-- bufs will be all buffers of the filetype for a buffer-local mapping -- bufs will be all buffers of the filetype for a buffer-local mapping
-- OR `false` for a global mapping -- OR `false` for a global mapping
local bufs = keys.ft local bufs = { false }
and vim.tbl_filter(function(buf)
return vim.bo[buf].filetype == keys.ft if keys.ft then
end, vim.api.nvim_list_bufs()) local ft = type(keys.ft) == "string" and { keys.ft } or keys.ft --[[@as string[] ]]
or { false } bufs = vim.tbl_filter(function(buf)
return vim.tbl_contains(ft, vim.bo[buf].filetype)
end, vim.api.nvim_list_bufs())
end
for _, buf in ipairs(bufs) do for _, buf in ipairs(bufs) do
pcall(vim.keymap.del, keys.mode, keys.lhs, { buffer = buf or nil }) pcall(vim.keymap.del, keys.mode, keys.lhs, { buffer = buf or nil })