From 0303a8ea1f3fa830d78dbd78ba7c4c350afbe72a Mon Sep 17 00:00:00 2001 From: un_9bot Date: Thu, 11 Sep 2025 19:46:57 +0300 Subject: [PATCH] fix(help): nil value --- lua/pantran/utils/buffer.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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