From 507b695753b4a7e1eff75f578b7a04b6307e4bc6 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 4 Jan 2023 07:54:35 +0100 Subject: [PATCH] fix(keys): only replace localleader and maplocalleader. Fixes #307, fixes #308 --- lua/lazy/core/handler/keys.lua | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lua/lazy/core/handler/keys.lua b/lua/lazy/core/handler/keys.lua index 9399dff..559e7e3 100644 --- a/lua/lazy/core/handler/keys.lua +++ b/lua/lazy/core/handler/keys.lua @@ -13,6 +13,19 @@ local Loader = require("lazy.core.loader") ---@class LazyKeysHandler:LazyHandler local M = {} +---@param feed string +function M.replace_special(feed) + for special, key in pairs({ leader = vim.g.mapleader, localleader = vim.g.maplocalleader }) do + local pattern = "<" + for i = 1, #special do + pattern = pattern .. "[" .. special:sub(i, i) .. special:upper():sub(i, i) .. "]" + end + pattern = pattern .. ">" + feed = feed:gsub(pattern, key) + end + return feed +end + function M.retrigger(keys) local pending = "" while true do @@ -28,10 +41,12 @@ function M.retrigger(keys) if op and op ~= "" and vim.api.nvim_get_mode().mode:find("o") then keys = "" .. op .. keys end - local feed = vim.api.nvim_replace_termcodes(keys, true, true, true) .. pending + local feed = keys .. pending + feed = M.replace_special(feed) if vim.v.count ~= 0 then feed = vim.v.count .. feed end + vim.notify(feed) vim.api.nvim_input(feed) end