-
-
Notifications
You must be signed in to change notification settings - Fork 106
/
Copy pathframes.lua
64 lines (53 loc) · 1.9 KB
/
frames.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
local config = require("dapui.config")
local util = require("dapui.util")
---@param client dapui.DAPClient
return function(client, send_ready)
client.listen.scopes(send_ready)
client.listen.terminated(send_ready)
client.listen.exited(send_ready)
client.listen.disconnect(send_ready)
return {
---@async
---@param canvas dapui.Canvas
render = function(canvas, thread_id, show_subtle, indent)
local success, response = pcall(client.request.stackTrace, { threadId = thread_id })
local current_frame_id = nil
if not success then
return
end
local frames = response.stackFrames
if not show_subtle then
frames = vim.tbl_filter(function(frame)
return frame.presentationHint ~= "subtle"
end, frames)
end
if client.session then
current_frame_id = client.session.current_frame and client.session.current_frame.id
end
for _, frame in ipairs(frames) do
local is_current = frame.id == current_frame_id
canvas:write(string.rep(" ", is_current and (indent - 1) or indent))
if is_current then
canvas:write(config.icons.current_frame .. " ")
end
canvas:write(
frame.name,
{ group = frame.id == current_frame_id and "DapUICurrentFrameName" or "DapUIFrameName" }
)
canvas:write(" ")
if frame.source ~= nil then
local file_name = frame.source.name or frame.source.path or "<unknown>"
local source_name = util.pretty_name(file_name)
canvas:write(source_name, { group = "DapUISource" })
end
if frame.line ~= nil then
canvas:write(":")
canvas:write(frame.line, { group = "DapUILineNumber" })
end
canvas:add_mapping("open", util.partial(client.lib.jump_to_frame, frame, true))
canvas:write("\n")
end
canvas:remove_line()
end,
}
end