Skip to content

Commit

Permalink
refactor: simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
pogyomo committed Jun 14, 2024
1 parent fe9f6d2 commit 5d9596f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
5 changes: 3 additions & 2 deletions lua/submode/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 3 additions & 6 deletions lua/submode/mode.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 5d9596f

Please sign in to comment.