forked from zbirenbaum/copilot.lua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.lua
More file actions
72 lines (62 loc) · 1.42 KB
/
config.lua
File metadata and controls
72 lines (62 loc) · 1.42 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
---@class copilot_config
local default_config = {
---@class copilot_config_panel
panel = {
enabled = true,
auto_refresh = false,
---@type table<'accept'|'next'|'prev'|'dismiss', false|string>
keymap = {
jump_prev = "[[",
jump_next = "]]",
accept = "<CR>",
refresh = "gr",
open = "<M-CR>",
},
},
---@class copilot_config_suggestion
suggestion = {
enabled = true,
auto_trigger = false,
debounce = 75,
---@type table<'accept'|'next'|'prev'|'dismiss', false|string>
keymap = {
accept = "<M-l>",
next = "<M-]>",
prev = "<M-[>",
dismiss = "<C-]>",
},
},
---@deprecated
ft_disable = nil,
---@type table<string, boolean>
filetypes = {},
copilot_node_command = "node",
server_opts_overrides = {},
}
local mod = {
config = nil,
}
function mod.setup(opts)
if mod.config then
vim.notify("[copilot] config is already set", vim.log.levels.WARN)
return
end
local config = vim.tbl_deep_extend("force", default_config, opts or {})
--- for backward compatibility
if config.ft_disable then
for _, disabled_ft in ipairs(config.ft_disable) do
config.filetypes[disabled_ft] = false
end
config.ft_disable = nil
end
mod.config = config
return mod.config
end
---@param key? string
function mod.get(key)
if mod.config and key then
return mod.config[key]
end
return mod.config
end
return mod