Overview
Avante.nvim provides AI-powered code assistance that integrates seamlessly into your Neovim workflow. Ask questions about your code, get intelligent suggestions, and apply AI-generated changes with a single command.
Core Features
Ask Questions Get intelligent answers about your code, architecture, or implementation details
Code Editing AI suggests and applies targeted code improvements and refactoring
Chat Sessions Maintain context across multiple interactions with persistent chat history
Visual Mode Editing Select code visually and ask AI to refactor, improve, or explain it
Asking Questions
Ask the AI questions about your current code file:
From Command Mode
:AvanteAsk How can I improve the performance of this function ?
The AI will analyze your code and provide specific suggestions.
With Keybindings
Press <Leader>aa (default) to open the sidebar and start asking:
Sidebar opens on the right
Type your question in the input area
Press <CR> to submit
AI responds with analysis and suggestions
Control where the sidebar appears:
:AvanteAsk position = left Explain this code
:AvanteAsk position = top What does this function do ?
:AvanteAsk position = bottom How can I test this ?
Editing Code
Let AI refactor and improve your code:
Visual Selection
Select code in visual mode
" Visual line mode
V5j
" Or visual block mode
< C-v >
Trigger AvanteEdit
:AvanteEdit Refactor this to use async/await
Or use the keybinding: <Leader>ae (default)
Review suggestions
The AI generates improved code. Review the diff in the sidebar.
Apply changes
Press a to apply at cursor
Press A to apply all suggestions
Press co / ct to choose ours/theirs in conflicts
Example Editing Workflow
-- Original code
function fetch_user ( id )
local result = api . call ( '/users/' .. id )
return result
end
Select the function and run:
:AvanteEdit Add error handling and logging
AI suggests:
-- AI-improved code
function fetch_user ( id )
vim . notify ( string.format ( 'Fetching user: %s' , id ), vim . log . levels . DEBUG )
local ok , result = pcall ( api . call , '/users/' .. id )
if not ok then
vim . notify ( string.format ( 'Failed to fetch user %s: %s' , id , result ), vim . log . levels . ERROR )
return nil
end
return result
end
Chat Sessions
Maintain context across multiple interactions:
Starting a Chat
This opens the sidebar without immediately asking a question (as opposed to :AvanteAsk which prompts immediately).
Creating New Chats
Start a fresh conversation with no previous context.
Managing History
Avante automatically saves your chat history:
" View previous chats
:AvanteHistory
" Clear current session
:AvanteClear history
" Clear all cached data
:AvanteClear cache
Or use keybindings:
<Leader>ah - Select from history
<Leader>an - New chat session
Adding Context
Help the AI understand your project better:
Adding Files
Add files to the conversation context:
" From sidebar
@ " Press @ to open file selector
" From command
< Leader >ac " Add current buffer
< Leader >aB " Add all open buffers
Using Mentions
Reference specific context in your prompts:
@file src/auth.lua - Check if this module handles session expiration
@codebase - Find all database query functions
@diagnostics - Show me all errors in the project
See Completion Sources for details.
Project Instructions
Create an avante.md file in your project root:
## Your Role
You are an expert Lua developer specializing in Neovim plugins.
## Coding Standards
- Use snake_case for function names
- Add type annotations with ---@type
- Include luadoc comments for public functions
The AI will reference this file automatically.
One-Click Application
Quickly apply AI suggestions to your code:
Apply at Cursor
Press a in the sidebar to apply the suggestion under your cursor.
Apply All
Press A to apply all AI-suggested changes at once.
Diff Navigation
Navigate and resolve conflicts:
Keybinding Action ]xNext conflict [xPrevious conflict coChoose ours ctChoose theirs cbChoose both caChoose all theirs ccChoose cursor
Move between sidebar and code:
Keybinding Action <Tab>Switch windows forward <S-Tab>Switch windows backward <Leader>afFocus sidebar q or <Esc>Close sidebar
Configuration
Customize AI assistance behavior:
require ( 'avante' ). setup ({
provider = "claude" , -- AI provider
behaviour = {
auto_set_keymaps = true , -- Automatically set keybindings
auto_apply_diff_after_generation = false , -- Manual review
},
windows = {
position = "right" , -- Sidebar position
width = 30 , -- Sidebar width percentage
},
})
Tips for Better Results
Be specific : Instead of “improve this”, say “refactor this to reduce cyclomatic complexity and improve readability”.
Provide context : Use @mentions to reference related files and @diagnostics to include error information.
Iterate : Don’t expect perfection on the first try. Use the edit feature (e) to refine your request.
Review before applying : Always review AI suggestions before applying, especially for critical code.
Next Steps
Quick Start Get started with Avante in minutes
Completion Sources Use mentions, slash commands, and shortcuts
Diff Management Master conflict resolution
Project Instructions Guide AI with project context