diff --git a/lua/pantran/utils/buffer.lua b/lua/pantran/utils/buffer.lua index 0312e62..bea337d 100644 --- a/lua/pantran/utils/buffer.lua +++ b/lua/pantran/utils/buffer.lua @@ -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