Skip to content

Commit 507b695

Browse files
committed
fix(keys): only replace localleader and maplocalleader. Fixes #307, fixes #308
1 parent a11a317 commit 507b695

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

lua/lazy/core/handler/keys.lua

+16-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@ local Loader = require("lazy.core.loader")
1313
---@class LazyKeysHandler:LazyHandler
1414
local M = {}
1515

16+
---@param feed string
17+
function M.replace_special(feed)
18+
for special, key in pairs({ leader = vim.g.mapleader, localleader = vim.g.maplocalleader }) do
19+
local pattern = "<"
20+
for i = 1, #special do
21+
pattern = pattern .. "[" .. special:sub(i, i) .. special:upper():sub(i, i) .. "]"
22+
end
23+
pattern = pattern .. ">"
24+
feed = feed:gsub(pattern, key)
25+
end
26+
return feed
27+
end
28+
1629
function M.retrigger(keys)
1730
local pending = ""
1831
while true do
@@ -28,10 +41,12 @@ function M.retrigger(keys)
2841
if op and op ~= "" and vim.api.nvim_get_mode().mode:find("o") then
2942
keys = "<esc>" .. op .. keys
3043
end
31-
local feed = vim.api.nvim_replace_termcodes(keys, true, true, true) .. pending
44+
local feed = keys .. pending
45+
feed = M.replace_special(feed)
3246
if vim.v.count ~= 0 then
3347
feed = vim.v.count .. feed
3448
end
49+
vim.notify(feed)
3550
vim.api.nvim_input(feed)
3651
end
3752

0 commit comments

Comments
 (0)