Skip to content
Edit this page

AI

The AI extra adds CodeCompanion: a chat buffer next to your code and inline edits, with the LLM you choose. It is off by default. With it off, nothing about CodeCompanion is installed or loaded, and with it on, nothing is sent anywhere until you open a chat or ask for an edit.

-- user/settings.lua
M.config = {
  extras = { ai = true },
  codecompanion = {
    interactions = {
      chat = { adapter = "anthropic" }, -- or "openai", "gemini", "deepseek", "mistral", ...
      inline = { adapter = "anthropic" },
    },
  },
}

Restart Neovim (or run :Lazy install). :CodeArtSetup can turn the extra on too, in the optional plugins question.

Keys

Keys Mode What it does
<leader>aa normal Open or hide the chat
<leader>aa visual Add the selection to the chat
<leader>ai normal, visual Inline edit: asks for a prompt, then changes the buffer (or the selection) in place. You accept or reject the change

All of CodeCompanion's own commands work as well: :CodeCompanionChat, :CodeCompanion <prompt>, :CodeCompanionActions and :CodeCompanionCmd. In the chat buffer, ? shows its keys.

Choosing the LLM

CodeCompanion calls the service behind an adapter. Everything in config.codecompanion goes to require("codecompanion").setup(), so its configuration docs apply as they are.

  • An API key. HTTP adapters read the key from an environment variable named after the provider, such as ANTHROPIC_API_KEY, OPENAI_API_KEY or GEMINI_API_KEY. Set it in your shell profile, not in user/settings.lua, so it stays out of your config files.
  • GitHub Copilot. Without an adapter, CodeCompanion uses Copilot, which works once you have signed in with copilot.vim or copilot.lua. :checkhealth codeart warns when no adapter is set, so you know which one is in use.
  • An agent. Adapters such as claude_code, codex and gemini_cli run a coding agent over the Agent Client Protocol in the chat buffer. Each needs its own setup; see ACP adapters.

A local model

With Ollama running on your machine, nothing leaves it:

M.config = {
  extras = { ai = true },
  codecompanion = {
    interactions = {
      chat = { adapter = { name = "ollama", model = "qwen3:8b" } },
      inline = { adapter = { name = "ollama", model = "qwen3:8b" } },
    },
  },
}

Pull the model first (ollama pull qwen3:8b). Any model Ollama has works; smaller ones answer faster but edit less reliably.

Checking it

:checkhealth codeart shows the AI extra in the Extras section: whether codecompanion.nvim is installed and which adapter the chat uses. :checkhealth codecompanion checks CodeCompanion's own requirements (curl, the yaml parser, which CodeArt installs when the extra first loads).

To keep the extra on but drop the plugin for a while: M.disable_plugins = { codecompanion = true }.

Other AI plugins

CodeArt ships one AI plugin so that its keys, health and docs stay simple. Others work as your own plugins in additional_plugins (see Extra plugins):

-- user/settings.lua: Copilot suggestions as you type
M.additional_plugins = {
  {
    "zbirenbaum/copilot.lua",
    cmd = "Copilot",
    event = "InsertEnter",
    opts = { suggestion = { auto_trigger = true } },
  },
}
-- user/settings.lua: Claude Code in a terminal split, with your buffers as context
M.additional_plugins = {
  {
    "coder/claudecode.nvim",
    dependencies = { "folke/snacks.nvim" },
    cmd = { "ClaudeCode", "ClaudeCodeSend" },
    opts = {},
  },
}

Pick keys for them that do not clash with <leader>aa and <leader>ai if the AI extra is on too.