forked from zbirenbaum/copilot.lua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
52 lines (44 loc) · 1.22 KB
/
init.lua
File metadata and controls
52 lines (44 loc) · 1.22 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
49
50
51
52
local M = { client_info = nil }
local client = require("copilot.client")
local defaults = {
cmp = {
enabled = true,
method = "getPanelCompletions",
},
panel = { -- no config options yet
enabled = true,
},
ft_disable = {},
plugin_manager_path = vim.fn.stdpath("data") .. "/site/pack/packer",
server_opts_overrides = {},
settings = {
advanced = {
listCount = 10, -- #completions for panel
inlineSuggestCount = 3, -- #completions for getCompletions
}
}
}
local create_cmds = function (_)
vim.api.nvim_create_user_command("CopilotPanel", function ()
local panel = require("copilot.extensions.panel").create()
panel.send_request()
require("copilot.extensions.print_panel").create(panel.buf)
end, {})
end
local config_handler = function(opts)
local user_config = opts and vim.tbl_deep_extend("force", defaults, opts) or defaults
return user_config
end
M.setup = function(opts)
local user_config = config_handler(opts)
vim.schedule(function ()
client.start(user_config)
if user_config.cmp.enabled then
require("copilot_cmp").setup(user_config.cmp.method)
end
if user_config.panel.enabled then
create_cmds(user_config)
end
end)
end
return M