Skip to content

Commit

Permalink
fix(keys): only replace localleader and maplocalleader. Fixes #307, f…
Browse files Browse the repository at this point in the history
…ixes #308
  • Loading branch information
folke committed Jan 4, 2023
1 parent a11a317 commit 507b695
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lua/lazy/core/handler/keys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,10 +41,12 @@ function M.retrigger(keys)
if op and op ~= "" and vim.api.nvim_get_mode().mode:find("o") then
keys = "<esc>" .. 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)

This comment has been minimized.

Copy link
@mathjiajia

mathjiajia Jan 4, 2023

do we really need this?

This comment has been minimized.

Copy link
@folke

folke Jan 4, 2023

Author Owner

sorry, debug output. removed now

vim.api.nvim_input(feed)
end

Expand Down

0 comments on commit 507b695

Please sign in to comment.