wip
This commit is contained in:
parent
d1f73bcebc
commit
640128d4a6
1 changed files with 52 additions and 0 deletions
|
@ -31,4 +31,56 @@ M.get_selected_text = function()
|
|||
end)
|
||||
end
|
||||
|
||||
M.keymap_decorator = function(opts)
|
||||
opts = opts or {}
|
||||
|
||||
local decorate_key = function(key)
|
||||
return vim.tbl_extend("force", key, {
|
||||
(opts.lhs_prefix or "") .. key[1], -- lhs
|
||||
key[2], -- rhs
|
||||
desc = (opts.desc_prefix or "") .. key.desc .. (opts.desc_suffix or ""),
|
||||
})
|
||||
end
|
||||
|
||||
return function(keys)
|
||||
if keys and type(keys[1]) == "table" then
|
||||
return vim.iter(keys):map(decorate_key):totable()
|
||||
else
|
||||
return decorate_key(keys)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- M.test = function()
|
||||
-- local key = {
|
||||
-- "a",
|
||||
-- "<cmd>DoA<cr>",
|
||||
-- desc = "this does A",
|
||||
-- mode = "v",
|
||||
-- }
|
||||
|
||||
-- local keys = {
|
||||
-- {
|
||||
-- "a",
|
||||
-- "<cmd>DoA<cr>",
|
||||
-- desc = "this does A",
|
||||
-- mode = "v",
|
||||
-- },
|
||||
-- {
|
||||
-- "b",
|
||||
-- "<cmd>DoB<cr>",
|
||||
-- desc = "this does B",
|
||||
-- mode = "n",
|
||||
-- },
|
||||
-- }
|
||||
|
||||
-- local do_it = M.keymap_decorator {
|
||||
-- lhs_prefix = "<leader>!",
|
||||
-- desc_prefix = "OK: ",
|
||||
-- }
|
||||
|
||||
-- P(do_it(key))
|
||||
-- P(do_it(keys))
|
||||
-- end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Add table
Reference in a new issue