Codecompanion.Nvim

✨ AI Coding, Vim Style

Last verified:

Visit Codecompanion.Nvim

What is Codecompanion.Nvim?

CodeCompanion.nvim is a Neovim plugin that enables AI-powered coding using large language models (LLMs) and agents directly within Neovim. It brings a Copilot Chat-like and Zed AI-like experience to Neovim, allowing developers to interact with AI assistants through chat buffers, inline code transformations, and CLI interactions. The plugin uses HTTP and Agent Client Protocol (ACP) adapters to connect to various LLM providers and AI agents.

Key features include support for numerous LLM providers (Anthropic, Copilot, GitHub Models, DeepSeek, Gemini, Mistral AI, Novita, Ollama, OpenAI, Azure OpenAI, HuggingFace, xAI), Agent Client Protocol support for agents like Claude Code, Codex, Gemini CLI, and Copilot CLI, inline code transformations and refactoring, a built-in prompt library for common tasks like explaining LSP errors and generating commit messages, support for Model Context Protocol (MCP), vision/image input support, multiple simultaneous chat buffers, custom prompts and slash commands, editor context features, and async execution for fast performance.

The plugin is designed for Neovim users who want AI-assisted coding without leaving their editor. It is particularly suitable for developers who already use Neovim and want Copilot Chat functionality, those who prefer Vim-style workflows, developers who want to use multiple LLM providers from one interface, and users who want agent-based coding with tools like Claude Code integrated into Neovim. It requires Neovim 0.11.0 or greater and works best with users familiar with Neovim's buffer and command system.

Codecompanion.Nvim pricing

Pricing model: Freemium

The CodeCompanion.nvim plugin itself is completely free and open source. However, most LLM providers require API keys which have their own pricing: Anthropic requires an API key (prompt caching supported), GitHub Copilot requires a token from copilot.vim setup (requires Copilot subscription), Anthropic Claude Code requires API key or Claude Pro subscription, Gemini requires API key or Gemini Pro subscription, Mistral AI requires API key or Le Chat Pro subscription, OpenAI requires API key, DeepSeek requires API key, and other providers like Augment Code, Codex, Goose, HuggingFace, Kilo Code, Kimi CLI, Novita, and xAI all require API keys. Ollama is free for local models. GitHub Models can be used basically for free with limits of 4000-8000 tokens which is enough for daily usage.

Codecompanion.Nvim pros

  • Supports 20+ LLM providers out of the box including Anthropic, Copilot, OpenAI, Gemini, and Ollama
  • Agent Client Protocol support for Claude Code, Codex, Gemini CLI, Copilot CLI and more
  • Copilot Chat-like experience directly in Neovim
  • Inline code transformations write output directly into Neovim buffers
  • Built-in prompt library with /commit, /explain, /fix, /lsp, and /tests commands
  • Support for Model Context Protocol (MCP) for enhanced tool use
  • Vision support allows images as input to LLMs
  • Multiple chat buffers can be open simultaneously
  • Custom prompts, slash commands, and editor context can be created
  • Async execution ensures fast performance without blocking
  • Default adapter is GitHub Copilot which works out of the box if copilot.vim is installed
  • Supports local LLMs via Ollama for privacy and offline use
  • Action palette provides access to all plugin features with Telescope/mini_pick integration
  • Editor context with #buffer automatically updates when buffer changes
  • Tools like @cmd_runner let LLM execute tests and commands on your machine
  • Grep search tool with ripgrep integration for finding code occurrences
  • Keymap gy quickly yanks the nearest codeblock from LLM output
  • Support for rules files like CLAUDE.md and .cursor/rules
  • Native Neovim completion works with nvim-cmp and blink.cmp
  • Community-contributed adapters extend provider support

Codecompanion.Nvim cons

  • Requires Neovim 0.11.0 or greater which may not be available on all systems
  • Most LLM providers require API keys which adds cost and setup complexity
  • Initial configuration can be complex for Neovim beginners
  • Requires curl library as a dependency
  • nvim-treesitter with YAML parser needed for markdown prompt library
  • ripge library required for grep_search tool functionality
  • File command needed for detecting image mimetype with vision support
  • ACP adapters only supported for chat interaction not inline
  • Pinning to specific release version recommended to avoid breaking changes
  • Some users may need Vim/Neovim prior experience to use effectively

Frequently asked questions about Codecompanion.Nvim

What is CodeCompanion.nvim?

CodeCompanion.nvim is a Neovim plugin which enables you to code with AI using LLMs and agents directly in Neovim. It provides a Copilot Chat-like experience with support for 20+ LLM providers and AI agents via HTTP and Agent Client Protocol adapters.

What LLM providers does CodeCompanion support?

CodeCompanion supports Anthropic, Augment Code, Cagent, Claude Code, Cline CLI, Codex, Copilot, DeepSeek, Gemini, Gemini CLI, GitHub Models, Goose, HuggingFace, Kilo Code, Kimi CLI, Mistral AI, Novita, Ollama, OpenAI, opencode, and xAI out of the box. You can also create custom adapters or use community-contributed adapters.

What are the system requirements for CodeCompanion?

CodeCompanion requires Neovim 0.11.0 or greater, the curl library, and optionally an API key for your chosen LLM. Optional dependencies include nvim-treesitter with YAML parser for markdown prompts, the file command for image mimetype detection, and ripgrep for the grep_search tool.

What are the different interaction types in CodeCompanion?

CodeCompanion has five interaction types: Chat (chat buffer for direct LLM conversation via :CodeCompanionChat), CLI (terminal wrapper for agent CLIs like Claude Code via :CodeCompanionCLI), Inline (writes code directly into buffer via :CodeCompanion), Cmd (creates Neovim commands in command-line via :CodeCompanionCmd), and Background (runs tasks like compacting messages or generating chat titles).

How do I set up an adapter in CodeCompanion?

Adapters are configured in the setup function under the interactions table. For example, set chat adapter to 'anthropic' and inline adapter to 'copilot'. Most adapters look for environment variables like ANTHROPIC_API_KEY or OPENAI_API_KEY. You can also override API keys using the extend function in the adapters configuration.

What is the default adapter in CodeCompanion?

The default adapter in CodeCompanion is GitHub Copilot. If you have copilot.vim or copilot.lua installed, CodeCompanion will work out of the box without additional configuration.

How do I use slash commands in CodeCompanion chat?

Slash commands are accessed via / (by default) in the chat buffer and run commands to insert additional context. They work with native Neovim completions alongside nvim-cmp and blink.cmp. Use <C-_> in insert mode to open the native completion menu. Available slash commands include /buffer for buffer context.

What tools are available in CodeCompanion?

Tools are accessed via @ (by default) and allow LLMs to function as agents. Key tools include @insert_edit_into_file for modifying code in buffers, @cmd_runner for executing commands and running test suites, and @grep_search for finding code occurrences using ripgrep. Tag tools in chat buffer like @cmd_runner or #{buffer} for editor context.

How do I copy code from a chat buffer?

The fastest way to copy code from a chat buffer is using gy which yanks the nearest codeblock. You can also navigate between responses using [[ or ]] and cycle between chat buffers using { or } when in a chat buffer.

Can I use CodeCompanion with local LLMs?

Yes, CodeCompanion supports Ollama adapter which works with both locally hosted and remotely hosted Ollama instances. This allows you to use local LLMs for privacy and offline use without API keys.

Categories

Use cases

Browse all AI tools on NeedAnAI