-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.lua
92 lines (80 loc) · 3.36 KB
/
config.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
local M = {}
---@class SymbolProvider
---@field name? string optional name of the provider, if not given, will be set to its key in table
---@field dir string|nil path to a directory containing symbols, if given takes precedence over url field
---@field url string|nil url to a symbol server
---@field auth string[]|nil basic auth information ("user:pass"), or see plenary.curl for other formats
---@field timeout integer|nil timeout to wait for curl request (defaults to plenary.curl's timeout [10000])
---@alias ElementPosition "left"|"right"|"below"|"above"
---@class ViewElementConfig
---@field width integer
---@field height integer
---@field position ElementPosition
---@field keys table<string, string|fun(win: integer, buf: integer)>
---@alias ViewElementDefinition "modules"|"threads"|"crash"|"stack"|ViewElementDefinition[]
---@class ViewConfig
---@field elements ViewElementDefinition[] defines the view elements to show. Root elements will be created by splitting the initial window
---If given an array, the first element will be created by splitting the initial window, following elements by splitting the predecessor element
---@field threads ViewElementConfig
---@field crash ViewElementConfig
---@field stack ViewElementConfig
---@field modules ViewElementConfig
---@class ConfigOptions
---@field stackwalk_path? string|nil path the minidump_stackwalk binary lives in
---@field symbol_providers table<string, SymbolProvider>
---@field load_module? (fun(module: ModuleDefinition): boolean,string|nil)|nil filter function to decide if symbols should be loaded for the given module and optionally return a preferred symbol privder (key in symbol_providers) which is tried first
---@field try_all_providers? boolean if true and the debug symbols can't be found at the preferred provider from load_module, try all others (always true if load_module == nil or load_module does not return a preferred provider)
---@field on_symbol_loaded? (fun(osinfo: SystemInfo, sympath: string))|nil callback which is called after a symbol was loaded
---@field to_local_source? (fun(path: string): string)|nil map the source path contained in the crashdump to a local file path (if == nil, the source path is used as it)
---@field jump_to_first_frame? boolean|nil after loading the crashdump, jump to the source of the top frame of the crashed thread
---@field view? ViewConfig|nil
local defaults = {
stackwalk_path = nil,
symbol_providers = {},
load_module = nil,
try_all_providers = false,
on_symbol_loaded = nil,
to_local_source = nil,
jump_to_first_frame = true,
view = {
elements = {{"threads", "crash", "stack"}, "modules"},
modules = {
width = 40,
height = 80,
position = "right",
keys = {},
},
threads = {
width = 40,
height = 20,
position = "below",
keys = {},
},
crash = {
width = 40,
height = 20,
position = "right",
keys = {},
},
stack = {
width = 40,
height = 20,
position = "right",
keys = {
["<cr>"] = "jump",
}
},
}
}
---@type ConfigOptions
---@diagnostic disable-next-line: missing-fields
M.options = {}
M.setup = function(opts)
M.options = vim.tbl_deep_extend("force", defaults, opts or {})
for key, prov in pairs(M.options.symbol_providers) do
if prov.name == nil or prov.name == "" then
prov.name = key
end
end
end
return M