feat: add submap support and add pass_through submap
This commit is contained in:
+14
-1
@@ -1,23 +1,36 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
local bind = require("lua.lib.bind")
|
local bind = require("lua.lib.bind")
|
||||||
|
local utils = require("lua.lib.utils")
|
||||||
|
|
||||||
local pieces = {
|
local pieces = {
|
||||||
"apps",
|
"apps",
|
||||||
"window",
|
"window",
|
||||||
"workspace",
|
"workspace",
|
||||||
|
"passthrough",
|
||||||
}
|
}
|
||||||
|
|
||||||
M.binds = {}
|
M.binds = {}
|
||||||
|
M.submaps = {}
|
||||||
|
|
||||||
for _, piece in pairs(pieces) do
|
for _, piece in pairs(pieces) do
|
||||||
local bind_piece = require("lua.binds." .. piece).binds
|
local p = require("lua.binds." .. piece)
|
||||||
|
local bind_piece = p.binds
|
||||||
for _, bind_item in pairs(bind_piece) do
|
for _, bind_item in pairs(bind_piece) do
|
||||||
table.insert(M.binds, bind_item)
|
table.insert(M.binds, bind_item)
|
||||||
end
|
end
|
||||||
|
local submap = p.submaps
|
||||||
|
if submap then
|
||||||
|
M.submaps = utils.tbl_recursive_merge(M.submaps, submap)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.load()
|
function M.load()
|
||||||
bind.map(M.binds)
|
bind.map(M.binds)
|
||||||
|
for name, binds in pairs(M.submaps) do
|
||||||
|
hl.define_submap(name, function()
|
||||||
|
bind.map(binds)
|
||||||
|
end)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
local bind = require("lua.lib.bind")
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.binds = {
|
||||||
|
{
|
||||||
|
keys = bind.with_leader("P"),
|
||||||
|
dispatcher = hl.dsp.submap("pass_through"),
|
||||||
|
desc = "Pass through submap",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
M.submaps = {
|
||||||
|
pass_through = {
|
||||||
|
{
|
||||||
|
keys = bind.with_leader("escape"),
|
||||||
|
dispatcher = hl.dsp.submap("reset"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return M
|
||||||
Reference in New Issue
Block a user