From 76160be5d38cd67e46557cb5d0b3e36ececdfa3c Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 31 Oct 2025 07:41:18 +0100 Subject: [PATCH] fix(picker.keymaps): try to locate neovim compiled lua source files for keymaps --- lua/snacks/picker/source/vim.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lua/snacks/picker/source/vim.lua b/lua/snacks/picker/source/vim.lua index b8854876..d86867f5 100644 --- a/lua/snacks/picker/source/vim.lua +++ b/lua/snacks/picker/source/vim.lua @@ -242,9 +242,15 @@ function M.keymaps(opts) } if km.callback then local info = debug.getinfo(km.callback, "S") + item.info = info if info.what == "Lua" then - item.file = info.source:sub(2) - item.pos = { info.linedefined, 0 } + local source = info.source:sub(2) + item.file = source:gsub("^vim/", vim.env.VIMRUNTIME .. "/lua/vim/") + if source:find("^vim/") and info.linedefined == 0 then + item.search = "/vim\\.keymap\\.set.*['\"]" .. km.lhs + else + item.pos = { info.linedefined, 0 } + end item.preview = "file" end end