Skip to content

Commit 84fc1d9

Browse files
authored
Merge branch 'main' into feat/context-editing-compaction
2 parents e22b634 + 7858b5a commit 84fc1d9

12 files changed

Lines changed: 429 additions & 211 deletions

File tree

doc/codecompanion.txt

Lines changed: 101 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*codecompanion.txt* For NVIM v0.11 Last change: 2026 May 04
1+
*codecompanion.txt* For NVIM v0.11 Last change: 2026 May 10
22

33
==============================================================================
44
Table of Contents *codecompanion-table-of-contents*
@@ -221,7 +221,7 @@ and blink.cmp <https://github.com/Saghen/blink.cmp>. For the latter, on version
221221
},
222222
<
223223

224-
The plugin also supports |codecompanion-usage-chat-buffer-completion| and
224+
The plugin also supports |codecompanion-usage-chat-buffer--completion| and
225225
coc.nvim <https://github.com/neoclide/coc.nvim>.
226226

227227

@@ -314,10 +314,10 @@ SETUP *codecompanion-getting-started-setup*
314314
CHAT AND INLINE ~
315315

316316

317-
[!NOTE] The adapters that the plugin supports out of the box can be found here
317+
[!NOTE] The adapters that the plugin supports out of the box can be found in
318+
the built-in adapters directory
318319
<https://github.com/olimorris/codecompanion.nvim/tree/main/lua/codecompanion/adapters>.
319-
Or, see the user contributed adapters
320-
|codecompanion-configuration-adapters-http-community-adapters|.
320+
Or, see the |codecompanion-configuration-adapters-http-community-adapters|.
321321
|codecompanion-configuration-adapters-acp| are only supported for the chat
322322
interaction.
323323
The Chat Buffer is where you can converse with an LLM from within a Neovim
@@ -450,7 +450,7 @@ Commands` in the chat buffer.
450450
**Editor Context**
451451

452452
`Editor Context`, accessed via `#` (by default), contain data about the present
453-
state of Neovim. You can find a list of available editor context,
453+
state of Neovim. You can find a
454454
|codecompanion-usage-chat-buffer-editor-context|. The buffer editor context
455455
will automatically link a buffer to the chat buffer, by default, updating the
456456
LLM when the buffer changes.
@@ -469,15 +469,13 @@ You can use them in your prompts like:
469469
`<C-_>` in insert mode when in the chat buffer. Note: Slash commands should
470470
also work with coc.nvim.
471471
`Slash commands`, accessed via `/` (by default), run commands to insert
472-
additional context into the chat buffer. You can find a list of available
473-
commands as well as how to use them,
472+
additional context into the chat buffer. You can find a
474473
|codecompanion-usage-chat-buffer-slash-commands|.
475474

476475
**Tools**
477476

478477
`Tools`, accessed via `@` (by default), allow the LLM to function as an agent
479-
and leverage external tools. You can find a list of available tools as well as
480-
how to use them,
478+
and leverage external tools. You can find a
481479
|codecompanion-usage-chat-buffer-agents-tools-available-tools|.
482480

483481
You can use them in your prompts like:
@@ -621,8 +619,9 @@ IN THE CHAT BUFFER ~
621619
[!NOTE] CodeCompanion enables context management by default
622620
If you're using the `openai_responses` or `anthropic` adapters, then
623621
CodeCompanion will use their native server-side compaction capabilities. Please
624-
see their respective documentation here
625-
<https://developers.openai.com/api/docs/guides/compaction> and here
622+
see the OpenAI compaction documentation
623+
<https://developers.openai.com/api/docs/guides/compaction> and Anthropic
624+
compaction documentation
626625
<https://platform.claude.com/docs/en/build-with-claude/compaction> for more
627626
information.
628627

@@ -1415,11 +1414,10 @@ The example below uses the `gemini-api-key` method, pulling the API key from
14151414

14161415
SETUP: GOOSE CLI ~
14171416

