Skip to content

🤖 Seamlessly integrate Aider with Neovim for an enhanced AI-assisted coding experience!

License

Notifications You must be signed in to change notification settings

GeorgesAlkhouri/nvim-aider

Repository files navigation

aider nvim-aider

🤖 Seamlessly integrate Aider with Neovim for an enhanced AI-assisted coding experience!

screenshot_1 screenshot_2

🚧 This plugin is in initial development. Expect breaking changes and rough edges.
October 17, 2024

🌟 Features

  • 🖥️ Aider terminal integration within Neovim
  • 🎨 Color theme configuration support with auto Catppuccin flavor synchronization if available
  • 📤 Quick commands to add/drop current buffer files
  • 📤 Send buffers or selections to Aider
  • 💬 Optional user prompt for buffer and selection sends
  • 🔍 Aider command selection UI with fuzzy search and input prompt
  • 🌲➕ Neo-tree integration also with multi-file/directory selection with visual mode support
  • 🌳 Integration with nvim-tree.lua for adding or dropping files directly from the tree interface

🎮 Commands

  • 🩺 AiderHealth - Check if everything is working correctly
  • ⌨️ AiderTerminalToggle - Toggle the Aider terminal window
  • 📤 AiderTerminalSend [text] - Send text to Aider
    • Without arguments: Opens input prompt
    • With arguments: Sends provided text directly
    • In visual mode: Sends selected text with an optional prompt
  • 🔍 AiderQuickSendCommand - List all Aider commands from 🍿 Snacks picker with option to add prompt after selection
  • 📁 AiderQuickAddFile - Add current buffer file to Aider session
  • 🗑️ AiderQuickDropFile - Remove current buffer file from Aider session
  • 📋 AiderQuickSendBuffer - Send entire buffer content to Aider with an optional prompt
  • 📚 AiderQuickReadOnlyFile - Add current buffer as read-only reference file
  • 🌳 AiderTreeAddReadOnlyFile - Add a read-only file from nvim-tree to Aider chat

🔗 Requirements

🐍 Python: Install aider-chat
📋 System: Neovim >= 0.9.4, Working clipboard thanks to @milanglacier
🌙 Lua: folke/snacks.nvim,
optionals catppuccin/nvim, nvim-neo-tree/neo-tree.nvim, nvim-tree.lua

📦 Installation

Using lazy.nvim:

{
    "GeorgesAlkhouri/nvim-aider",
    cmd = {
      "AiderTerminalToggle", "AiderHealth",
    },
    keys = {
      { "<leader>a/", "<cmd>AiderTerminalToggle<cr>", desc = "Open Aider" },
      { "<leader>as", "<cmd>AiderTerminalSend<cr>", desc = "Send to Aider", mode = { "n", "v" } },
      { "<leader>ac", "<cmd>AiderQuickSendCommand<cr>", desc = "Send Command To Aider" },
      { "<leader>ab", "<cmd>AiderQuickSendBuffer<cr>", desc = "Send Buffer To Aider" },
      { "<leader>a+", "<cmd>AiderQuickAddFile<cr>", desc = "Add File to Aider" },
      { "<leader>a-", "<cmd>AiderQuickDropFile<cr>", desc = "Drop File from Aider" },
      { "<leader>ar", "<cmd>AiderQuickReadOnlyFile<cr>", desc = "Add File as Read-Only" },
      -- Example nvim-tree.lua integration if needed
      { "<leader>a+", "<cmd>AiderTreeAddFile<cr>", desc = "Add File from Tree to Aider", ft = "NvimTree" },
      { "<leader>a-", "<cmd>AiderTreeDropFile<cr>", desc = "Drop File from Tree from Aider", ft = "NvimTree" },
    },
    dependencies = {
      "folke/snacks.nvim",
      --- The below dependencies are optional
      "catppuccin/nvim",
      "nvim-tree/nvim-tree.lua",
      --- Neo-tree integration
      {
        "nvim-neo-tree/neo-tree.nvim",
        opts = function(_, opts)
          -- Example mapping configuration (already set by default)
          -- opts.window = {
          --   mappings = {
          --     ["+"] = { "nvim_aider_add", desc = "add to aider" },
          --     ["-"] = { "nvim_aider_drop", desc = "drop from aider" }
          --   }
          -- }
          require("nvim_aider.neo_tree").setup(opts)
        end,
      },
    },
    config = true,
  }

⚙️ Configuration

There is no need to call setup if you don't want to change the default options.

require("nvim_aider").setup({
  -- Command that executes Aider
  aider_cmd = "aider",
  -- Command line arguments passed to aider
  args = {
    "--no-auto-commits",
    "--pretty",
    "--stream",
  },
  -- Theme colors (automatically uses Catppuccin flavor if available)
  theme = {
    user_input_color = "#a6da95",
    tool_output_color = "#8aadf4",
    tool_error_color = "#ed8796",
    tool_warning_color = "#eed49f",
    assistant_output_color = "#c6a0f6",
    completion_menu_color = "#cad3f5",
    completion_menu_bg_color = "#24273a",
    completion_menu_current_color = "#181926",
    completion_menu_current_bg_color = "#f4dbd6",
  },
  -- snacks.picker.layout.Config configuration
  picker_cfg = {
    preset = "vscode",
  },
  -- Other snacks.terminal.Opts options
  config = {
    os = { editPreset = "nvim-remote" },
    gui = { nerdFontsVersion = "3" },
  },
  win = {
    wo = { winbar = "Aider" },
    style = "nvim_aider",
    position = "bottom",
  },
})

🧩 Other Aider Neovim plugins


Made with 🤖 using Aider

About

🤖 Seamlessly integrate Aider with Neovim for an enhanced AI-assisted coding experience!

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •