Introducing CodeCompanion.nvim: Your Neovim's Best Friend
CodeCompanion.nvim is an impressive Neovim plugin that brings the power of large language models (LLMs) directly into your coding environment. With a focus on integration and productivity, this plugin promises to streamline coding workflows and enhance the interactive experience within Neovim. Below, you will find a detailed introduction to its features, requirements, and how it can become an essential tool for developers.
Features
Copilot Chat and Zed AI Combined in Neovim
This feature enables a harmonious interaction between GitHub's Copilot Chat and Zed AI, seamlessly integrated into Neovim. Users can enhance their coding discussions with these AI-powered assistants, making suggestions and getting assistance in real-time.
Multiple LLM Adapter Support
CodeCompanion.nvim supports diverse LLMs, including Anthropic, Copilot, Gemini, Ollama, OpenAI, and xAI. Developers have the flexibility to integrate their preferred LLM or bring in a custom solution to fit their unique project requirements.
Inline Transformations and Code Refactoring
The plugin allows for inline code transformations, simplifying the process of code creation and refactoring. This feature provides developers with a powerful tool to write and update code efficiently.
Enhanced LLM Outputs with Variables, Slash Commands, and More
The plugin ensures improved LLM outputs through the use of agents/tools, Variables, Slash Commands, and Workflows. These features offer additional context and processing capabilities, which are instrumental in generating more accurate and relevant LLM responses.
Built-in Prompt Library
CodeCompanion.nvim comes with a built-in prompt library that caters to common coding tasks, like providing advice on Language Server Protocol (LSP) errors and explaining code snippets. This library can be customized, allowing users to create their own prompts, Variables, and Slash Commands to suit individual needs.
Multiple Open Chats and Asynchronous Execution
Users can maintain multiple chat sessions simultaneously, increasing productivity by allowing parallel interactions with different LLMs or ongoing tasks. The asynchronous execution ensures that these interactions and AI responses do not interrupt the coding flow, providing fast and smooth performance.
Requirements
To make the most of CodeCompanion.nvim, users need to ensure the following requirements are met:
- The
curl
library - Neovim 0.10.0 or greater
- An optional API key for the chosen LLM (if required)
Installation
Installing the plugin is straightforward and can be done with popular package managers like Lazy.nvim, Packer, or vim-plug. Example scripts for each manager's configuration are provided to facilitate an effortless setup.
For instance, using Lazy.nvim, the installation code looks like:
{
"olimorris/codecompanion.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-treesitter/nvim-treesitter",
"hrsh7th/nvim-cmp",
"nvim-telescope/telescope.nvim",
{ "stevearc/dressing.nvim", opts = {} },
},
config = true
}
Quickstart Guide
To begin using CodeCompanion.nvim, it's vital to initially configure an adapter to connect with the preferred LLM. The plugin offers several strategies like chat and inline to interact with LLMs efficiently.
Chat Buffer
Invoke :CodeCompanionChat
to open a chat interface where you can type prompts and engage directly with the LLM. Users can employ Variables and Slash Commands to provide further context, such as /buffer
to insert open buffers or /fetch
to pull content from a URL.
Inline Assistant
Run :CodeCompanion <your prompt>
to use the inline assistant for writing or altering code directly in your Neovim buffer. The assistant also memorizes conversations, making it adept at executing commands based on past interactions.
Configuration and Customization
A core strength of CodeCompanion.nvim is its configurability. Users are free to set environment variables, tailor prompts, or even extend the existing adapters by altering configurations. Adapters can connect to LLMs via proxy or use OpenAI-compatible models.
In sum, CodeCompanion.nvim is designed to be a flexible and powerful Neovim plugin that empowers developers to work smarter with the aid of advanced language models. Whether through dynamic in-line coding or engaging chat interfaces, the plugin promises to elevate the coding experience in Neovim to new heights.