Skip to content

Commit

Permalink
fix: handle baskslashes when leader or localleader isn't set
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed May 3, 2021
1 parent cd23fdc commit d155ab3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lua/which-key/keys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,12 @@ function M.hook_add(prefix, mode, buf, secret_only)
-- hook up if needed
if not M.hooked[id] and not M.hooked[id_global] then
local cmd = [[<cmd>lua require("which-key").show(%q, {mode = %q, auto = true})<cr>]]
if vim.g.mapleader == "\\" then prefix = prefix:gsub("<[lL]eader>", "\\") end
if vim.g.maplocalleader == "\\" then prefix = prefix:gsub("<[lL]ocalleader>", "\\") end
if vim.g.mapleader == "\\" or vim.g.mapleader == nil then
prefix = prefix:gsub("<[lL]eader>", "\\")
end
if vim.g.maplocalleader == "\\" or vim.g.maplocalleader == nil then
prefix = prefix:gsub("<[lL]ocalleader>", "\\")
end
cmd = string.format(cmd, prefix, mode)
-- map group triggers and nops
-- nops are needed, so that WhichKey always respects timeoutlen
Expand Down

0 comments on commit d155ab3

Please sign in to comment.