Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lua/pantran/utils/buffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,15 @@ end
function buffer.get_mappings(buf, mode)
local mappings = {}
for _, mapping in ipairs(vim.api.nvim_buf_get_keymap(buf, mode)) do
local id = tonumber(mapping.rhs:match("^.+%[(%d+)%]"))
mappings[mapping.lhs] = id and buffer.callbacks[buf][id] or mapping.rhs
local rhs = mapping.rhs
if rhs ~= nil then
local id = rhs:match("^.+%[(%d+)%]")
id = id and tonumber(id) or nil
local cb = (id and buffer.callbacks[buf] and buffer.callbacks[buf][id]) or rhs
if cb ~= nil then
mappings[mapping.lhs] = cb
end
end
end
return mappings
end
Expand Down