Files
sunhat/configs/dotfiles/nvim/lua/plugins/avante.lua
2025-08-15 16:37:31 -05:00

221 lines
5.1 KiB
Lua

vim.pack.add({
{ src = 'https://github.com/yetone/avante.nvim' },
{ src = 'https://github.com/nvim-lua/plenary.nvim' },
{ src = 'https://github.com/MunifTanjim/nui.nvim' },
{ src = 'https://github.com/hrsh7th/nvim-cmp' },
{ src = 'https://github.com/nvim-treesitter/nvim-treesitter' },
{ src = 'https://github.com/stevearc/dressing.nvim' },
{ src = 'https://github.com/nvim-tree/nvim-web-devicons' },
{ src = 'https://github.com/HakonHarnes/img-clip.nvim' },
{ src = 'https://github.com/MeanderingProgrammer/render-markdown.nvim' },
{ src = 'https://github.com/ravitemer/mcphub.nvim' },
})
require'avante'.setup({
provider = 'openai',
auto_suggestions_provider = 'openai',
providers = {
claude = {
endpoint = 'https://api.anthropic.com',
model = 'claude-sonnet-4-20250514',
timeout = 30000,
extra_request_body = {
temperature = 0.75,
max_tokens = 4096,
},
},
openai = {
endpoint = 'https://api.openai.com/v1',
model = 'gpt-5',
extra_request_body = {
timeout = 30000,
temperature = 0,
max_completion_tokens = 8192,
},
},
},
rag_service = {
enabled = false,
host_path = '/home/gib/Documents/Code',
runner = 'docker',
llm = {
provider = 'openai',
endpoint = 'https://api.openai.com/v1',
api_key = 'OPENAI_API_KEY',
model = 'gpt-4o-mini',
extra = {
temperature = 0.7,
max_tokens = 512,
timeout = 60,
},
},
embed = {
provider = 'openai',
endpoint = 'https://api.openai.com/v1',
api_key = 'OPENAI_API_KEY',
model = 'text-embedding-3-large',
extra = nil,
},
docker_extra_args = '',
},
web_search_engine = {
provider = 'searxng',
proxy = nil,
},
system_prompt = function()
local hub = require('mcphub').get_hub_instance()
return hub and hub:get_active_servers_prompt() or ''
end,
custom_tools = function()
return {
require('mcphub.extensions.avante').mcp_tool(),
}
end,
behaviour = {
auto_suggestions = false,
auto_set_highlight_group = true,
auto_set_keymaps = true,
auto_apply_diff_after_generation = false,
support_paste_from_clipboard = false,
minimize_diff = true,
enable_token_counting = true,
auto_approve_tool_permissions = true,
},
mappings = {
--- @class AvanteConflictMappings
diff = {
ours = 'co',
theirs = 'ct',
all_theirs = 'ca',
both = 'cb',
cursor = 'cc',
next = ']x',
prev = '[x',
},
suggestion = {
accept = '<M-l>',
next = '<M-]>',
prev = '<M-[>',
dismiss = '<C-]>',
},
jump = {
next = ']]',
prev = '[[',
},
submit = {
normal = '<CR>',
insert = '<C-s>',
},
cancel = {
normal = { '<C-c>', '<Esc>', 'q' },
insert = { '<C-c>' },
},
sidebar = {
apply_all = 'A',
apply_cursor = 'a',
retry_user_request = 'r',
edit_user_request = 'e',
switch_windows = '<Tab>',
reverse_switch_windows = '<S-Tab>',
remove_file = 'd',
add_file = '@',
close = { '<Esc>', 'q' },
close_from_input = nil,
},
},
hints = { enabled = true },
windows = {
---@type 'right' | 'left' | 'top' | 'bottom'
position = 'right',
wrap = true,
width = 35,
sidebar_header = {
enabled = true,
align = 'center',
rounded = true,
},
input = {
prefix = '> ',
height = 8,
},
edit = {
border = 'rounded',
start_insert = true,
},
ask = {
floating = false,
start_insert = true,
border = 'rounded',
---@type 'ours' | 'theirs'
focus_on_apply = 'ours',
},
},
highlights = {
diff = {
current = 'DiffText',
incoming = 'DiffAdd',
},
},
--- @class AvanteConflictUserConfig
diff = {
autojump = true,
---@type string | fun(): any
list_opener = 'copen',
override_timeoutlen = 500,
},
suggestion = {
debounce = 1000,
throttle = 1000,
},
})
require'img-clip'.setup({
default = {
embed_image_as_base64 = false,
prompt_for_file_name = false,
drag_and_drop = {
insert_mode = true,
},
},
})
require'render-markdown'.setup({
file_types = { 'markdown', 'Avante' },
})
require'mcphub'.setup({
config = vim.fn.expand('/home/gib/.config/mcphub/servers.json'),
port = 37373,
shutdown_delay = 60 * 10 * 000,
use_bundled_binary = false,
mcp_request_timeout = 60000,
auto_approve = true,
auto_toggle_mcp_servers = true,
extensions = {
avante = {
make_slash_commands = true,
},
},
native_servers = {},
ui = {
window = {
width = 0.8,
height = 0.8,
align = 'center',
relative = 'editor',
zindex = 50,
border = 'rounded',
},
wo = {
winhl = 'Normal:MCPHubNormal,FloatBorder:MCPHubBorder',
},
},
--on_ready = function(hub)
--end,
--on_error = function(err)
--end,
log = {
level = vim.log.levels.WARN,
to_file = false,
file_path = nil,
prefix = 'MCPHub',
},
})