Overview of avante-tokenizers
mainavante-tokenizers is a Rust crate designed to provide a unified interface for working with different tokenization libraries, specifically unifying hf/tokenizers (Hugging Face) and tiktoken-rs (OpenAI).repository·main·Indexed 12 days ago
https://github.com/yetone/avante.nvimA Neovim plugin that brings Cursor-like AI capabilities to the editor, featuring AI-driven code suggestions, one-click applications, and a terminal-based agent experience called 'Zen Mode'. It supports multiple LLM providers including Claude, OpenAI, Azure, Gemini, Cohere, Copilot, and local options via Ollama. The plugin includes a RAG service with support for OpenAI, DashScope, and Ollama for embeddings, and allows project-specific AI behavior customization via an avante.md file.
avante-tokenizers is a Rust crate designed to provide a unified interface for working with different tokenization libraries, specifically unifying hf/tokenizers (Hugging Face) and tiktoken-rs (OpenAI).You can define custom prompts for specific modes by placing *.{mode}.avanterules files in your project root. Avante will detect these based on the project root (LSP workspace, LSP root_dir, etc.).
Supported Modes:
planning.avanterules (for planning mode)editing.avanterules (for editing mode)suggesting.avanterules (for suggesting mode)Template Engine:
Files ending in .avanterules are Jinja templates rendered using minijinja.
Loading Priority:
rules.project_dir (configured in setup)rules.global_dir (configured in setup)Configuration:
You can define custom directories for these rules in the setup function.
require('avante').setup({
rules = {
project_dir = '.avante/rules', -- Relative to project root or absolute
global_dir = '~/.config/avante/rules', -- Absolute path
},
})The dual_boost feature is an experimental mode that generates two separate responses from two different providers (first_provider and second_provider) and then uses a third prompt to combine them into a single response.
Configuration keys:
enabled: Boolean to enable the feature.first_provider: The first LLM to call.second_provider: The second LLM to call.prompt: The template used to merge outputs. It supports {{provider1_output}} and {{provider2_output}} placeholders.timeout: Timeout in milliseconds.dual_boost = {
enabled = false,
first_provider = "openai",
second_provider = "claude",
prompt = "Based on the following two reference outputs, generate a response that combines elements of both but reflects your own judgment and unique perspective. Do not provide any explanation, just give the response directly. Reference output 1: [{{provider1_output}}], Reference output 2: [{{provider2_output}}]",
timeout = 60000,
}Avante supports mode-specific custom rules using .avanterules files (which are Jinja templates). Avante looks for these files in the project root based on a hierarchy: LSP workspace folders > LSP root_dir > filename root pattern > CWD.
To match a specific mode, name the file *.{mode}.avanterules (e.g., typescript.planning.avanterules for planning mode in TypeScript projects).
You can configure where Avante looks for these rules using the rules option:
rules.project_dir: Relative to project root (e.g., .avante/rules).rules.global_dir: Absolute path (e.g., ~/.config/avante/rules).Loading Priority:
rules.project_dirrules.global_dirrequire('avante').setup({
rules = {
project_dir = '.avante/rules',
global_dir = '~/.config/avante/rules',
},
})You can install avante.nvim using several other Neovim plugin managers. Most require a build step (make or do = 'make') and specific dependencies.
Requires plenary.nvim and nui.nvim. To build from source, pass source=true to the plugin definition.
Use the hooks property to run vim.cmd('make') after checkout.
Use the run property to execute make.
" vim-plug
Plug 'yetone/avante.nvim', { 'branch': 'main', 'do': 'make' }
" Packer
use {
'yetone/avante.nvim',
branch = 'main',
run = 'make',
config = function() require('avante').setup() end
}If you use blink.cmp, you can integrate Avante's completion sources (Mentions, Slash Commands, Shortcuts, and Files) using blink.compat or the Kaiser-Yang/blink-cmp-avante plugin.
Available Completion Sources:
@): @codebase, @diagnostics, @file, @quickfix, @buffers./): /help, /init, /clear, /new, /compact, /lines <start>-<end> <question>, /commit.#): Predefined prompt templates.-- Example blink.cmp configuration with Avante sources
default = {
...,
"avante_commands",
"avante_mentions",
"avante_shortcuts",
"avante_files",
}
providers = {
avante_commands = {
name = "avante_commands",
module = "blink.compat.source",
score_offset = 90,
opts = {},
},
avante_files = {
name = "avante_files",
module = "blink.compat.source",
score_offset = 100,
opts = {},
},
avante_mentions = {
name = "avante_mentions",
module = "blink.compat.source",
score_offset = 1000,
opts = {},
},
avante_shortcuts = {
name = "avante_shortcuts",
module = "blink.compat.source",
score_offset = 1000,
opts = {},
}
...
}To use your Claude subscription instead of an API key, set the auth_type of the claude provider to "max" in your configuration.
After re-opening Neovim, the authentication process will start in your browser. Once authorized, copy the provided code into the Neovim prompt. If you need to re-initiate authentication, run :AvanteSwitchProvider claude.
-- Providers = { ...
claude = {
-- ...
auth_type = "max",
},Fast Apply provides instant code edits with high accuracy (96-98%) by using specialized models. To use it, you must enable the feature in your configuration, obtain a Morph API key from morphllm.com, and set the MORPH_API_KEY environment variable.
Morph Model Options:
morph-v3-fast: 4500+ tok/sec, 96% accuracy, 16k context.morph-v3-large: 2500+ tok/sec, 98% accuracy, 16k context.auto: 2500-4500 tok/sec, 98% accuracy, 16k context.behaviour = {
enable_fastapply = true, -- Enable Fast Apply feature
},
providers = {
morph = {
model = "morph-v3-large",
},
}export MORPH_API_KEY="your-api-key"The recommended way to install avante.nvim is via lazy.nvim. Note that you must include the build step. If you want to build from source, you must set BUILD_FROM_SOURCE=true in your make command (though the provided snippet uses a conditional for Windows/Unix).
Important Requirements:
cargo is required.powershell is used for the build process.Recommended Neovim Option:
To ensure the sidebar can be fully collapsed, set vim.opt.laststatus = 3 in your Neovim configuration.
{
"yetone/avante.nvim",
build = vim.fn.has("win32") ~= 0
and "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false"
or "make",
event = "VeryLazy",
version = false, -- Never set this value to "*"!
opts = {
provider = "claude",
-- add other opts here
},
dependencies = {
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
-- optional dependencies
"nvim-telescope/telescope.nvim",
"hrsh7th/nvim-cmp",
"folke/snacks.nvim",
-- ...
},
}Avante supports the Agent Client Protocol (ACP), allowing integration with AI agents that use standardized JSON-RPC communication. ACP providers are configured in the acp_providers section. Supported agents include gemini-cli, claude-code, goose, codex, and kimi-cli.
Prerequisites:
gemini and set GEMINI_API_KEY.acp-claude-code via npm and set ANTHROPIC_API_KEY.acp_providers = {
["gemini-cli"] = {
command = "gemini",
args = { "--experimental-acp" },
env = {
NODE_NO_WARNINGS = "1",
GEMINI_API_KEY = os.getenv("GEMINI_API_KEY"),
},
},
["claude-code"] = {
command = "claude-agent-acp",
args = { },
env = {
NODE_NO_WARNINGS = "1",
ANTHROPIC_API_KEY = os.getenv("ANTHROPIC_API_KEY"),
},
},
["goose"] = {
command = "goose",
args = { "acp" },
},
["codex"] = {
command = "codex-acp",
args = {},
env = {
NODE_NO_WARNINGS = "1",
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY"),
},
},
}Avante can use the Claude Text Editor Tool for a more elegant code editing experience.
Requirements:
claude-3-5-sonnet-* or claude-3-7-sonnet-* model.claude provider.{
behaviour = {
enable_claude_text_editor_tool_mode = true,
},
}