Overview
You can integrate Avante.nvim with neo-tree to quickly add files or folders to the Avante chat context directly from the neo-tree sidebar.This integration allows you to select files in neo-tree and add them to Avante’s selected files list without leaving the file explorer.
Installation & Configuration
Add the following configuration to your neo-tree setup:How It Works
Define Custom Command
The
avante_add_files command is defined in neo-tree’s filesystem.commands section.Convert to Relative Path
Uses
require('avante.utils').relative_path() to convert the absolute path to a project-relative path.Ensure Avante Sidebar is Open
Checks if the Avante sidebar is open; if not, opens it with
require('avante.api').ask().Add File to Selection
Adds the file to Avante’s selected files list using
sidebar.file_selector:add_selected_file().Usage
Adding Files
- Open neo-tree sidebar (
:Neotreeor your configured keybinding) - Navigate to the file or folder you want to add
- Press
oa(or your configured key) to add it to Avante’s context - The file appears in Avante’s “Selected Files” list
Customizing the Keybinding
You can change'oa' to any keybinding you prefer:
Complete Example Configuration
Here’s a complete example with both Avante and neo-tree configured:Advanced: Remove Files
You can also add a command to remove files from Avante’s selection:Tips & Tricks
Add Multiple Files
Navigate and press
oa on multiple files to add them all to the context.Add Folders
You can add entire folders by pressing
oa on a directory node.Visual Feedback
Check Avante’s sidebar to see the list of selected files after adding.
Exclude Neo-tree
Use
exclude_auto_select to prevent neo-tree buffers from being auto-selected.Alternative: nvim-tree Integration
For nvim-tree users, you can create a similar integration:Exclude Auto-Select
To prevent file explorer buffers from being automatically selected by Avante:Troubleshooting
Keybinding not working
Keybinding not working
- Verify the mapping is in the correct section (
filesystem.window.mappings) - Check for conflicts with other neo-tree mappings
- Ensure neo-tree is loaded before using the mapping
File not appearing in Avante
File not appearing in Avante
- Check if Avante sidebar is open after pressing
oa - Verify the file path is correct
- Look for errors in
:messages - Ensure
avante.utils.relative_path()is working correctly
Neo-tree buffer showing in Avante
Neo-tree buffer showing in Avante
Add neo-tree to
exclude_auto_select:Related Documentation
Completion Sources
Other ways to add files to context
Keybindings
All Avante keybindings
File Selector
Configure file picker providers