-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfig.lua
More file actions
57 lines (51 loc) · 1.58 KB
/
Copy pathconfig.lua
File metadata and controls
57 lines (51 loc) · 1.58 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
---@class ModelCmp.Config
---@field requests RequestConfig
---@field api ModelCmp.Modelapi.Config
---@field virtualtext table<string, string> virtual text config
---@class RequestConfig
---@field delay_ms integer Request Delay time in ms
---@field max_retries integer Number of retries possible in given timeout
---@field timeout_ms integer Time delay for requests max_retries option
local M = {}
---@return ModelCmp.Config
function M.default()
return {
requests = {
delay_ms = 1000,
max_retries = 5,
timeout_ms = 300000,
},
api = require("model_cmp.modelapi.apiconfig").default,
virtualtext = {
enable = false,
type = "inline",
style = {
-- Setup the Highlight group for Virtual text suggestions
fg = "#b53a3a",
italic = false,
bold = false,
},
},
}
end
---@type ModelCmp.Config
local options
---@param opts? ModelCmp.Config
---@param maingroup integer MainAutoGrp
---@return ModelCmp.Config
function M.setup(opts, maingroup)
opts = opts or {}
---@type ModelCmp.Config
options = vim.tbl_deep_extend("force", M.default(), opts)
require("model_cmp.commands").setup(maingroup)
require("model_cmp.virtualtext").setup()
require("model_cmp.modelapi.common").setup()
require("model_cmp.utils").MAX_ERROR_COUNT = options.requests.max_retries
return options
end
return setmetatable(M, {
__index = function(_, key)
options = options or M.setup()
return options[key]
end,
})