Skip to content

Commit 613a9f3

Browse files
author
Max Copeland
committed
Default Avante to Copilot; run Claude via Claude Code CLI instead
Claude's auth_type=max OAuth hits an unresolved upstream 429 on token exchange for third-party tools (yetone/avante.nvim, anomalyco/opencode#18329), not something fixable on our end. Copilot is now Avante's default/auto-suggestions provider; the claude provider stays configured to retry later via :AvanteSwitchProvider claude. Added <leader>tc to toggle a reusable split terminal running the Claude Code CLI, alongside the existing <leader>tt generic shell terminal (factored both out of one closure-based helper).
1 parent b68c43e commit 613a9f3

2 files changed

Lines changed: 46 additions & 32 deletions

File tree

‎.config/nvim/init.lua‎

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -190,40 +190,51 @@ vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right win
190190
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
191191
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
192192

193-
-- Toggle a split terminal
193+
-- Toggle a split terminal running a given command.
194194
-- Reuses a single terminal buffer instead of spawning a new one (and
195195
-- leaking the old one's shell process) on every toggle; closing kills
196-
-- the shell rather than just hiding the window.
197-
local split_terminal_buf = nil
198-
199-
local function toggle_split_terminal()
200-
local buf_valid = split_terminal_buf and vim.api.nvim_buf_is_valid(split_terminal_buf)
201-
local win = buf_valid and vim.fn.bufwinid(split_terminal_buf) or -1
202-
203-
if win ~= -1 then
204-
-- Terminal is visible: close the window and kill the shell
205-
vim.api.nvim_win_close(win, true)
206-
vim.fn.jobstop(vim.b[split_terminal_buf].terminal_job_id)
207-
vim.api.nvim_buf_delete(split_terminal_buf, { force = true })
208-
split_terminal_buf = nil
209-
elseif buf_valid then
210-
-- Terminal was closed some other way (e.g. plain :q); reopen the same
211-
-- buffer instead of leaking a new one
212-
vim.cmd '25split'
213-
vim.api.nvim_win_set_buf(0, split_terminal_buf)
214-
vim.wo.number = false
215-
vim.cmd 'startinsert'
216-
else
217-
-- No terminal yet: open a new split terminal
218-
vim.cmd '25split | set nonumber | terminal bash --login'
219-
split_terminal_buf = vim.api.nvim_get_current_buf()
220-
vim.cmd 'startinsert'
196+
-- the job rather than just hiding the window. Each call site gets its
197+
-- own buffer slot via closure, so separate terminals (shell, Claude
198+
-- Code) can be toggled independently.
199+
local function make_split_terminal_toggle(cmd)
200+
local buf = nil
201+
202+
return function()
203+
local buf_valid = buf and vim.api.nvim_buf_is_valid(buf)
204+
local win = buf_valid and vim.fn.bufwinid(buf) or -1
205+
206+
if win ~= -1 then
207+
-- Terminal is visible: close the window and kill the job
208+
vim.api.nvim_win_close(win, true)
209+
vim.fn.jobstop(vim.b[buf].terminal_job_id)
210+
vim.api.nvim_buf_delete(buf, { force = true })
211+
buf = nil
212+
elseif buf_valid then
213+
-- Terminal was closed some other way (e.g. plain :q); reopen the same
214+
-- buffer instead of leaking a new one
215+
vim.cmd '25split'
216+
vim.api.nvim_win_set_buf(0, buf)
217+
vim.wo.number = false
218+
vim.cmd 'startinsert'
219+
else
220+
-- No terminal yet: open a new split terminal
221+
vim.cmd('25split | set nonumber | terminal ' .. cmd)
222+
buf = vim.api.nvim_get_current_buf()
223+
vim.cmd 'startinsert'
224+
end
221225
end
222226
end
223227

224-
-- vim.api.nvim_set_keymap('n', '<leader>tt', ':lua toggle_split_terminal()<CR>', { noremap = true, silent = true })
228+
local toggle_split_terminal = make_split_terminal_toggle 'bash --login'
225229
vim.keymap.set('n', '<leader>tt', toggle_split_terminal, { desc = 'Toggle a split [T]erminal' })
226230

231+
-- Claude Code CLI in its own split, since Claude runs there (official,
232+
-- subscription-authenticated client) rather than through Avante's Claude
233+
-- provider, which hits an unresolved OAuth token-exchange 429 for
234+
-- third-party tools.
235+
local toggle_claude_terminal = make_split_terminal_toggle 'claude'
236+
vim.keymap.set('n', '<leader>tc', toggle_claude_terminal, { desc = 'Toggle [C]laude Code terminal' })
237+
227238
-- [[ Basic Autocommands ]]
228239
-- See `:help lua-guide-autocommands`
229240

‎.config/nvim/lua/plugins/avante.lua‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@ return {
55
event = 'VeryLazy',
66
version = false, -- track main; avante ships frequently and pins break new providers
77
opts = {
8-
provider = 'claude',
9-
auto_suggestions_provider = 'claude',
8+
-- Copilot is the default: Claude's auth_type = "max" OAuth (below) hits
9+
-- an unresolved upstream 429 on token exchange for third-party tools
10+
-- (github.com/yetone/avante.nvim, github.com/anomalyco/opencode#18329).
11+
-- Claude work happens in the Claude Code CLI instead (<leader>tc).
12+
-- The claude provider is left configured so `:AvanteSwitchProvider
13+
-- claude` can be retried later if/when that upstream issue clears.
14+
provider = 'copilot',
15+
auto_suggestions_provider = 'copilot',
1016
providers = {
1117
claude = {
1218
endpoint = 'https://api.anthropic.com',
1319
model = 'claude-sonnet-5',
14-
-- Browser OAuth against your Claude Pro/Max subscription instead of
15-
-- a pay-per-token API key. Run `:AvanteSwitchProvider claude` after
16-
-- install to kick off the login if it doesn't prompt automatically.
1720
auth_type = 'max',
1821
extra_request_body = {
1922
temperature = 0.75,

0 commit comments

Comments
 (0)