1418-
To use Goose <https://block.github.io/goose/> in CodeCompanion, ensure you've
1419-
followed their documentation
1420-
<https://block.github.io/goose/docs/getting-started/installation/> to setup and
1421-
install Goose CLI. Then ensure that in your chat buffer you select the `goose`
1422-
adapter.
1417+
To use Goose <https://goose-docs.ai/> in CodeCompanion, ensure you've followed
1418+
their documentation <https://goose-docs.ai/docs/getting-started/installation/>
1419+
to setup and install Goose CLI. Then ensure that in your chat buffer you select
1420+
the `goose` adapter.
14231421

14241422

14251423
SETUP: KILO CODE ~
@@ -1483,6 +1481,72 @@ You can specify a custom model in your `~/.config/opencode/config.json` file:
14831481
<
14841482

14851483

1484+
CREATING CUSTOM ACP ADAPTERS ~
1485+
1486+
Not every ACP-compatible tool will have a built-in adapter. You can define your
1487+
own directly in your configuration — the example below uses a hypothetical
1488+
`myagent` CLI tool. Use the built-in ACP adapters
1489+
<https://github.com/olimorris/codecompanion.nvim/blob/main/lua/codecompanion/adapters/acp>
1490+
as a reference.
1491+
1492+
>lua
1493+
require("codecompanion").setup({
1494+
adapters = {
1495+
acp = {
1496+
my_agent = function()
1497+
local helpers = require("codecompanion.adapters.acp.helpers")
1498+
return {
1499+
name = "my_agent",
1500+
formatted_name = "MyAgent",
1501+
type = "acp",
1502+
roles = {
1503+
llm = "assistant",
1504+
user = "user",
1505+
},
1506+
commands = {
1507+
default = {
1508+
"myagent",
1509+
"--acp",
1510+
},
1511+
},
1512+
defaults = {
1513+
mcpServers = {},
1514+
timeout = 20000, -- 20 seconds
1515+
},
1516+
parameters = {
1517+
protocolVersion = 1,
1518+
clientCapabilities = {
1519+
fs = { readTextFile = true, writeTextFile = true },
1520+
},
1521+
clientInfo = {
1522+
name = "CodeCompanion.nvim",
1523+
version = "1.0.0",
1524+
},
1525+
},
1526+
handlers = {
1527+
setup = function(self)
1528+
return true
1529+
end,
1530+
auth = function(self)
1531+
return true
1532+
end,
1533+
form_messages = function(self, messages, capabilities)
1534+
return helpers.form_messages(self, messages, capabilities)
1535+
end,
1536+
on_exit = function(self, code) end,
1537+
},
1538+
}
1539+
end,
1540+
},
1541+
},
1542+
})
1543+
<
1544+
1545+
User-created adapters are shared in the adapter discussions on GitHub
1546+
<https://github.com/olimorris/codecompanion.nvim/discussions?discussions_q=is%3Aopen+label%3A%22tip%3A+adapter%22>
1547+
— a good place to raise issues or ask questions about your specific adapter.
1548+
1549+
14861550
HTTP ADAPTERS *codecompanion-configuration-http-adapters*
14871551

14881552

@@ -1600,7 +1664,7 @@ the adapter's URL, headers, parameters and other fields at runtime.
16001664

16011665

16021666
[!NOTE] In this `command` example, we're using the 1Password CLI to extract the
1603-
Gemini API Key. You could also use gpg as outlined here
1667+
Gemini API Key. You could also use gpg as outlined in this community discussion
16041668
<https://github.com/olimorris/codecompanion.nvim/discussions/601>
16051669
Supported `env` value types: - **Plain environment variable name (string)**: if
16061670
the value is the name of an environment variable that has already been set
@@ -1850,8 +1914,8 @@ Thanks to the community for building the following adapters:
18501914
- Venice.ai <https://github.com/olimorris/codecompanion.nvim/discussions/972>
18511915
- Vertex AI <https://github.com/viespejo/cc-adapter-vertex-ai.nvim>
18521916

