2022-12-05 21:45:50 +08:00
|
|
|
local Util = require("lazy.core.util")
|
|
|
|
local Loader = require("lazy.core.loader")
|
|
|
|
|
|
|
|
---@class LazyKeysHandler:LazyHandler
|
|
|
|
local M = {}
|
|
|
|
|
|
|
|
---@param keys string
|
2022-12-16 16:13:08 +08:00
|
|
|
function M:_add(keys)
|
2022-12-05 21:45:50 +08:00
|
|
|
vim.keymap.set("n", keys, function()
|
|
|
|
vim.keymap.del("n", keys)
|
|
|
|
Util.track({ keys = keys })
|
2022-12-16 16:13:08 +08:00
|
|
|
Loader.load(self.active[keys], { keys = keys })
|
2022-12-22 02:01:58 +08:00
|
|
|
local extra = ""
|
|
|
|
while true do
|
|
|
|
local c = vim.fn.getchar(0)
|
|
|
|
if c == 0 then
|
|
|
|
break
|
|
|
|
end
|
|
|
|
extra = extra .. vim.fn.nr2char(c)
|
|
|
|
end
|
|
|
|
local feed = vim.api.nvim_replace_termcodes(keys .. extra, true, true, true)
|
2022-12-21 01:24:40 +08:00
|
|
|
vim.api.nvim_feedkeys(feed, "m", false)
|
2022-12-05 21:45:50 +08:00
|
|
|
Util.track()
|
2022-12-21 01:24:40 +08:00
|
|
|
end, { silent = true })
|
2022-12-05 21:45:50 +08:00
|
|
|
end
|
|
|
|
|
2022-12-16 16:13:08 +08:00
|
|
|
---@param keys string
|
|
|
|
function M:_del(keys)
|
|
|
|
pcall(vim.keymap.del, "n", keys)
|
2022-12-05 21:45:50 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
return M
|