Skip to content

Installation ​

IMPORTANT

Pin the plugin to a release to avoid breaking changes

Requirements ​

  • Neovim 0.12 or later
  • curl
  • plenary.nvim
  • (Optional) An API key for your chosen LLM
  • (Optional) A Tree-sitter yaml parser, for markdown prompts in the prompt library and skills
  • (Optional) The file command, to detect the mimetype of images
  • (Optional) ripgrep, for the grep_search tool
  • (Optional) MarkItDown, to fetch webpages with the default adapter
  • (Optional) sqlite3, to read Copilot tokens from a SQLite database

To check them:

:checkhealth codecompanion

Installing ​

nvim-treesitter is the easiest way to install the yaml parser:

lua
vim.pack.add({ "https://www.github.com/nvim-lua/plenary.nvim" })
vim.pack.add({ "https://github.com/nvim-treesitter/nvim-treesitter" })
vim.pack.add({ {
  src = "https://www.github.com/olimorris/codecompanion.nvim",
  version = vim.version.range("^19.0.0")
} })

-- Somewhere in your config
require("codecompanion").setup()
lua
{
  "olimorris/codecompanion.nvim",
  version = "^19.0.0",
  opts = {},
  dependencies = {
    "nvim-lua/plenary.nvim",
    "nvim-treesitter/nvim-treesitter",
  },
},
lua
use({
  "olimorris/codecompanion.nvim",
  tag = "^19.0.0",
  config = function()
    require("codecompanion").setup()
  end,
  requires = {
    "nvim-lua/plenary.nvim",
    "nvim-treesitter/nvim-treesitter",
  },
}),

WARNING

If you pin your plugins to their latest releases, keep plenary.nvim on its master branch. See #377

Extensions ​

Extensions add features to CodeCompanion. To install and configure mcphub.nvim:

lua
-- Lazy.nvim
{
  "olimorris/codecompanion.nvim",
  dependencies = {
    "ravitemer/mcphub.nvim"
  }
}
lua
require("codecompanion").setup({
  extensions = {
    mcphub = {
      callback = "mcphub.extensions.codecompanion",
      opts = {
        make_vars = true,
        make_slash_commands = true,
        show_result_in_chat = true
      }
    }
  }
})

See Extending with Extensions for the extensions available and how to write your own.

Other Plugins ​

These plugins work well with CodeCompanion. The examples use lazy.nvim.

Rendering Markdown ​

render-markdown.nvim and markview.nvim render the markdown in the chat buffer:

lua
{
  "MeanderingProgrammer/render-markdown.nvim",
  ft = { "markdown", "codecompanion" }
},
lua
{
  "OXY2DEV/markview.nvim",
  lazy = false,
  opts = {
    preview = {
      filetypes = { "markdown", "codecompanion" },
      ignore_buftypes = {},
    },
  },
},

img-clip.nvim ​

img-clip.nvim pastes images from your clipboard into the chat buffer with :PasteImage:

lua
{
  "HakonHarnes/img-clip.nvim",
  opts = {
    filetypes = {
      codecompanion = {
        prompt_for_file_name = false,
        template = "[Image]($FILE_PATH)",
        use_absolute_path = true,
      },
    },
  },
},

Completion ​

Completion in the chat buffer works with blink.cmp, nvim-cmp and coc.nvim, or with Neovim's native completion. On blink.cmp 0.10.0 or earlier, add codecompanion as a source:

lua
sources = {
  per_filetype = {
    codecompanion = { "codecompanion" },
  }
},

Help ​

If something isn't working, see Troubleshooting.

Released under the Apache-2.0 License.