Replies: 2 comments 17 replies
-
|
Pretty sure you can take the existing ACP adapters and change the command to point to Opencode |
Beta Was this translation helpful? Give feedback.
-
|
Hi! I just tried opencode acp but can't get it to work. I have latest version of codecompanion and opencode. Do i need to start a opencode server manually first? When i open the chat window neovim hangs for quite some time and then i get the following error message Here's my config return {
"olimorris/codecompanion.nvim",
-- dir = "~/Projects/einarpersson/codecompanion.nvim/",
dependencies = {
"nvim-lua/plenary.nvim",
"j-hui/fidget.nvim",
},
init = function()
vim.keymap.set({ "n", "v" }, "<C-a>", "<cmd>CodeCompanionActions<cr>", { noremap = true, silent = true })
vim.keymap.set({ "n", "v" }, "<LocalLeader>a", "<cmd>CodeCompanionChat Toggle<cr>", { noremap = true, silent = true })
vim.keymap.set("v", "ga", "<cmd>CodeCompanionChat Add<cr>", { noremap = true, silent = true })
end,
opts = {
strategies = {
chat = {
adapter = "opencode",
},
inline = {
adapter = "anthropic",
},
},
display = {
diff = {
provider = "mini_diff",
},
chat = {
show_token_count = true,
fold_context = true,
}
},
adapters = {
acp = {
opencode = "opencode",
},
http = {
anthropic = function()
return require("codecompanion.adapters").extend("anthropic", {
env = {
api_key = "cmd:cat /home/einar/.config/nvim/.claude.key",
},
schema = {
extended_thinking = {
default = false,
},
},
})
end,
}
},
}
}I also tried with the minimal.lua in this repo and added acp adapter opencode. I get same result. After a while I could at least send a "hi" and checking the debug info I see this -- Adapter: "OpenCode"
-- With Command: "opencode acp"
-- Mode: "learning (learning)"
-- Buffer Number: 18
-- Following Buffer: "lua/plugins/codecompanion.lua" (12)
local messages =
{ {
_meta = {
cycle = 1,
id = 873739340,
index = 1,
tag = "system_prompt_from_config"
},
content = "You are an AI programming assistant named \"CodeCompanion\", working within the Neovim text editor.\n\nYou can answer general programming questions and perform the following tasks:\n* Answer general programming questions.\n* Explain how the code in a Neovim buffer works.\n* Review the selected code from a Neovim buffer.\n* Generate unit tests for the selected code.\n* Propose fixes for problems in the selected code.\n* Scaffold code for a new workspace.\n* Find relevant code to the user's query.\n* Propose fixes for test failures.\n* Answer questions about Neovim.\n\nFollow the user's requirements carefully and to the letter.\nUse the context and attachments the user provides.\nKeep your answers short and impersonal, especially if the user's context is outside your core tasks.\nUse Markdown formatting in your answers.\nDo not use H1 or H2 markdown headers.\nWhen suggesting code changes or new content, use Markdown code blocks.\nTo start a code block, use 4 backticks.\nAfter the backticks, add the programming language name as the language ID.\nTo close a code block, use 4 backticks on a new line.\nIf the code modifies an existing file or should be placed at a specific location, add a line comment with 'filepath:' and the file path.\nIf you want the user to decide where to place the code, do not add the file path comment.\nIn the code block, use a line comment with '...existing code...' to indicate code that is already present in the file.\nCode block example:\n````languageId\n// filepath: /path/to/file\n// ...existing code...\n{ changed code }\n// ...existing code...\n{ changed code }\n// ...existing code...\n````\nEnsure line comments use the correct syntax for the programming language (e.g. \"#\" for Python, \"--\" for Lua).\nFor code blocks use four backticks to start and end.\nAvoid wrapping the whole response in triple backticks.\nDo not include diff formatting unless explicitly asked.\nDo not include line numbers in code blocks.\n\nWhen given a task:\n1. Think step-by-step and, unless the user requests otherwise or the task is very simple, describe your plan in pseudocode.\n2. When outputting code blocks, ensure only relevant code is included, avoiding any repeating or unrelated code.\n3. End your response with a short suggestion for the next user turn that directly supports continuing the conversation.\n\nAdditional context:\nAll non-code text responses must be written in the English language.\nThe current date is 2025-11-20.\nThe user's Neovim version is 0.11.2.\nThe user is working on a Linux machine. Please respond with system specific commands if applicable.\n",
opts = {
visible = false
},
role = "system"
}, {
_meta = {
cycle = 1,
id = 1131121490,
index = 2,
sent = true
},
content = "hi",
opts = {
visible = true
},
role = "user"
} }and -- Adapter: "OpenCode"
-- With Command: "opencode acp"
-- Buffer Number: 2
-- Following Buffer: "" (1)
local messages =
{ {
_meta = {
cycle = 1,
id = 873739340,
index = 1,
tag = "system_prompt_from_config"
},
content = "You are an AI programming assistant named \"CodeCompanion\", working within the Neovim text editor.\n\nYou can answer general programming questions and perform the following tasks:\n* Answer general programming questions.\n* Explain how the code in a Neovim buffer works.\n* Review the selected code from a Neovim buffer.\n* Generate unit tests for the selected code.\n* Propose fixes for problems in the selected code.\n* Scaffold code for a new workspace.\n* Find relevant code to the user's query.\n* Propose fixes for test failures.\n* Answer questions about Neovim.\n\nFollow the user's requirements carefully and to the letter.\nUse the context and attachments the user provides.\nKeep your answers short and impersonal, especially if the user's context is outside your core tasks.\nUse Markdown formatting in your answers.\nDo not use H1 or H2 markdown headers.\nWhen suggesting code changes or new content, use Markdown code blocks.\nTo start a code block, use 4 backticks.\nAfter the backticks, add the programming language name as the language ID.\nTo close a code block, use 4 backticks on a new line.\nIf the code modifies an existing file or should be placed at a specific location, add a line comment with 'filepath:' and the file path.\nIf you want the user to decide where to place the code, do not add the file path comment.\nIn the code block, use a line comment with '...existing code...' to indicate code that is already present in the file.\nCode block example:\n````languageId\n// filepath: /path/to/file\n// ...existing code...\n{ changed code }\n// ...existing code...\n{ changed code }\n// ...existing code...\n````\nEnsure line comments use the correct syntax for the programming language (e.g. \"#\" for Python, \"--\" for Lua).\nFor code blocks use four backticks to start and end.\nAvoid wrapping the whole response in triple backticks.\nDo not include diff formatting unless explicitly asked.\nDo not include line numbers in code blocks.\n\nWhen given a task:\n1. Think step-by-step and, unless the user requests otherwise or the task is very simple, describe your plan in pseudocode.\n2. When outputting code blocks, ensure only relevant code is included, avoiding any repeating or unrelated code.\n3. End your response with a short suggestion for the next user turn that directly supports continuing the conversation.\n\nAdditional context:\nAll non-code text responses must be written in the English language.\nThe current date is 2025-11-20.\nThe user's Neovim version is 0.11.2.\nThe user is working on a Linux machine. Please respond with system specific commands if applicable.\n",
opts = {
visible = false
},
role = "system"
}, {
_meta = {
cycle = 1,
id = 799117247,
index = 2
},
content = "hello",
opts = {
visible = true
},
role = "user"
} }I have read the docs but they seems to suggest that things should "just work". |
Beta Was this translation helpful? Give feedback.



Uh oh!
There was an error while loading. Please reload this page.
-
Opencode has recently added support for ACP: https://opencode.ai/docs/acp/
Anyone knows how configure codecompanion to use it?
Beta Was this translation helpful? Give feedback.
All reactions