Skip to main content

Overview

Avante.nvim integrates with both nvim-cmp and blink.cmp to provide intelligent completions for mentions, slash commands, and shortcuts within the Avante chat interface.

nvim-cmp Integration

Avante works with nvim-cmp out of the box. Simply ensure nvim-cmp is installed as a dependency:
{
  "yetone/avante.nvim",
  dependencies = {
    "hrsh7th/nvim-cmp", -- autocompletion for avante commands and mentions
    -- ... other dependencies
  },
}
For users of blink.cmp (a faster nvim-cmp alternative), Avante provides compatibility through blink.compat.
When using blink.cmp, choose a selector other than native as it currently has known issues.

LazyVim Users

If you’re using LazyVim, copy the full blink.cmp config from the website or extend the options:
{
  "saghen/blink.cmp",
  opts = {
    sources = {
      compat = {
        "avante_commands",
        "avante_mentions",
        "avante_files",
      },
    },
  },
}

Manual Configuration

For other setups, add custom providers:
{
  "saghen/blink.cmp",
  opts = {
    sources = {
      default = {
        -- ... other sources
        "avante_commands",
        "avante_mentions",
        "avante_shortcuts",
        "avante_files",
      },
      providers = {
        avante_commands = {
          name = "avante_commands",
          module = "blink.compat.source",
          score_offset = 90, -- show at a higher priority than lsp
          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, -- highest priority
          opts = {},
        },
        avante_shortcuts = {
          name = "avante_shortcuts",
          module = "blink.compat.source",
          score_offset = 1000,
          opts = {},
        },
      },
    },
  },
}
You can also use the dedicated Kaiser-Yang/blink-cmp-avante plugin.

Completion Sources

Mentions (@ trigger)

Mentions allow you to quickly reference features or add context to your chat:
@codebase
mention
Enable project context and repository mapping via RAG serviceUsage: Ask questions about your entire codebaseExample: @codebase How does authentication work in this project?Requires: RAG service to be enabled
@diagnostics
mention
Enable diagnostics information from LSPUsage: Include current errors/warnings in the contextExample: @diagnostics Help me fix these type errors
@file
mention
Open file selector to add files to chat contextUsage: Add specific files for the AI to referenceExample: @file (then select files from the picker)
@quickfix
mention
Add files from quickfix list to chat contextUsage: Include files with errors or search resultsExample: @quickfix Review these failing tests
@buffers
mention
Add all open buffers to chat contextUsage: Give the AI context about all currently open filesExample: @buffers Refactor these related components

Slash Commands (/ trigger)

Built-in commands for common operations:
/help
command
Show help message with available commandsUsage: Get information about Avante features and commands
/init
command
Initialize AGENTS.md based on current projectUsage: Set up project-specific AI instructions
/clear
command
Clear chat history for the current sessionUsage: Start fresh without previous context
/new
command
Start a new chat sessionUsage: Begin a separate conversation thread
/compact
command
Compact history messages to save tokensUsage: Reduce context size while preserving important information
/lines
command
Ask about specific line rangesSyntax: /lines <start>-<end> <question>Example: /lines 10-50 What does this function do?
/commit
command
Generate commit message for staged changesUsage: Create conventional commit messages automatically

Shortcuts (# trigger)

Shortcuts provide quick access to predefined prompt templates:
require('avante').setup({
  shortcuts = {
    {
      name = "refactor",
      description = "Refactor code with best practices",
      details = "Automatically refactor code to improve readability, maintainability, and follow best practices while preserving functionality",
      prompt = "Please refactor this code following best practices, improving readability and maintainability while preserving functionality.",
    },
    {
      name = "test",
      description = "Generate unit tests",
      details = "Create comprehensive unit tests covering edge cases, error scenarios, and various input conditions",
      prompt = "Please generate comprehensive unit tests for this code, covering edge cases and error scenarios.",
    },
    {
      name = "explain",
      description = "Explain code functionality",
      prompt = "Please explain what this code does in detail, including its purpose, logic, and any important patterns or considerations.",
    },
    {
      name = "optimize",
      description = "Optimize code performance",
      prompt = "Please analyze this code for performance improvements and suggest optimizations while maintaining functionality.",
    },
    {
      name = "document",
      description = "Add documentation",
      prompt = "Please add comprehensive documentation to this code, including docstrings, comments, and usage examples.",
    },
  },
})

Using Shortcuts

Type # in the chat input to see available shortcuts:
  • #refactor → Expands to the refactor prompt
  • #test → Expands to the test generation prompt
  • #explain → Expands to the explanation prompt

Custom Shortcuts

Create project-specific shortcuts:
shortcuts = {
  {
    name = "api",
    description = "Generate API endpoint",
    prompt = "Create a RESTful API endpoint following our project conventions with proper error handling, validation, and documentation.",
  },
  {
    name = "component",
    description = "Generate React component",  
    prompt = "Create a React component using TypeScript, hooks, and our component pattern with proper props typing and documentation.",
  },
}

File Selector Configuration

Configure which file picker to use with @file:
require('avante').setup({
  selector = {
    provider = "telescope", -- "native" | "fzf_lua" | "mini_pick" | "snacks" | "telescope"
    provider_opts = {}, -- Options for the picker
  },
})

Available Selectors

selector = {
  provider = "telescope",
}
Requires: nvim-telescope/telescope.nvim

Custom Selector Provider

Create a custom file selector:
selector = {
  ---@param selector avante.ui.Selector
  provider = function(selector)
    local items = selector.items ---@type avante.ui.SelectorItem[]
    local title = selector.title ---@type string
    local on_select = selector.on_select ---@type fun(selected_item_ids: string[]|nil): nil

    -- Your custom picker logic here
    -- Call on_select(selected_ids) when done
  end,
}

Switching Selector Provider

You can switch the selector provider at runtime:
:AvanteSwitchSelectorProvider telescope
Available options: native, telescope, fzf_lua, mini_pick, snacks

Exclude Auto-Select

Prevent certain buffer types from being auto-selected:
require('avante').setup({
  selector = {
    exclude_auto_select = { "NvimTree", "neo-tree" },
  },
})

Complete Example

Here’s a complete configuration with all completion sources:
require('avante').setup({
  -- File selector
  selector = {
    provider = "telescope",
    exclude_auto_select = { "NvimTree" },
  },
  
  -- Shortcuts
  shortcuts = {
    {
      name = "refactor",
      description = "Refactor code with best practices",
      prompt = "Please refactor this code following best practices.",
    },
    {
      name = "test",
      description = "Generate unit tests",
      prompt = "Please generate comprehensive unit tests for this code.",
    },
  },
  
  -- Enable RAG for @codebase
  rag_service = {
    enabled = true,
    -- ... RAG configuration
  },
})

Tips and Tricks

Quick File Adding

Use @file to quickly add specific files to context without leaving the chat.

Codebase Queries

Enable RAG and use @codebase for intelligent whole-project queries.

Custom Shortcuts

Create shortcuts for common project-specific prompts to save typing.

Diagnostics Context

Use @diagnostics when asking the AI to fix errors or warnings.

RAG Service

Enable semantic codebase search

Slash Commands

Complete slash command reference

blink.cmp Guide

Detailed blink.cmp setup