nvim-configs/lua/plugins/avante.lua

193 lines
4.4 KiB
Lua

local function deepseek(model)
return {
__inherited_from = "openai",
api_key_name = "DEEPSEEK_API_KEY",
endpoint = "https://api.deepseek.com",
max_completion_tokens = 12288,
model = model,
}
end
local function qwen(model)
return {
__inherited_from = "openai",
api_key_name = "QWEN_API_KEY",
endpoint = "https://dashscope.aliyuncs.com/compatible-mode/v1/",
max_completion_tokens = 12288,
model = model,
disable_tools = true,
}
end
local function yostar(model)
return {
__inherited_from = "openai",
api_key_name = "YOSTAR_API_KEY",
endpoint = "https://litellm.yostar.net",
max_completion_tokens = 12288,
model = model,
}
end
local function codestral()
return {
__inherited_from = "openai",
api_key_name = "CODESTRAL_API_KEY",
endpoint = "https://codestral.mistral.ai/v1",
max_completion_tokens = 12288,
model = "codestral-latest",
}
end
local function ark(model)
return {
__inherited_from = "openai",
api_key_name = "ARK_API_KEY",
endpoint = "https://ark.cn-beijing.volces.com/api/v3/",
max_completion_tokens = 12288,
model = model,
}
end
return {
{
"yetone/avante.nvim",
event = "VeryLazy",
lazy = true,
build = "make",
dependencies = {
"stevearc/dressing.nvim",
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
{
"MeanderingProgrammer/render-markdown.nvim",
opts = {
file_types = { "markdown", "Avante" },
},
ft = { "markdown", "Avante" },
},
},
opts = {
provider = "arkv3",
auto_suggestions_provider = "arkv3",
-- cursor_applying_provider = "yoqwen32",
-- behaviour = {
-- enable_cursor_planning_mode = true, -- enable cursor planning mode!
-- },
file_selector = {
provider = "fzf-lua",
provider_opts = {},
},
vendors = {
-- ds
dsv3 = deepseek("deepseek-chat"),
dsr1 = deepseek("deepseek-reasoner"),
-- 百炼
qwenv3 = qwen("deepseek-v3"),
qwenr1 = qwen("deepseek-r1"),
-- yostar
yor1 = yostar("DeepSeek-R1"),
yov3 = yostar("DeepSeek-V3"),
-- ark
arkv3 = ark("deepseek-v3-250324"),
-- codestral
codestral = codestral(),
},
-- Key mappings for diff functionality
mappings = {
diff = {
theirs = "<M-l>",
ours = "<M-L>",
},
},
},
},
{
"nvim-neo-tree/neo-tree.nvim",
config = function()
require("neo-tree").setup({
filesystem = {
commands = {
avante_add_files = function(state)
local node = state.tree:get_node()
local filepath = node:get_id()
local relative_path = require("avante.utils").relative_path(filepath)
local sidebar = require("avante").get()
local open = sidebar:is_open()
-- ensure avante sidebar is open
if not open then
require("avante.api").ask()
sidebar = require("avante").get()
end
sidebar.file_selector:add_selected_file(relative_path)
-- remove neo tree buffer
if not open then
sidebar.file_selector:remove_selected_file("neo-tree filesystem [1]")
end
end,
},
window = {
mappings = {
["oa"] = "avante_add_files",
},
},
},
})
end,
},
{
"saghen/blink.cmp",
dependencies = {
"Kaiser-Yang/blink-cmp-avante",
-- ... Other dependencies
},
opts = {
sources = {
-- Add 'avante' to the list
default = { "avante", "lsp", "path", "snippets", "buffer" },
providers = {
avante = {
module = "blink-cmp-avante",
name = "Avante",
opts = {
-- options for blink-cmp-avante
},
},
},
},
},
},
{
"milanglacier/minuet-ai.nvim",
event = "InsertEnter",
config = function()
require("minuet").setup({
virtualtext = {
auto_trigger_ft = { "*" },
keymap = {
accept = "<M-l>",
accept_line = "<M-Down>",
next = "<M-]>",
prev = "<M-[>",
dismiss = "<M-BS>",
},
},
})
end,
},
}