Replies: 3 comments 2 replies
-
I have encountered the same error message. Here are my options that are folding related local o = vim.o
o.foldenable = false
o.foldexpr = "nvim_treesitter#foldexpr()"
o.foldlevel = 99
o.foldlevelstart = 99
o.foldmethod = "expr" And here is my codecompanion configuration that solves the error by setting fold method to manual while codecompanion does it's thing. ---@module "lazy"
---@type LazySpec
return {
"olimorris/codecompanion.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-treesitter/nvim-treesitter",
},
cmd = {
"CodeCompanion",
"CodeCompanionActions",
"CodeCompanionChat",
"CodeCompanionCmd",
},
keys = {
{ "<leader>ci", "<cmd>CodeCompanion<cr>", desc = "CodeCompanion Inline Assistant" },
{ "<leader>cc", "<cmd>CodeCompanionChat Toggle<cr>", desc = "CodeCompanion Chat Buffer" },
{ "<leader>cx", "<cmd>CodeCompanionCmd<cr>", desc = "CodeCompanion CMD Generator" },
{ "<leader>cX", "<cmd>CodeCompanionActions<cr>", desc = "CodeCompanion Actions Palette" },
},
opts = {
adapters = {
openai = function()
return require("codecompanion.adapters").extend("openai", {
env = { api_key = vim.env.OPENAI_API_KEY },
parameters = {
model = "gpt-4.1-mini",
temperature = 0.1,
stream = true,
max_tokens = 8192,
top_p = 1,
presence_penalty = 0,
frequency_penalty = 0,
},
})
end,
},
strategies = {
chat = { adapter = "openai" },
inline = { adapter = "openai" },
cmd = { adapter = "openai" },
},
},
config = function(_, opts)
require("codecompanion").setup(opts)
local tools = require("codecompanion.strategies.chat.ui.tools")
local original = tools.create_fold
tools.create_fold = function(bufnr, start_line)
local win = vim.api.nvim_get_current_win()
vim.api.nvim_win_call(win, function()
local old = vim.wo[win].foldmethod
vim.wo[win].foldmethod = "manual"
pcall(original, bufnr, start_line)
vim.defer_fn(function()
if vim.api.nvim_win_is_valid(win) then
vim.wo[win].foldmethod = old
end
end, 50)
end)
end
end,
} I hope that this helps to get this fixed. |
Beta Was this translation helpful? Give feedback.
0 replies
-
What is the error? The videos weren't clear to me |
Beta Was this translation helpful? Give feedback.
1 reply
-
I have created PR #1795 that hopefully fixes this error without having to add the stuff that I have in my configuration. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Wasn't sure the right place to post this, but I believe I may have found a bug with the new folding logic. If the chat buffer is hidden when the patch is accepted, then the fold will fail and break the chat buffer completely.
Here's an example of the error (this is the automatic flow where the chat view gets closed on smaller windows to show the diff, i just have a recording starting right before the AI creates the diff):
bad.mp4
And here's the same scenario but I open the chat buffer before accepting the change:
good.mp4
Beta Was this translation helpful? Give feedback.
All reactions