Skip to content

Commit

Permalink
feat(mappings): added support for lazy.nvim style mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jul 12, 2024
1 parent 44a6ea4 commit 6f7a945
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lua/which-key/mappings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,19 @@ function M._parse(value, parent, ret)

if count == 1 then
assert(type(value[1]) == "string", "Invalid mapping " .. vim.inspect(value))
mapping.desc = value[1] --[[@as string]]
if mapping.desc then
mapping.lhs = value[1] --[[@as string]]
else
mapping.desc = value[1] --[[@as string]]
end
elseif count == 2 then
mapping.rhs = value[1] --[[@as string]]
mapping.desc = value[2] --[[@as string]]
if mapping.desc then
mapping.lhs = value[1] --[[@as string]]
mapping.rhs = value[2] --[[@as string]]
else
mapping.rhs = value[1] --[[@as string]]
mapping.desc = value[2] --[[@as string]]
end
elseif count > 2 then
Util.error("Invalid mapping " .. vim.inspect(value))
end
Expand Down

0 comments on commit 6f7a945

Please sign in to comment.