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
31 lines (27 loc) · 1.01 KB
/
Copy pathpanel.lua
File metadata and controls
31 lines (27 loc) · 1.01 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
local util = require("copilot.util")
local panel = {
usecmp = false,
client = {},
buf = "",
uri = "copilot:///placeholder",
requests = {},
}
panel.send_request = function (opts)
opts = opts or {}
local client = opts.client or not vim.tbl_isempty(panel.client) and panel.client or util.get_copilot_client()
if not panel.client then return end
local completion_params = util.get_completion_params()
completion_params.panelId = opts.uri or panel.uri
local callback = opts.callback or function () end
return client.rpc.request("getPanelCompletions", completion_params, callback)
end
function panel.create (client, max_results)
panel.client = client or util.get_copilot_client()
if not panel.client then print("Error, copilot not running") end
panel.max_results = max_results or 10
panel.buf = type(panel.uri) == "number" or vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_name(panel.buf, "pb" .. tostring(panel.buf))
panel.uri = vim.uri_from_bufnr(panel.buf)
return panel
end
return panel