olimorris / codecompanion.nvim Goto Github PK
View Code? Open in Web Editor NEW✨ A Copilot Chat experience in Neovim. Supports Anthropic, Ollama and OpenAI LLMs
License: MIT License
✨ A Copilot Chat experience in Neovim. Supports Anthropic, Ollama and OpenAI LLMs
License: MIT License
minimal.lua
configlocal root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for , name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
-- Your CodeCompanion setup
local plugins = {
{
"olimorris/codecompanion.nvim",
-- dir = "~/project/codecompanion.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-treesitter/nvim-treesitter",
"nvim-telescope/telescope.nvim", -- Optional
{
"stevearc/dressing.nvim", -- Optional: Improves the default Neovim UI
opts = {},
},
{
"folke/edgy.nvim",
event = "VeryLazy",
init = function()
vim.opt.laststatus = 3
vim.opt.splitkeep = "screen"
end,
opts = {
animate = {
enabled = false,
},
right = {
{ ft = "codecompanion", title = "Code Companion Chat", size = { width = 0.45 } },
},
},
},
},
cmds = { "CodeCompanion", "CodeCompanionChat", "CodeCompanionToggle", "CodeCompanionActions" },
keys = {
{ "aa", "CodeCompanionActions", mode = { "n", "v" }, desc = "Actions" },
{ "av", "CodeCompanionAdd", mode = { "v" }, desc = "Add Visual" },
{ "at", "CodeCompanionToggle", mode = { "n", "v" }, desc = "Toggle" },
},
config = function(_, _)
require("codecompanion").setup {
-- log_level = vim.log.levels.TRACE,
adapters = {
openai = require("codecompanion.adapters").use("openai", {
env = {
api_key = "cmd:gpg --decrypt ~/.openai-api-key.gpg 2>/dev/null",
},
url = os.getenv "OPENAI_API_BASE" .. "/chat/completions",
}),
},
actions = {
{
name = "Generate Git Message",
strategy = "inline",
description = "Generate a git commit message",
opts = { placement = "cursor" },
prompts = {
{
role = "system",
content = [[Generate a concise, past tense commit message for provided diffs without additional content.]],
-- content = [[You are an expert software engineer.
-- Review the provided context and diffs which are about to be committed to a git repo.
-- Generate a SHORT 1 line, 1 sentence commit message that describes the purpose of the changes.
-- The commit message MUST be in the past tense.
-- It must describe the changes which have been made in the diffs!
-- Reply with JUST the commit message, without quotes, comments, questions, etc!]],
},
{
role = "user",
content = [[ CONTEXT: ]] .. vim.fn.system "git diff --cached",
},
},
},
{
name = "(CN) Generate Git Message ",
strategy = "inline",
description = "Generate a git commit message",
opts = { placement = "cursor" },
prompts = {
{
role = "system",
content = [[使用中文生成提供的差异的简明过去式提交消息,不包含其他内容。]],
-- content = [[You are an expert software engineer.
-- Review the provided context and diffs which are about to be committed to a git repo.
-- Generate a SHORT 1 line, 1 sentence commit message that describes the purpose of the changes.
-- The commit message MUST be in the past tense.
-- It must describe the changes which have been made in the diffs!
-- Reply with JUST the commit message, without quotes, comments, questions, etc!]],
},
{
role = "user",
content = [[ CONTEXT: ]] .. vim.fn.system "git diff --cached",
},
},
},
},
}
end,
}
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
-- setup treesitter
local ok, treesitter = pcall(require, "nvim-treesitter.configs")
if ok then
treesitter.setup({
ensure_installed = "all",
ignore_install = { "phpdoc" }, -- list of parser which cause issues or crashes
highlight = { enable = true },
})
end
Error executing vim.schedule lua callback: ...codecompanion.nvim/lua/codecompanion/adapters/openai.lua:153: attempt to index a nil value
stack traceback:
...codecompanion.nvim/lua/codecompanion/adapters/openai.lua:153: in function 'inline_output'
...decompanion.nvim/lua/codecompanion/strategies/inline.lua:211: in function 'cb'
...vim/lazy/codecompanion.nvim/lua/codecompanion/client.lua:115: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>
==============================================================================
codecompanion: require("codecompanion.health").check()
codecompanion.nvim report ~
Error executing vim.schedule lua callback: ...codecompanion.nvim/lua/codecompanion/adapters/openai.lua:153: attempt to index a nil value
stack traceback:
...codecompanion.nvim/lua/codecompanion/adapters/openai.lua:153: in function 'inline_output'
...decompanion.nvim/lua/codecompanion/strategies/inline.lua:211: in function 'cb'
...vim/lazy/codecompanion.nvim/lua/codecompanion/client.lua:115: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>
Error executing vim.schedule lua callback: ...codecompanion.nvim/lua/codecompanion/adapters/openai.lua:153: attempt to index a nil value
stack traceback:
...codecompanion.nvim/lua/codecompanion/adapters/openai.lua:153: in function 'inline_output'
...decompanion.nvim/lua/codecompanion/strategies/inline.lua:211: in function 'cb'
...vim/lazy/codecompanion.nvim/lua/codecompanion/client.lua:115: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>
No response
minimal.lua
config file above and still get the issueminimal.lua
configlocal root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
-- Your CodeCompanion setup
local plugins = {
{
"olimorris/codecompanion.nvim",
dependencies = {
{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate"},
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim",
{
"stevearc/dressing.nvim",
opts = {},
},
},
config = function()
require("codecompanion").setup({
strategies = { -- Change the adapters as required
chat = "openai",
inline = "openai",
},
})
end,
}
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
-- setup treesitter
local ok, treesitter = pcall(require, "nvim-treesitter.configs")
if ok then
treesitter.setup({
ensure_installed = "all",
ignore_install = { "phpdoc" }, -- list of parser which cause issues or crashes
highlight = { enable = true },
})
end
Error: could not connect to ollama app, is it running?
codecompanion: require("codecompanion.health").check()
codecompanion.nvim report ~
Error: could not connect to ollama app, is it running?
I would expect, if I'm not using ollama at all, for CodeCompanion to not attempt to call io.popen 'ollama list'
on line 4 of lua/codecompanion/adapters/ollama.lua
, or at least expect and ignore the Error log message.
Instead, it draws the error text into my window, wherever the cursor is, requiring a Ctrl-L to redraw every time I open nvim.
minimal.lua
config file above and still get the issueminimal.lua
configlocal root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
-- Your CodeCompanion setup
local plugins = {
{
"olimorris/codecompanion.nvim",
dependencies = {
{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" },
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim",
{
"stevearc/dressing.nvim",
opts = {},
},
},
config = function()
local adapters = require("codecompanion.adapters")
require("codecompanion").setup({
adapters = {
anthropic = adapters.use("anthropic", {
schema = {
model = {
default = "claude-3-5-sonnet-20240620",
},
},
}),
},
strategies = {
chat = "anthropic",
inline = "anthropic",
tools = "anthropic",
},
log_level = "TRACE",
})
end,
},
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
-- setup treesitter
local ok, treesitter = pcall(require, "nvim-treesitter.configs")
if ok then
treesitter.setup({
ensure_installed = "all",
ignore_install = { "phpdoc" }, -- list of parser which cause issues or crashes
highlight = { enable = true },
})
end
No response
codecompanion: require("codecompanion.health").check()
codecompanion.nvim report
The log is empty.
When using the Anthropic adapter as in the modified minimal config, visually selecting a code block and typing :CodeCompanion
, followed by a prompt, results in no LLM response being inserted into the buffer. Instead, a string like "replace|true" gets inserted at the location of the selection. This string appears to be the value of the placement
variable in inline.lua
:
When using the OpenAI adapter, this does not happen, and the LLM response is inserted into the buffer as expected.
:CodeCompanion
minimal.lua
config file above and still get the issueminimal.lua
configlocal root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
{
"olimorris/codecompanion.nvim",
dependencies = {
{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate"},
"nvim-lua/plenary.nvim",
{
"stevearc/dressing.nvim", -- Optional: Improves the default Neovim UI
opts = {},
},
},
config = true
}
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
-- setup treesitter
local ok, treesitter = pcall(require, "nvim-treesitter.configs")
if ok then
treesitter.setup({
ensure_installed = "all",
ignore_install = { "phpdoc" }, -- list of parser which cause issues or crashes
highlight = { enable = true },
})
end
Error: Error malformed json: Expected value but found T_END at character 1
Error: Error malformed json: Expected value but found invalid token at character 1
codecompanion: require("codecompanion.health").check()
codecompanion.nvim report
- Log file: /Users/chazleong/.config/nvim/.repro/state/nvim/codecompanion.log
- OK nvim-treesitter installed
- OK plenary.nvim installed
- OK dressing.nvim installed
- WARNING edgy.nvim not found
- OK curl installed
<EMPTY>
Ollama adapter throws no error and CodeCompanion works as usual.
Ollama adapter throws error and CodeCompanion + Ollama is currently broken.
codecompanion.nvim
minimal.lua
config abovenvim --clean -u minimal.lua
:CodeCompanionChat ollama
minimal.lua
config file above and still get the issueArghhhh...it's because Anthropic want the system message outside of the prompt:
response = client.messages.create(
model="claude-2.1",
system="Respond only in Spanish.", # <-- system prompt
messages=[
{"role": "user", "content": "Hello, Claude!"} # <-- user prompt
]
)
minimal.lua
configlocal root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
-- NOTE this part here
-- these are my defaults, but I want them to be true on the chat buffer
vim.opt.wrap = false
vim.opt.linebreak = false
--
-- install plugins
local plugins = {
{
"olimorris/codecompanion.nvim",
dependencies = {
{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" },
"nvim-lua/plenary.nvim",
{
"stevearc/dressing.nvim", -- Optional: Improves the default Neovim UI
opts = {},
},
},
opts = {
adapters = {
chat = "ollama",
inline = "ollama",
},
display = {
chat = {
type = "buffer",
buf_options = {
buflisted = true,
},
win_options = {
-- I'd like these settings overridden for the chat buffer
wrap = true,
linebreak = true,
},
},
},
},
},
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
-- setup treesitter
local ok, treesitter = pcall(require, "nvim-treesitter.configs")
if ok then
treesitter.setup({
ensure_installed = "all",
ignore_install = { "phpdoc" }, -- list of parser which cause issues or crashes
highlight = { enable = true },
})
end
No response
==============================================================================
codecompanion: require("codecompanion.health").check()
codecompanion.nvim report ~
- Log file: $HOME/.local/state/nvim/codecompanion.log
- OK nvim-treesitter installed
- OK plenary.nvim installed
- OK dressing.nvim installed
- WARNING edgy.nvim not found
- OK curl installed
None
When I open the chat buffer, the window gets vim.opt.wrap = true
and vim.opt.linebreak = true
Using the provided minimal config, enter a long string in the chat buffer like
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
minimal.lua
config file above and still get the issueHey just seeing this, looks very cool! It would be cool to be able to use LocalAI, since OpenAI API is quite expensive. LocalAI has a drop-in replacement REST API, so (if things work out the way I hope) it should just be a matter of setting the base URL and all the API endpoint mappings and request/response logic should still work.
minimal.lua
configlocal root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
{
"olimorris/codecompanion.nvim",
dependencies = {
{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" },
"nvim-lua/plenary.nvim",
{
"stevearc/dressing.nvim", -- Optional: Improves the default Neovim UI
opts = {},
},
},
config = function()
require("codecompanion").setup({
adapters = {
chat = require("codecompanion.adapters").use("ollama"),
inline = require("codecompanion.adapters").use("ollama"),
},
})
end,
},
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
-- setup treesitter
local ok, treesitter = pcall(require, "nvim-treesitter.configs")
if ok then
treesitter.setup({
ensure_installed = "all",
ignore_install = { "phpdoc" }, -- list of parser which cause issues or crashes
highlight = { enable = true },
})
end
No response
==============================================================================
codecompanion: require("codecompanion.health").check()
codecompanion.nvim report ~
- Log file: /Users/mat/.local/state/nvim/codecompanion.log
- OK nvim-treesitter installed
- OK plenary.nvim installed
- OK dressing.nvim installed
- WARNING edgy.nvim not found
- OK curl installed
None
It asks me for a prompt via vim.ui.input()
It inserts the system prompt text into my buffer lol
:CodeCompanion
without any argumentsminimal.lua
config file above and still get the issueminimal.lua
configlocal root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
-- Your CodeCompanion setup
local plugins = {
{
"olimorris/codecompanion.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-treesitter/nvim-treesitter",
"nvim-telescope/telescope.nvim", -- Optional
{
"grapp-dev/nui-components.nvim",
dependencies = {
"MunifTanjim/nui.nvim",
},
},
{
"stevearc/dressing.nvim", -- Optional: Improves the default Neovim UI
opts = {},
},
{
"folke/edgy.nvim",
event = "VeryLazy",
init = function()
vim.opt.laststatus = 3
vim.opt.splitkeep = "screen"
end,
opts = {
animate = {
enabled = false,
},
right = {
{ ft = "codecompanion", title = "Code Companion Chat", size = { width = 0.45 } },
},
},
},
},
config = function()
vim.cmd([[cab cc CodeCompanion]])
vim.cmd([[cab ccb CodeCompanionWithBuffers]])
require("codecompanion").setup({
adapters = {
openai = require("codecompanion.adapters").use("openai", {
env = {
api_key = "cmd:gpg --decrypt ~/.openai-api-key.gpg 2>/dev/null",
},
url = os.getenv("OPENAI_API_BASE") .. "/chat/completions",
schema = {
model = {
default = "gpt-4o",
choices = {
"gpt-4o",
"gpt-4-turbo-preview",
"gpt-4",
"gpt-3.5-turbo",
},
},
},
}),
anthropic = require("codecompanion.adapters").use("anthropic", {
env = {
api_key = "cmd:gpg --decrypt ~/.openai-api-key.gpg 2>/dev/null",
},
url = os.getenv("OPENAI_API_BASE") .. "/messages",
schema = {
model = {
default = "claude-3-5-sonnet",
},
},
}),
},
strategies = { -- Change the adapters as required
chat = {
adapter = "openai",
},
inline = {
adapter = "openai",
},
tool = {
adapter = "openai",
},
agent = {
adapter = "openai",
agents = {
opts = {
auto_submit_errors = false,
auto_submit_success = true,
},
},
},
},
opts = {
log_level = "TRACE",
},
})
end,
},
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
-- setup treesitter
local ok, treesitter = pcall(require, "nvim-treesitter.configs")
if ok then
treesitter.setup({
ensure_installed = "all",
ignore_install = { "phpdoc" }, -- list of parser which cause issues or crashes
highlight = { enable = true },
})
end
==============================================================================
codecompanion: require("codecompanion.health").check()
codecompanion.nvim report ~
[TRACE] 2024-07-15 04:13:21
Opening selector
[TRACE] 2024-07-15 04:13:23
Opening selector
[TRACE] 2024-07-15 04:13:24
Context: {
active_buffers = { {
filetype = "lua",
id = 2,
name = "init.lua",
path = "/Users/lijie/dotfiles/.config/nvim/init.lua"
} },
bufnr = 2,
buftype = "",
cursor_pos = { 17, 19 },
end_col = 19,
end_line = 17,
filename = "/Users/lijie/dotfiles/.config/nvim/init.lua",
filetype = "lua",
is_normal = true,
is_visual = false,
lines = {},
mode = "n",
start_col = 19,
start_line = 17,
winnr = 1000
}
[TRACE] 2024-07-15 04:13:24
Strategy: Chat
[ERROR] 2024-07-15 04:13:25
Could not parse the settings in the chat buffer
Actions -> Prompts -> GenerateCommitGitMessage
minimal.lua
config file above and still get the issueminimal.lua
configrequire("codecompanion").setup({
adapters = {
llama3 = require("codecompanion.adapters").use("ollama", {
schema = {
model = {
default = "llama3",
},
num_ctx = {
default = 16384
},
num_predict = {
default = -1
},
},
}),
codegemma = require("codecompanion.adapters").use("ollama", {
schema = {
model = {
default = "codegemma"
},
},
}),
},
strategies = {
chat = {
adapter = "llama3",
},
inline = {
adapter = "codegemma",
},
agent = {
adapter = "llama3",
},
},
})
==============================================================================
codecompanion: require("codecompanion.health").check()
codecompanion.nvim report ~
- Log file: /Users/jacobpyke/.local/state/nvim/codecompanion.log
- OK plenary.nvim installed
- OK nvim-treesitter installed
- OK telescope.nvim installed
- OK dressing.nvim installed
- OK curl installed
- OK base64 installed
n/a
I noticed the get_ollama_choices()
ollama
you can just stipulate llama3
and it will resolve to llama3:latest
. Happy to fix it but ran out of time this morning to get it done, so I am leaving this bug report as a slight reminder. I should be able to have it fixed by this afternoon.
No response
minimal.lua
config file above and still get the issueWhilst I'm adopting a fairly rigid approach to maintaining this plugin (as per the README), I will aim to notify users of any breaking changes (and possibly other critical info) via this issue. Users are strongly encouraged to subscribe to this issue to get notified of such changes.
Every breaking change is added as a new comment.
minimal.lua
configlocal root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
-- Your CodeCompanion setup
local plugins = {
{
"olimorris/codecompanion.nvim",
dependencies = {
{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate"},
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim",
{
"stevearc/dressing.nvim",
opts = {},
},
},
config = function()
require("codecompanion").setup({
strategies = { -- Change the adapters as required
chat = "openai",
inline = "openai",
},
})
end,
}
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
-- setup treesitter
local ok, treesitter = pcall(require, "nvim-treesitter.configs")
if ok then
treesitter.setup({
ensure_installed = "all",
ignore_install = { "phpdoc" }, -- list of parser which cause issues or crashes
highlight = { enable = true },
})
end
Error detected while processing User Autocommands for "CodeCompanionRequest":
Error executing lua callback: /usr/share/nvim/runtime/lua/vim/treesitter.lua:124: str: expected string, got nil
stack traceback:
[C]: in function 'error'
vim/shared.lua: in function 'validate'
/usr/share/nvim/runtime/lua/vim/treesitter.lua:124: in function 'get_string_parser'
...codecompanion.nvim/lua/codecompanion/strategies/chat.lua:246: in function 'run_tools'
...codecompanion.nvim/lua/codecompanion/strategies/chat.lua:599: in function '_user_on_exit'
...andelwow/.repro/plugins/plenary.nvim/lua/plenary/job.lua:241: in function '_shutdown'
...andelwow/.repro/plugins/plenary.nvim/lua/plenary/job.lua:221: in function 'shutdown'
.../plugins/codecompanion.nvim/lua/codecompanion/client.lua:31: in function <.../plugins/codecompanion.nvim/lua/codecompanion/client.lua:28>
[C]: in function 'nvim_exec_autocmds'
...codecompanion.nvim/lua/codecompanion/strategies/chat.lua:609: in function 'cb'
.../plugins/codecompanion.nvim/lua/codecompanion/client.lua:115: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>
codecompanion: require("codecompanion.health").check()
codecompanion.nvim report ~
- Log file: /home/bernie/.local/state/nvim/codecompanion.log
- OK plenary.nvim installed
- OK nvim-treesitter installed
- OK telescope.nvim installed
- OK dressing.nvim installed
- WARNING edgy.nvim not found
- OK curl installed
- OK base64 installed
[DEBUG] 2024-05-25 18:15:52
Stream Request: { "-sSL", "-D", "/run/user/1000/plenary_curl_b9c14a5b.headers", "--compressed", "-X", "POST", "-H", "Authorization: Bearer REMOVED", "-H", "Content-Type: application/json", "--data-raw", '{"top_p":1,"temperature":1,"presence_penalty":0,"frequency_penalty":0,"messages":[{"role":"user"}],"model":"gpt-4o","stream":true}', "--no-buffer", "--silent", "https://api.openai.com/v1/chat/completions" }
[DEBUG] 2024-05-25 18:15:52
Couldn't parse JSON: {
[DEBUG] 2024-05-25 18:15:52
Couldn't parse JSON: "error": {
[DEBUG] 2024-05-25 18:15:52
Couldn't parse JSON: "message": "The model `gpt-4o` does not exist or you do not have access to it.",
[DEBUG] 2024-05-25 18:15:52
Couldn't parse JSON: "type": "invalid_request_error",
[DEBUG] 2024-05-25 18:15:52
Couldn't parse JSON: "param": null,
[DEBUG] 2024-05-25 18:15:52
Couldn't parse JSON: "code": "model_not_found"
[DEBUG] 2024-05-25 18:15:52
Couldn't parse JSON: }
[DEBUG] 2024-05-25 18:15:52
Couldn't parse JSON: }
Calling :CodeCompanionChat
followed by :w
results in the above error.
Tested with nvim built from git head:
NVIM v0.11.0-dev-96+g7994fdba6
Build type: Release
LuaJIT 2.1.1713484068
Also tested with Arch system package:
NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1713773202
/usr/bin/nvim --clean -u minimal.lua
:CodeCompanionChat
:w
minimal.lua
config file above and still get the issueminimal.lua
configlocal root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
-- Your CodeCompanion setup
local plugins = {
{
"olimorris/codecompanion.nvim",
dependencies = {
{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" },
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim",
{
"stevearc/dressing.nvim",
opts = {},
},
},
config = function()
require("codecompanion").setup({
strategies = { -- Change the adapters as required
chat = "openai",
inline = "openai",
},
})
end,
},
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
-- setup treesitter
local ok, treesitter = pcall(require, "nvim-treesitter.configs")
if ok then
treesitter.setup({
ensure_installed = "all",
ignore_install = { "phpdoc" }, -- list of parser which cause issues or crashes
highlight = { enable = true },
})
end
Error: Error malformed json: Expected value but found T_END at character 1
Error: Error malformed json: Expected value but found invalid token at character 1
Press ENTER or type command to continue
Error: Error malformed json: Expected the end but found T_COLON at character 12
Press ENTER or type command to continue
Error: Error malformed json: Expected the end but found T_COLON at character 9
Press ENTER or type command to continue
Error: Error malformed json: Expected the end but found T_COLON at character 10
Press ENTER or type command to continue
Error: Error malformed json: Expected the end but found T_COLON at character 9
Press ENTER or type command to continue
Error: Error malformed json: Expected value but found T_END at character 1
Press ENTER or type command to continue
Error: Error malformed json: Expected value but found T_END at character 1
codecompanion: require("codecompanion.health").check()
codecompanion.nvim report
- Log file: /Users/adam/.repro/state/nvim/codecompanion.log
- OK nvim-treesitter installed
- OK plenary.nvim installed
- OK dressing.nvim installed
- WARNING edgy.nvim not found
- OK curl installed
Log file is empty.
When I use the :CodeCompanionChat
, after typing a prompt and saving the buffer, to get back a prompt.
I get the malformed JSON error when I save the buffer with a prompt.
When I look at the plugin code in ~/.repro/plugins/codecompanion.nvim
, I'm on this commit 1d081640d4854d619a5746532ffd6073b40bf35e
, made on Sat Apr 6 16:30:47.
I have checked that I have the env var for Open AI with:
:lua print(vim.fn.getenv("OPENAI_API_KEY"))
:CodeCompanionChat
,Hello
),Malformed JSON
error.minimal.lua
config file above and still get the issueminimal.lua
configThe default minimal config provided above.
Error executing vim.schedule lua callback: ...decompanion.nvim/lua/codecompanion/strategies/inl
ine.lua:205: attempt to call method 'set_params' (a nil value)
stack traceback:
...decompanion.nvim/lua/codecompanion/strategies/inline.lua:205: in function 'get_inlin
e_output'
...decompanion.nvim/lua/codecompanion/strategies/inline.lua:338: in function 'cb'
.../sqve/.repro/plugins/dressing.nvim/lua/dressing/util.lua:206: in function <.../sqve/
.repro/plugins/dressing.nvim/lua/dressing/util.lua:202>
codecompanion.nvim report ~
- Log file: /home/sqve/.repro/state/nvim/codecompanion.log
- OK plenary.nvim installed
- OK nvim-treesitter installed
- OK telescope.nvim installed
- OK dressing.nvim installed
- WARNING edgy.nvim not found
- OK curl installed
- OK base64 installed
File is empty
The plugin should generate a unit test for me
An error was produced.
test
.test
and run CodeCompanion
.Translate this to a random language
in the prompt.minimal.lua
config file above and still get the issueminimal.lua
configlocal root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
-- Your CodeCompanion setup
local plugins = {
{
"olimorris/codecompanion.nvim",
dependencies = {
{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" },
"nvim-lua/plenary.nvim",
-- "nvim-telescope/telescope.nvim",
-- {
-- "stevearc/dressing.nvim",
-- opts = {},
-- },
},
config = function()
require("codecompanion").setup({
strategies = { -- Change the adapters as required
chat = "openai",
inline = "openai",
},
})
end,
},
{
"ibhagwan/fzf-lua",
branch = "main",
init = function()
--require("fzf-lua").register_ui_select()
end,
},
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
-- setup treesitter
local ok, treesitter = pcall(require, "nvim-treesitter.configs")
if ok then
treesitter.setup({
ensure_installed = "all",
ignore_install = { "phpdoc" }, -- list of parser which cause issues or crashes
highlight = { enable = true },
})
end
No response
no need
no logs
The problematic command is :CodeCompanionActions in visual mode or simply :'<,'>CodeCompanionActions.
So, if you don't use any ui lib (dressing) it works perfectly.
But if you use something else, such as the default nvim one, the fzf-lua one and the noice one, it will not work.
Cannot input any selection
minimal.lua
config file above and still get the issueA declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.