Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions doc/codecompanion.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*codecompanion.txt* For NVIM v0.11 Last change: 2026 March 07
*codecompanion.txt* For NVIM v0.11 Last change: 2026 March 09

==============================================================================
Table of Contents *codecompanion-table-of-contents*
Expand Down Expand Up @@ -1327,9 +1327,10 @@ The configuration for both types of adapters is exactly the same, however they
sit within their own tables (`adapters.http.*` and `adapters.acp.*`) and have
different options available. HTTP adapters use `models` to allow users to
select the specific LLM they’d like to interact with. ACP adapters use
`commands` to allow users to customize their interaction with agents (e.g.�
enabling `yolo` mode). As there is a lot of shared functionality between the
two adapters, it is recommend that you read this page alongside the ACP one.
`commands` to allow users to customize their interaction with agents
(e.g. enabling `yolo` mode). As there is a lot of shared functionality between
the two adapters, it is recommend that you read this page alongside the ACP
one.


CHANGING THE DEFAULT ADAPTER ~
Expand Down Expand Up @@ -1383,7 +1384,7 @@ the adapter’s URL, headers, parameters and other fields at runtime.
<https://github.com/olimorris/codecompanion.nvim/discussions/601>
Supported `env` value types: - **Plain environment variable name (string)**: if
the value is the name of an environment variable that has already been set
(e.g.`"HOME"` or `"GEMINI_API_KEY"`), the plugin will read the value. -
(e.g. `"HOME"` or `"GEMINI_API_KEY"`), the plugin will read the value. -
**Command (string prefixed with cmd:)**: any value that starts with `cmd:` will
be executed via the shell. Example: `"cmd:op read
op://personal/Gemini/credential --no-newline"`. - **Function**: you can provide
Expand Down Expand Up @@ -1560,8 +1561,15 @@ LLAMA.CPP WITH --REASONING-FORMAT DEEPSEEK

OLLAMA (REMOTELY)

To use Ollama remotely, change the URL in the env table, set an API key and
pass it via an "Authorization" header:
The simplest way to connect to a remote Ollama instance is to set the
`OLLAMA_HOST` environment variable (the same variable used by the Ollama CLI):

>bash
export OLLAMA_HOST="http://192.168.1.100:11434"
<

Alternatively, configure it directly in your setup using `extend()`. If you
need authentication, set an API key and pass it via an "Authorization" header:

>lua
require("codecompanion").setup({
Expand Down Expand Up @@ -3384,7 +3392,7 @@ The fastest way to copy an LLM’s code output is with `gy`. This will yank the
nearest codeblock.


APPLYING AN LLM€�S EDITS TO A BUFFER OR FILE ~
APPLYING AN LLMS EDITS TO A BUFFER OR FILE ~

The |codecompanion-usage-chat-buffer-agents-tools-files| tool, combined with
the |codecompanion-usage-chat-buffer-editor-context.html-buffer| editor context
Expand Down Expand Up @@ -4222,7 +4230,7 @@ message to the LLM.

[!IMPORTANT] With the exception of `#{buffer}` and `#{buffers}`, editor context
captures a point-in-time snapshot when your message is sent. If the underlying
data changes (e.g.new diagnostics, a different quickfix list), simply use the
data changes (e.g. new diagnostics, a different quickfix list), simply use the
context again in a new message to share the latest state.

#BUFFER ~
Expand Down Expand Up @@ -5118,7 +5126,7 @@ These handlers manage tool/function calling:
as a great reference to understand how they’re working with the output of the
API

OPENAI€�S API OUTPUT
OPENAIS API OUTPUT

If we reference the OpenAI documentation
<https://platform.openai.com/docs/guides/text-generation/chat-completions-api>
Expand Down Expand Up @@ -7024,7 +7032,7 @@ tool to function. In the case of Anthropic, we insert additional headers.
<

Some adapter tools can be a `hybrid` in terms of their implementation. That is,
they’re an adapter tool that requires a client-side component (i.e.a
they’re an adapter tool that requires a client-side component (i.e. a
built-in tool). This is the case for the
|codecompanion-usage-chat-buffer-agents-tools-memory| tool from Anthropic. To
allow for this, ensure that the tool definition in `available_tools` has
Expand Down
8 changes: 7 additions & 1 deletion doc/configuration/adapters-http.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,13 @@ require("codecompanion").setup({

### Ollama (remotely)

To use Ollama remotely, change the URL in the env table, set an API key and pass it via an "Authorization" header:
The simplest way to connect to a remote Ollama instance is to set the `OLLAMA_HOST` environment variable (the same variable used by the Ollama CLI):

```bash
export OLLAMA_HOST="http://192.168.1.100:11434"
```

Alternatively, configure it directly in your setup using `extend()`. If you need authentication, set an API key and pass it via an "Authorization" header:

```lua
require("codecompanion").setup({
Expand Down
4 changes: 3 additions & 1 deletion lua/codecompanion/adapters/http/ollama/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ return {
["Content-Type"] = "application/json",
},
env = {
url = "http://localhost:11434",
url = function()
return os.getenv("OLLAMA_HOST") or "http://localhost:11434"
end,
},
handlers = {
setup = function(self)
Expand Down
17 changes: 17 additions & 0 deletions tests/adapters/http/test_ollama.lua
Original file line number Diff line number Diff line change
Expand Up @@ -343,4 +343,21 @@ T["Ollama adapter"]["No Streaming"]["can output for the inline assistant"] = fun
h.eq("Dynamic Scripting language", adapter.handlers.inline_output(adapter, json).output)
end

T["Ollama adapter"]["OLLAMA_HOST"] = new_set()

T["Ollama adapter"]["OLLAMA_HOST"]["uses OLLAMA_HOST when set"] = function()
local adapter_utils = require("codecompanion.utils.adapters")
vim.env.OLLAMA_HOST = "http://192.168.1.100:11434"
adapter_utils.get_env_vars(adapter)
h.eq("http://192.168.1.100:11434", adapter.env_replaced.url)
vim.env.OLLAMA_HOST = nil
end

T["Ollama adapter"]["OLLAMA_HOST"]["fallback to localhost when OLLAMA_HOST is not set"] = function()
local adapter_utils = require("codecompanion.utils.adapters")
vim.env.OLLAMA_HOST = nil
adapter_utils.get_env_vars(adapter)
h.eq("http://localhost:11434", adapter.env_replaced.url)
end

return T
Loading