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
yamlparser, 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 codecompanionInstalling
nvim-treesitter is the easiest way to install the yaml parser:
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(){
"olimorris/codecompanion.nvim",
version = "^19.0.0",
opts = {},
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-treesitter/nvim-treesitter",
},
},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:
-- Lazy.nvim
{
"olimorris/codecompanion.nvim",
dependencies = {
"ravitemer/mcphub.nvim"
}
}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:
{
"MeanderingProgrammer/render-markdown.nvim",
ft = { "markdown", "codecompanion" }
},{
"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:
{
"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:
sources = {
per_filetype = {
codecompanion = { "codecompanion" },
}
},Help
If something isn't working, see Troubleshooting.