feat(libmodal): `mode.map.fn`

pull/36/head
Iron-E 3 months ago
parent 974c40cfc6
commit 239f356394
No known key found for this signature in database
GPG Key ID: 569E791B76A42A1A

@ -61,6 +61,26 @@ end
libmodal.mode.map = {}
--- Example:
--- ```lua
--- {
--- a = vim.cmd.undo, -- Error
--- b = function() vim.cmd.undo() end, -- OK
--- c = fn(vim.cmd.undo), -- Good
--- }
--- ```
---
--- @generic T
--- @param f fun(...: T) the function to map
--- @param ... T arguments to `f`
--- @return fun() # that calls `f` which the arguments provided
function libmodal.mode.map.fn(f, ...)
local args = { ... }
return function()
f(unpack(args))
end
end
--- `enter` a mode using the arguments given, and do not return to the current mode.
---
--- Example:

Loading…
Cancel
Save