2024-08-17 15:14:30 +08:00
|
|
|
---NOTE: user will be merged with defaults and
|
|
|
|
---we add a default var_accessor for this table to config values.
|
2024-08-17 14:14:02 -04:00
|
|
|
---
|
2024-08-17 15:14:30 +08:00
|
|
|
---@class avante.CoreConfig: avante.Config
|
2024-08-15 17:45:46 +08:00
|
|
|
local M = {}
|
|
|
|
|
2024-08-17 15:14:30 +08:00
|
|
|
---@class avante.Config
|
|
|
|
M.defaults = {
|
2024-08-18 21:33:45 +08:00
|
|
|
---@alias Provider "openai" | "claude" | "azure" | "deepseek"
|
|
|
|
provider = "claude", -- "claude" or "openai" or "azure" or "deepseek"
|
2024-08-15 17:45:46 +08:00
|
|
|
openai = {
|
|
|
|
endpoint = "https://api.openai.com",
|
|
|
|
model = "gpt-4o",
|
|
|
|
temperature = 0,
|
|
|
|
max_tokens = 4096,
|
|
|
|
},
|
|
|
|
azure = {
|
|
|
|
endpoint = "", -- example: "https://<your-resource-name>.openai.azure.com"
|
|
|
|
deployment = "", -- Azure deployment name (e.g., "gpt-4o", "my-gpt-4o-deployment")
|
|
|
|
api_version = "2024-06-01",
|
|
|
|
temperature = 0,
|
|
|
|
max_tokens = 4096,
|
|
|
|
},
|
|
|
|
claude = {
|
|
|
|
endpoint = "https://api.anthropic.com",
|
|
|
|
model = "claude-3-5-sonnet-20240620",
|
|
|
|
temperature = 0,
|
|
|
|
max_tokens = 4096,
|
|
|
|
},
|
2024-08-18 21:33:45 +08:00
|
|
|
deepseek = {
|
|
|
|
endpoint = "https://api.deepseek.com",
|
|
|
|
model = "deepseek-coder",
|
|
|
|
temperature = 0,
|
|
|
|
max_tokens = 4096,
|
|
|
|
},
|
2024-08-17 16:31:24 -04:00
|
|
|
behaviour = {
|
|
|
|
auto_apply_diff_after_generation = false, -- Whether to automatically apply diff after LLM response.
|
|
|
|
},
|
2024-08-15 17:45:46 +08:00
|
|
|
highlights = {
|
2024-08-17 14:14:02 -04:00
|
|
|
---@type AvanteConflictHighlights
|
2024-08-15 17:45:46 +08:00
|
|
|
diff = {
|
|
|
|
current = "DiffText", -- need have background color
|
|
|
|
incoming = "DiffAdd", -- need have background color
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mappings = {
|
2024-08-17 22:29:05 +08:00
|
|
|
ask = "<leader>aa",
|
|
|
|
edit = "<leader>ae",
|
2024-08-17 13:41:34 -04:00
|
|
|
refresh = "<leader>ar",
|
2024-08-17 14:14:02 -04:00
|
|
|
--- @class AvanteConflictMappings
|
2024-08-15 17:45:46 +08:00
|
|
|
diff = {
|
|
|
|
ours = "co",
|
|
|
|
theirs = "ct",
|
|
|
|
none = "c0",
|
|
|
|
both = "cb",
|
|
|
|
next = "]x",
|
|
|
|
prev = "[x",
|
|
|
|
},
|
2024-08-17 10:39:59 -04:00
|
|
|
jump = {
|
|
|
|
next = "]]",
|
|
|
|
prev = "[[",
|
|
|
|
},
|
2024-08-15 17:45:46 +08:00
|
|
|
},
|
2024-08-17 15:14:30 +08:00
|
|
|
windows = {
|
2024-08-18 13:48:19 +08:00
|
|
|
wrap_line = true,
|
2024-08-17 15:14:30 +08:00
|
|
|
width = 30, -- default % based on available width
|
|
|
|
},
|
2024-08-17 14:14:02 -04:00
|
|
|
--- @class AvanteConflictUserConfig
|
|
|
|
diff = {
|
|
|
|
debug = false,
|
|
|
|
autojump = true,
|
|
|
|
---@type string | fun(): any
|
|
|
|
list_opener = "copen",
|
|
|
|
},
|
2024-08-15 17:45:46 +08:00
|
|
|
}
|
|
|
|
|
2024-08-17 15:14:30 +08:00
|
|
|
---@type avante.Config
|
|
|
|
M.options = {}
|
|
|
|
|
2024-08-17 14:14:02 -04:00
|
|
|
---@class avante.ConflictConfig: AvanteConflictUserConfig
|
|
|
|
---@field mappings AvanteConflictMappings
|
|
|
|
---@field highlights AvanteConflictHighlights
|
|
|
|
M.diff = {}
|
|
|
|
|
2024-08-17 15:14:30 +08:00
|
|
|
---@param opts? avante.Config
|
|
|
|
function M.setup(opts)
|
|
|
|
M.options = vim.tbl_deep_extend("force", M.defaults, opts or {})
|
2024-08-17 14:14:02 -04:00
|
|
|
|
|
|
|
M.diff = vim.tbl_deep_extend(
|
|
|
|
"force",
|
|
|
|
{},
|
|
|
|
M.options.diff,
|
|
|
|
{ mappings = M.options.mappings.diff, highlights = M.options.highlights.diff }
|
|
|
|
)
|
2024-08-17 15:14:30 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
M = setmetatable(M, {
|
|
|
|
__index = function(_, k)
|
|
|
|
if M.options[k] then
|
|
|
|
return M.options[k]
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
function M.get_window_width()
|
|
|
|
return math.ceil(vim.o.columns * (M.windows.width / 100))
|
2024-08-15 17:45:46 +08:00
|
|
|
end
|
|
|
|
|
2024-08-17 15:14:30 +08:00
|
|
|
---@return {width: integer, height: integer, position: integer}
|
|
|
|
function M.get_renderer_layout_options()
|
|
|
|
local width = M.get_window_width()
|
|
|
|
local height = vim.o.lines
|
|
|
|
local position = vim.o.columns - width
|
|
|
|
return { width = width, height = height, position = position }
|
2024-08-15 17:45:46 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
return M
|