diff --git a/lua/submode/init.lua b/lua/submode/init.lua index 477a3c7..bd19b70 100644 --- a/lua/submode/init.lua +++ b/lua/submode/init.lua @@ -53,8 +53,9 @@ function M.create(name, opts, default) state.submode_to_user_mappings[name] = {} state.submode_to_default_mappings[name] = {} - local listlized_enter = utils.listlize(opts.enter) --[=[@as string[]]=] - for _, enter in ipairs(listlized_enter) do + for _, enter in + ipairs(utils.listlize(opts.enter) --[=[@as string[]]=]) + do vim.keymap.set(opts.mode, enter, function() M.enter(name) end) diff --git a/lua/submode/mode.lua b/lua/submode/mode.lua index 7cece75..9f817d4 100644 --- a/lua/submode/mode.lua +++ b/lua/submode/mode.lua @@ -11,12 +11,9 @@ end ---@return fun(): boolean local function fany(preds) return function() - for _, pred in ipairs(preds) do - if pred() then - return true - end - end - return false + return vim.iter(preds):any(function(pred) + return pred() + end) end end