1853-
The section of the discussion forums which is dedicated to user created
1854-
adapters can be found here
1917+
The section of the discussion forums dedicated to user-created adapters can be
1918+
found in the adapter discussions on GitHub
18551919
<https://github.com/olimorris/codecompanion.nvim/discussions?discussions_q=is%3Aopen+label%3A%22tip%3A+adapter%22>.
18561920
Use these individual threads as a place to raise issues and ask questions about
18571921
your specific adapters.
@@ -3589,6 +3653,14 @@ buffer.
35893653
When in a chat buffer, you can cycle between other chat buffers with `{` or
35903654
`}`.
35913655

3656+
By default, opening or cycling to a chat hides whichever chat is currently
3657+
visible. If you'd rather keep chats per tab — so a chat opened in tab A is
3658+
never closed or stolen by activity in tab B — set `display.chat.window.pertab
3659+
= true` in your config. With that enabled, `{` / `}` only cycles through chats
3660+
that are visible in the current tab or not currently visible anywhere, and
3661+
`:CodeCompanionChat Toggle` jumps to the existing tab when the chat lives
3662+
there.
3663+
35923664

35933665
ACTION PALETTE *codecompanion-usage-action-palette*
35943666

@@ -3878,7 +3950,8 @@ HOW THEY WORK ~
38783950

38793951
Tools make use of an LLM's function calling
38803952
<https://platform.openai.com/docs/guides/function-calling> ability. All tools
3881-
in CodeCompanion follow OpenAI's function calling specification, here
3953+
in CodeCompanion follow OpenAI's function calling specification for defining
3954+
functions
38823955
<https://platform.openai.com/docs/guides/function-calling#defining-functions>.
38833956

38843957
When a tool is added to the chat buffer, the LLM is instructured by the plugin
@@ -3889,8 +3962,8 @@ which sees tool's added to a queue and sequentially worked with their output
38893962
being shared back to the LLM via the chat buffer. Depending on the tool, flags
38903963
may be inserted on the chat buffer for later processing.
38913964

3892-
An outline of the architecture can be seen
3893-
|codecompanion-extending-tools-architecture|.
3965+
An outline of the |codecompanion-extending-tools-architecture| is available in
3966+
the extending section.
38943967

38953968

38963969
AGENTS / TOOL GROUPS ~
@@ -4283,7 +4356,7 @@ receive up to date information:
42834356

42844357
Currently, the tool uses tavily <https://www.tavily.com> and you'll need to
42854358
ensure that an API key has been set accordingly, as per the adapter
4286-
<https://github.com/olimorris/codecompanion.nvim/blob/main/lua/codecompanion/adapters/tavily.lua>.
4359+
<https://github.com/olimorris/codecompanion.nvim/blob/main/lua/codecompanion/adapters/http/tavily.lua>.
42874360

42884361

42894362
ADAPTER TOOLS ~
@@ -4874,7 +4947,8 @@ file to share with the LLM. This can be a useful way to minimize token
48744947
consumption whilst sharing the basic outline of a file. The plugin utilizes the
48754948
amazing work from **aerial.nvim** by using their Tree-sitter symbol queries as
48764949
the basis. The list of filetypes that the plugin currently supports can be
4877-
found here <https://github.com/olimorris/codecompanion.nvim/tree/main/queries>.
4950+
found in the Tree-sitter queries directory
4951+
<https://github.com/olimorris/codecompanion.nvim/tree/main/queries>.
48784952

48794953
The command has native, `Telescope`, `mini.pick`, `fzf.lua` and `snacks.nvim`
48804954
providers available. Also, multiple symbols can be selected and added to the
@@ -5519,7 +5593,7 @@ This guide is intended to serve as a reference for anyone who wishes to
55195593
contribute an adapter to the plugin or understand the inner workings of
55205594
existing adapters.
55215595

5522-
The plugin's in-built adapters can be found here
5596+
The plugin's in-built adapters can be found in the adapters source directory
55235597
<https://github.com/olimorris/codecompanion.nvim/tree/main/lua/codecompanion/adapters>.
55245598

