Open matthewblott opened 1 month ago
Hi, please provide a minimal config that only contains relevant info for avante.nvim.
Dumping your whole config won't help here.
Okay. I've tried a fresh install with a bare bones configuration and lazy.nvim
installed at ${HOME}/.local/share/nvim/lazy.nvim
. The result is the same. Here is the init.lua
config in full:
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
vim.fn.system {
'git',
'clone',
'--filter=blob:none',
'https://github.com/folke/lazy.nvim.git',
'--branch=stable', -- latest stable release
lazypath,
}
end
vim.opt.rtp:prepend(lazypath)
require('lazy').setup({
{
'yetone/avante.nvim',
event = 'VeryLazy',
lazy = false,
version = false,
opts = {
provider = "openai",
},
build = 'make BUILD_FROM_SOURCE=true',
dependencies = {
'stevearc/dressing.nvim',
'nvim-lua/plenary.nvim',
'MunifTanjim/nui.nvim',
{
'MeanderingProgrammer/render-markdown.nvim',
opts = {
file_types = { 'markdown', 'Avante' },
},
ft = { 'markdown', 'Avante' },
},
},
},
})
vim.wo.number = true
vim.wo.relativenumber = true
vim.opt.expandtab = true
vim.opt.clipboard = 'unnamedplus'
vim.g.mapleader = ' '
I tried to keep everything to a minimum. I also tried the config as suggested on the homepage of this site.
It looks like the following line in your config.lua
might be causing the issue:
keymap('n', 'a', '$A', opts)
This remaps the a
key to move the cursor to the end of the line ($
) and enter insert mode (A
). As a result, this likely overrides the default behavior of the a
key, including within the sidebar.
To resolve this, try removing or modifying that key mapping.
@ddillert Nah, it's nothing to do with that although that's what I thought at first. If you look at my last reply I've given you the full init.lua
file. I removed virtually everything.
@matthewblott Could you please share the exact text output you're receiving from the model by posting it here?
Below is the full response to the following chat request:
Create a request test for the index method of the about controller.
If I select the top line of each code snippet then the apply this
option becomes available:
However I am not able to perform any action either by click on apply this
or trying the keyboard shortcut.
@matthewblott, thanks for the screenshots! I tested your example and ran into the same issue.
Could you please try using :AvanteAsk
or <Leader>aa
with the same request to see if the issue persists?
Currently, for the apply feature to work, we expect a spec'ed string with line numbers to appear before the code snippets. These line numbers guide where to insert the snippets in the open file, but in this case, both the line numbers and spec'ed strings are not present.
@aarnphm, it looks like lua/avante/templates/planning.avanterules
only implements this for the :AvanteAsk feature.
Should we consider modifying the templates to include line numbers for :AvanteChat
, disabling the apply feature when line numbers are missing, or improving pattern matching by appending everything to the end of the file in the absence of line numbers? One possible approach could be:
If no line numbers are present, detect the keywords Add
, code
, and the filename that matches the currently open file, then use the last line number from the open file's buffer to insert the snippet.
I tried AvanteAsk
and this was the result:
I then ran :set modifiable
to see if that made a difference. The result was the same as it was when I ran AvanteChat
.
Since avante started supporting avanterules (using jinja2 to render prompts), there has been a serious bug: due to an error in the template of the prompts, jinja2 incorrectly filtered out key information from the prompts, resulting in incorrect final generated prompts. This has caused issues with returned content not conforming to specifications recently. I fixed this serious bug yesterday: https://github.com/yetone/avante.nvim/pull/603. I suspect your issue might also be related to this bug. Could you update avante to the latest version and try again?
Having this exact same issue. I'm on latest version of avante
@flopex Can you take a screenshot to show what your LLM response is?
I think I just figured out why, you first have to select one of response's code snippets before it can "<A: apply all".
Only getting the error if I try to <A from any of the response's text.
Since after submitting a request and cursor lands on the response pane, you kind of assume <A would be valid.
@flopex This was my experience too.
I have the same problem with minimal configuration from readme. After pressing "a" does not happen
return {
"yetone/avante.nvim",
event = "VeryLazy",
lazy = false,
version = false, -- set this if you want to always pull the latest change
opts = {
provider = "openai",
auto_suggestions_provider = "openai",
behaviour = {
auto_suggestions = true, -- Experimental stage
auto_set_highlight_group = true,
auto_set_keymaps = true,
auto_apply_diff_after_generation = false,
support_paste_from_clipboard = false,
},
hints = { enabled = true },
highlights = {
---@type AvanteConflictHighlights
diff = {
current = "DiffText",
incoming = "DiffAdd",
},
},
--- @class AvanteConflictUserConfig
diff = {
autojump = true,
---@type string | fun(): any
list_opener = "copen",
},
mappings = {
--- @class AvanteConflictMappings
diff = {
ours = "co",
theirs = "ct",
all_theirs = "ca",
both = "cb",
cursor = "cc",
next = "]x",
prev = "[x",
},
suggestion = {
accept = "<M-l>",
next = "<M-]>",
prev = "<M-[>",
dismiss = "<C-]>",
},
jump = {
next = "§]",
prev = "§[",
},
submit = {
normal = "<CR>",
insert = "<C-s>",
},
sidebar = {
switch_windows = "<Tab>",
reverse_switch_windows = "<S-Tab>",
},
},
},
keys = {
{ "§-", ":AvanteAsk<cr>", desc = "Avante" },
},
-- if you want to build from source then do `make BUILD_FROM_SOURCE=true`
build = "make",
-- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows
dependencies = {
"nvim-treesitter/nvim-treesitter",
"stevearc/dressing.nvim",
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
--- The below dependencies are optional,
"nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons
"zbirenbaum/copilot.lua", -- for providers='copilot'
{
-- support for image pasting
"HakonHarnes/img-clip.nvim",
event = "VeryLazy",
opts = {
-- recommended settings
default = {
embed_image_as_base64 = false,
prompt_for_file_name = false,
drag_and_drop = {
insert_mode = true,
},
-- required for Windows users
use_absolute_path = true,
},
},
},
{
-- Make sure to set this up properly if you have lazy=true
'MeanderingProgrammer/render-markdown.nvim',
opts = {
file_types = { "markdown", "Avante" },
},
ft = { "markdown", "Avante" },
},
},
}
I am having the same issue
Same
I am having the same issue, any solutions available yet?
This is the way how I reproduced the error:
qwen2.5-coder:7b-instruct-q8_0
with ollama and foo.rb
in the first issue message.produce minus function
several times in AvanteAsk until apply doesnt workApply works ->
Apply doesn't work ->
When I debugged this issue, there was empty filepath
in selected_snippets_map
of sidebar.lua
https://github.com/yetone/avante.nvim/blob/main/lua/avante/sidebar.lua#L550-L557
I think emtpy (or wrong) filepath
is the cause of this issue.
filepath
is set by the relative position of start_line_in_response_buf
( https://github.com/yetone/avante.nvim/blob/main/lua/avante/sidebar.lua#L365 ) and the error occurs when the LLM doesn't follow the prompts (like placing the file path in wrong position of response)
I am having the same issue, any solutions available yet?
applying changes work when I use avante ask
not avante chat
Describe the bug
I have a file
foo.rb
which contains the following code:I asked Avante chat to produce a
minus
function which it does and also presents me with a button to apply the changes that looks like the following:[: apply this, : apply all]
However if I try and press the button nothing happens and nothing happens if I press the 'a' key or shift + 'a'.
To reproduce
My config is pretty simple, just two files:
The
plugins.lua
file:The
config.lua
file:Expected behavior
Expected the changes to be applied and the
foo.rb
to look like the following:Environment
NVIM v0.10.1 Build type: Release LuaJIT 2.1.1720049189 OS: macOS 14.5
Repro