doc/installation.md
[!IMPORTANT] To avoid breaking changes, it is recommended to pin the plugin to a specific release when installing.
curl libraryyaml parser for markdown prompt library itemsgrep_search toolYou can run :checkhealth codecompanion to verify that all requirements are met.
The plugin can be installed with the plugin manager of your choice. It is recommended to pin the plugin to a specific release to avoid breaking changes.
nvim-treesitter is required if you plan to use markdown prompts in the prompt library, ensuring you have the yaml parser installed.
::: code-group
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",
},
}),
:::
Plenary.nvim note:
As per #377, if you pin your plugins to the latest releases, ensure you set plenary.nvim to follow the master branch
CodeCompanion supports extensions that add additional functionality to the plugin. Below is an example which installs and configures mcphub.nvim:
::: code-group
-- 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
}
}
}
})
:::
Visit the extensions documentation to learn more about available extensions and how to create your own.
CodeCompanion integrates with a number of other plugins to make your AI coding experience more enjoyable. Below are some common lazy.nvim configurations for popular plugins:
::: code-group
{
"MeanderingProgrammer/render-markdown.nvim",
ft = { "markdown", "codecompanion" }
},
{
"OXY2DEV/markview.nvim",
lazy = false,
opts = {
preview = {
filetypes = { "markdown", "codecompanion" },
ignore_buftypes = {},
},
},
},
{
"HakonHarnes/img-clip.nvim",
opts = {
filetypes = {
codecompanion = {
prompt_for_file_name = false,
template = "[Image]($FILE_PATH)",
use_absolute_path = true,
},
},
},
},
:::
Use render-markdown.nvim or markview.nvim to render the markdown in the chat buffer. Use img-clip.nvim to copy images from your system clipboard into a chat buffer via :PasteImage:
When in the chat buffer, completion can be used to more easily add editor context, slash commands and tools. Out of the box, the plugin supports completion with both nvim-cmp and blink.cmp. For the latter, on version <= 0.10.0, ensure that you've added codecompanion as a source:
sources = {
per_filetype = {
codecompanion = { "codecompanion" },
}
},
The plugin also supports native completion and coc.nvim.
Consider using the minimal.lua file to troubleshoot, running it with nvim --clean -u minimal.lua.