55255599

@@ -6872,7 +6946,7 @@ response from the LLM, identifying the tool and duly executing it.
68726946
There are two types of tools that CodeCompanion can leverage:
68736947

68746948
1. **Command-based**: These tools can execute a series of commands in the background using `vim.system`. They're non-blocking, meaning you can carry out other activities in Neovim whilst they run. Useful for heavy/time-consuming tasks.
6875-
2. **Function-based**: These tools, like insert_edit_into_file <https://github.com/olimorris/codecompanion.nvim/blob/main/lua/codecompanion/interactions/chat/tools/builtin/insert_edit_into_file.lua>, execute Lua functions directly in Neovim within the main process, one after another. They can also be executed asynchronously.
6949+
2. **Function-based**: These tools, like insert_edit_into_file <https://github.com/olimorris/codecompanion.nvim/blob/main/lua/codecompanion/interactions/chat/tools/builtin/insert_edit_into_file/init.lua>, execute Lua functions directly in Neovim within the main process, one after another. They can also be executed asynchronously.
68766950

68776951
For the purposes of this section of the guide, we'll be building a simple
68786952
function-based calculator tool that an LLM can use to do basic maths.

doc/configuration/adapters-acp.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,3 +409,62 @@ You can specify a custom model in your `~/.config/opencode/config.json` file:
409409
"model": "github-copilot/claude-sonnet-4.5",
410410
}
411411
```
412+
413+
## Creating Custom ACP Adapters
414+
415+
Not every ACP-compatible tool will have a built-in adapter. You can define your own directly in your configuration — the example below uses a hypothetical `myagent` CLI tool. Use the [built-in ACP adapters](https://github.com/olimorris/codecompanion.nvim/blob/main/lua/codecompanion/adapters/acp) as a reference.
416+
417+
````lua
418+
require("codecompanion").setup({
419+
adapters = {
420+
acp = {
421+
my_agent = function()
422+
local helpers = require("codecompanion.adapters.acp.helpers")
423+
return {
424+
name = "my_agent",
425+
formatted_name = "MyAgent",
426+
type = "acp",
427+
roles = {
428+
llm = "assistant",
429+
user = "user",
430+
},
431+
commands = {
432+
default = {
433+
"myagent",
434+
"--acp",
435+
},
436+
},
437+
defaults = {
438+
mcpServers = {},
439+
timeout = 20000, -- 20 seconds
440+
},
441+
parameters = {
442+
protocolVersion = 1,
443+
clientCapabilities = {
444+
fs = { readTextFile = true, writeTextFile = true },
445+
},
446+
clientInfo = {
447+
name = "CodeCompanion.nvim",
448+
version = "1.0.0",
449+
},
450+
},
451+
handlers = {
452+
setup = function(self)
453+
return true
454+
end,
455+
auth = function(self)
456+
return true
457+
end,
458+
form_messages = function(self, messages, capabilities)
459+
return helpers.form_messages(self, messages, capabilities)
460+
end,
461+
on_exit = function(self, code) end,
462+
},
463+
}
464+
end,
465+
},
466+
},
467+
})
468+
````
469+
470+
User-created adapters are shared in the [adapter discussions on GitHub](https://github.com/olimorris/codecompanion.nvim/discussions?discussions_q=is%3Aopen+label%3A%22tip%3A+adapter%22) — a good place to raise issues or ask questions about your specific adapter.

doc/configuration/chat-buffer.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,8 @@ require("codecompanion").setup({
867867
chat = {
868868
window = {
869869
buflisted = false, -- List the chat buffer in the buffer list?
870-
sticky = false, -- Chat window follows when switching tabs
870+
sticky = false, -- Chat window follows when switching tabs (ignored when `pertab` is true)
871+
pertab = false, -- Treat each tab as having its own chat window?
871872

872873
layout = "vertical", -- float|vertical|horizontal|tab|buffer
873874
full_height = true, -- for vertical layout

0 commit comments

Comments
 (0)