avante.nvim
avante.nvim is a Neovim plugin designed to emulate the behaviour of the Cursor AI IDE. It provides users with AI-driven code suggestions and the ability to apply these recommendations directly to their source files with minimal effort.
[!NOTE]
This project is undergoing rapid iterations, and many exciting features will be added successively. Stay tuned!
Features
- AI-Powered Code Assistance: Interact with AI to ask questions about your current code file and receive intelligent suggestions for improvement or modification.
- One-Click Application: Quickly apply the AI's suggested changes to your source code with a single command, streamlining the editing process and saving time.
Installation
For building binary if you wish to build from source, then cargo
is required. Otherwise curl
and tar
will be used to get prebuilt binary from GitHub.
lazy.nvim (recommended)
vim-plug
Lua
NOTE: For avante.tokenizers
and templates to work, make sure to call require('avante_lib').load()
somewhere when entering the editor. We will leave the users to decide where it fits to do this, as this varies among configurations. (But we do recommend running this after where you set your colorscheme)
[!IMPORTANT]
avante.nvim
is currently only compatible with Neovim 0.10.1 or later. Please ensure that your Neovim version meets these requirements before proceeding.
[!NOTE]
Recommended Neovim options:
-- views can only be fully collapsed with the global statusline vim.opt.laststatus = 3
[!TIP]
Any rendering plugins that support markdown should work with Avante as long as you add the supported filetype
Avante
. See https://github.com/yetone/avante.nvim/issues/175 and this comment for more information.
Default setup configuration
See config.lua#L9 for the full config
Usage
Given its early stage, avante.nvim
currently supports the following basic functionalities:
[!IMPORTANT]
Avante will only support Claude, and OpenAI (and its variants including azure)out-of-the-box due to its high code quality generation.
For all OpenAI-compatible providers, see wiki for more details.
[!IMPORTANT]
Due to the poor performance of other models, avante.nvim only recommends using the claude-3.5-sonnet model.
All features can only be guaranteed to work properly on the claude-3.5-sonnet model.
We do not accept changes to the code or prompts to accommodate other models. Otherwise, it will greatly increase our maintenance costs.
We hope everyone can understand. Thank you!
[!IMPORTANT]
For most consistency between neovim session, it is recommended to set the environment variables in your shell file.
By default,Avante
will prompt you at startup to input the API key for the provider you have selected.For Claude:
export ANTHROPIC_API_KEY=your-api-key
For OpenAI:
export OPENAI_API_KEY=your-api-key
For Azure OpenAI:
export AZURE_OPENAI_API_KEY=your-api-key
- Open a code file in Neovim.
- Use the
:AvanteAsk
command to query the AI about the code. - Review the AI's suggestions.
- Apply the recommended changes directly to your code with a simple command or key binding.
Note: The plugin is still under active development, and both its functionality and interface are subject to significant changes. Expect some rough edges and instability as the project evolves.
Key Bindings
The following key bindings are available for use with avante.nvim
:
[!NOTE]
If you are using
lazy.nvim
, then all keymap here will be safely set, meaning ifis already binded, then avante.nvim won't bind this mapping.
aa
In this case, user will be responsible for setting up their own. See notes on keymaps for more details.
Highlight Groups
See highlights.lua for more information
Custom prompts
By default, avante.nvim
provides three different modes to interact with: planning
, editing
, and suggesting
, followed with three different prompts per mode.
planning
: Used withrequire("avante").toggle()
on sidebarediting
: Used withrequire("avante").edit()
on selection codeblocksuggesting
: Used withrequire("avante").get_suggestion():suggest()
on Tab flow.
Users can customize the system prompts via Config.system_prompt
. We recommend calling this in a custom Autocmds depending on your need:
If one wish to custom prompts for each mode, avante.nvim
will check for project root based on the given buffer whether it contains
the following patterns: *.{mode}.avanterules
.
The rules for root hierarchy:
- lsp workspace folders
- lsp root_dir
- root pattern of filename of the current buffer
- root pattern of cwd
Example folder structure for custom prompt
If you have the following structure:
typescript.planning.avanterules
will be used forplanning
modesnippets.editing.avanterules`` will be used for
editing` mode- the default
suggesting
prompt fromavante.nvim
will be used forsuggesting
mode.
[!important]
*.avanterules
is a jinja template file, in which will be rendered using minijinja. See templates for example on how to extend current templates.
TODOs
- Chat with current file
- Apply diff patch
- Chat with the selected block
- Slash commands
- Edit the selected block
- Smart Tab (Cursor Flow)
- Chat with project (You can use
@codebase
to chat with the whole project) - CoT
- Chat with selected files
Roadmap
- Enhanced AI Interactions: Improve the depth of AI analysis and recommendations for more complex coding scenarios.
- LSP + Tree-sitter + LLM Integration: Integrate with LSP and Tree-sitter and LLM to provide more accurate and powerful code suggestions and analysis.
Contributing
Contributions to avante.nvim are welcome! If you're interested in helping out, please feel free to submit pull requests or open issues. Before contributing, ensure that your code has been thoroughly tested.
See wiki for more recipes and tricks.
Acknowledgments
We would like to express our heartfelt gratitude to the contributors of the following open-source projects, whose code has provided invaluable inspiration and reference for the development of avante.nvim:
The high quality and ingenuity of these projects' source code have been immensely beneficial throughout our development process. We extend our sincere thanks and respect to the authors and contributors of these projects. It is the selfless dedication of the open-source community that drives projects like avante.nvim forward.
License
avante.nvim is licensed under the Apache 2.0 License. For more details, please refer to the LICENSE file.
No reviews found!
No comments found for this product. Be the first to comment!