feat(builtin.autocommands): support jumping to lua callback src (#2916)
This commit is contained in:
@@ -1311,6 +1311,19 @@ internal.autocommands = function(opts)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local val = selection.value
|
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 ~= "<anonymous>" and val.group_name or ""
|
local group_name = val.group_name ~= "<anonymous>" and val.group_name or ""
|
||||||
local output =
|
local output =
|
||||||
vim.fn.execute("verb autocmd " .. group_name .. " " .. val.event .. " " .. val.pattern, "silent")
|
vim.fn.execute("verb autocmd " .. group_name .. " " .. val.event .. " " .. val.pattern, "silent")
|
||||||
|
|||||||
@@ -1232,6 +1232,7 @@ function make_entry.gen_from_autocommands(opts)
|
|||||||
group_name = group_name,
|
group_name = group_name,
|
||||||
pattern = entry.pattern,
|
pattern = entry.pattern,
|
||||||
command = command,
|
command = command,
|
||||||
|
callback = entry.callback,
|
||||||
},
|
},
|
||||||
--
|
--
|
||||||
ordinal = entry.event .. " " .. group_name .. " " .. entry.pattern .. " " .. entry.command,
|
ordinal = entry.event .. " " .. group_name .. " " .. entry.pattern .. " " .. entry.command,
|
||||||
|
|||||||
Reference in New Issue
Block a user