Configuring the Inline Interaction
IMPORTANT
HTTP adapters must use a model that supports tool calling. ACP agents edit a temporary copy of the buffer instead
CodeCompanion provides an inline interaction for quick, direct editing of your code. Unlike the chat buffer, the LLM edits the current buffer directly, using the same edit_file tool as the chat buffer.
Changing Adapter
The inline interaction uses the copilot adapter with the gpt-5.4-mini model by default. To change it:
require("codecompanion").setup({
interactions = {
inline = {
adapter = {
name = "anthropic",
model = "claude-haiku-4-5-20251001",
},
},
},
})An ACP agent can be used too:
require("codecompanion").setup({
interactions = {
inline = {
adapter = "claude_code",
},
},
})See Configuring HTTP Adapters and Configuring ACP Adapters for more.
Keymaps
The keymaps for reviewing an inline diff are shared with the chat buffer's diff. accept_hunk, reject_hunk and undo_hunk only apply to the inline interaction:
require("codecompanion").setup({
interactions = {
shared = {
keymaps = {
accept_change = {
modes = { n = "g2" },
},
reject_change = {
modes = { n = "g3" },
},
accept_hunk = {
modes = { n = "ga" },
},
reject_hunk = {
modes = { n = "gr" },
},
undo_hunk = {
modes = { n = "u" },
},
next_hunk = {
modes = { n = "}" },
},
previous_hunk = {
modes = { n = "{" },
},
show_keymaps = {
modes = { n = "?" },
},
},
},
},
})You can also cancel an inline request with:
require("codecompanion").setup({
interactions = {
inline = {
keymaps = {
stop = {
modes = { n = "q" },
index = 4,
callback = "keymaps.stop",
description = "Stop request",
},
},
},
},
})The keymaps for accepting and rejecting a change, g1, g2 and g3, are shared with the chat buffer and live under interactions.shared.keymaps. See Configuring the Diff.
Editor Context
Editor context shares part of your Neovim session with the LLM, using the #{} syntax in a prompt. Alongside the built-in items, you can add your own:
require("codecompanion").setup({
interactions = {
inline = {
editor_context = {
["my_context_item"] = {
path = "/Users/Oli/Code/my_context_item.lua",
description = "My context item",
opts = {
contains_code = true,
},
},
},
},
},
})Context Limit
The inline interaction shares the whole buffer with the LLM, unless it's over a token limit. Then it shares the lines around your cursor, or your selection, up to the limit. By default, the limit is 16,000 tokens. To change it:
require("codecompanion").setup({
interactions = {
inline = {
opts = {
max_context_tokens = 8000,
},
},
},
})If the model's input limit minus 3,000 is smaller, that's used instead, leaving room for the prompt and the reply. When you continue a conversation with an HTTP adapter, the earlier turns are taken off that too.
Rules and Skills
Edits should follow your project's conventions, so the inline interaction sends your rules with every prompt. By default that's the default group, which includes AGENTS.md and CLAUDE.md. To choose the groups:
require("codecompanion").setup({
rules = {
opts = {
inline = {
autoload = { "default", "my_project_rules" }, -- Can be a string, a list or a function returning either
},
},
},
})Set autoload = {} to send no rules. Rules sent this way don't count towards the context limit.
Skills aren't sent by default. Inline makes a single request with no time to read a skill when it needs one, so the full instructions of each skill you name go with every prompt:
require("codecompanion").setup({
skills = {
opts = {
inline = {
autoload = { "lua-developer" },
},
},
},
})NOTE
Rules and skills are only sent to HTTP adapters. An ACP agent loads its own
Diff
Changes to an existing buffer are shown as a diff before they're kept. To write them straight to the buffer instead, turn off display.diff.enabled. See Configuring the Diff.