forked from zbirenbaum/copilot.lua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpanel.lua
More file actions
48 lines (40 loc) · 1.44 KB
/
Copy pathpanel.lua
File metadata and controls
48 lines (40 loc) · 1.44 KB
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
local util = require("copilot.util")
local panel = {
callback = {
PanelSolution = {},
PanelSolutionsDone = {},
},
}
panel._handlers = {
---@param result { panelId: string, completionText: string, displayText: string, range: { ['end']: { character: integer, line: integer }, start: { character: integer, line: integer } }, score: number, solutionId: string }
PanelSolution = function(_, result)
if panel.callback.PanelSolution[result.panelId] then
panel.callback.PanelSolution[result.panelId](result)
end
end,
---@param result { panelId: string, status: 'OK'|'Error', message?: string }
PanelSolutionsDone = function(_, result)
if panel.callback.PanelSolutionsDone[result.panelId] then
panel.callback.PanelSolutionsDone[result.panelId](result)
end
end,
}
function panel.get_next_id() end
function panel.register(panelId, cb)
assert(type(panelId) == "string", "missing panelId")
panel.callback.PanelSolution[panelId] = cb.on_solution
panel.callback.PanelSolutionsDone[panelId] = cb.on_solutions_done
end
function panel.unregister(panelId)
assert(type(panelId) == "string", "missing panelId")
panel.callback.PanelSolution[panelId] = nil
panel.callback.PanelSolutionsDone[panelId] = nil
end
function panel.get_completions(params, callback)
local client = util.get_copilot_client()
if client then
return client.rpc.request("getPanelCompletions", params, callback)
end
return false
end
return panel