# [codecompanion.nvim](https://github.com/olimorris/codecompanion.nvim)

> AI-powered coding, seamlessly in Neovim

**codecompanion.nvim** is a productivity tool which streamlines how you develop with LLMs, in Neovim.

## Features

- :speech_balloon: [Copilot Chat](https://github.com/features/copilot) meets [Zed AI](https://zed.dev/blog/zed-ai), in Neovim
- :electric_plug: Support for Anthropic, Copilot, Gemini, Ollama, OpenAI, Azure OpenAI, HuggingFace and xAI LLMs (or bring your own!)
- :rocket: Inline transformations, code creation and refactoring
- :robot: Variables, Slash Commands, Agents/Tools and Workflows to improve LLM output
- :sparkles: Built in prompt library for common tasks like advice on LSP errors and code explanations
- :building_construction: Create your own custom prompts, Variables and Slash Commands
- :books: Have multiple chats open at the same time
- :muscle: Async execution for fast performance

## Installation

First, Navigate to the nvim configuration folder (default on Linux is `~/.config/nvim`)

### Install via `lazy.nvim`

Then to the `lua/plugins` folder. Create a file named `init.lua` and add the following content:

```lua
return {
  "olimorris/codecompanion.nvim",
  dependencies = {
    "nvim-lua/plenary.nvim",
    "nvim-treesitter/nvim-treesitter",
  },
  config = function()
    require("codecompanion").setup({
      adapters = {
        deepseek = function()
          return require("codecompanion.adapters").extend("deepseek", {
            env = {
              api_key = "YOUR_API_KEY",
            },
          })
        end,
      },
      strategies = {
        chat = { adapter = "deepseek", },
        inline = { adapter = "deepseek" },
        agent = { adapter = "deepseek" },
      },
    })
  end
}
```
Restart nvim, and `lazy.nvim` should automatically download and install the codecompanion.nvim plugin and its dependencies based on the above file.

### Install via `mini.deps`

Add the following content to your `init.lua`:

```lua
local add, later = MiniDeps.add, MiniDeps.later

later(function()
  add({
    source = "olimorris/codecompanion.nvim",
    depends = {
      "nvim-lua/plenary.nvim",
      "nvim-treesitter/nvim-treesitter",
    },
  })
  require("codecompanion").setup({
    adapters = {
      deepseek = function()
        return require("codecompanion.adapters").extend("deepseek", {
          env = {
              api_key = "YOUR_API_KEY",
          },
        })
      end,
    },
    strategies = {
      chat = { adapter = "deepseek", },
      inline = { adapter = "deepseek" },
      agent = { adapter = "deepseek" },
    },
  })
end)
```
Restart nvim, and `mini.deps` should also automatically download and install the codecompanion.nvim plugin.


### Other Installation Methods
https://codecompanion.olimorris.dev/installation.html

## Usage
https://codecompanion.olimorris.dev/usage/introduction.html