diff --git a/lua/telescope/builtin/__internal.lua b/lua/telescope/builtin/__internal.lua index dc4d1d8..6dc1363 100644 --- a/lua/telescope/builtin/__internal.lua +++ b/lua/telescope/builtin/__internal.lua @@ -1311,6 +1311,19 @@ internal.autocommands = function(opts) return false end local val = selection.value + local cb = val.callback + if vim.is_callable(cb) then + if type(cb) ~= "string" then + local f = type(cb) == "function" and cb or rawget(getmetatable(cb), "__call") + local info = debug.getinfo(f, "S") + local file = info.source:match "^@(.+)" + local lnum = info.linedefined + if file and (lnum or 0) > 0 then + selection.filename, selection.lnum, selection.col = file, lnum, 1 + return false + end + end + end local group_name = val.group_name ~= "" and val.group_name or "" local output = vim.fn.execute("verb autocmd " .. group_name .. " " .. val.event .. " " .. val.pattern, "silent") diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua index ebb9085..ba7a16a 100644 --- a/lua/telescope/make_entry.lua +++ b/lua/telescope/make_entry.lua @@ -1232,6 +1232,7 @@ function make_entry.gen_from_autocommands(opts) group_name = group_name, pattern = entry.pattern, command = command, + callback = entry.callback, }, -- ordinal = entry.event .. " " .. group_name .. " " .. entry.pattern .. " " .. entry.command,