Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Failure to ensure no snippet overlap #978

Open
ZacJMagee opened this issue Dec 21, 2024 · 4 comments
Open

bug: Failure to ensure no snippet overlap #978

ZacJMagee opened this issue Dec 21, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@ZacJMagee
Copy link

ZacJMagee commented Dec 21, 2024

Describe the bug

When trying to use a or A to apply the code from the plugin I keep getting this error.

 Error 12:33:02 AM notify.error Avante Failed to ensure snippets no overlap

I am just running the default configuration.

EDIT

I have also tried removing all my snippets engines and the same error appears.
Luasnip
Friendly snippets.

This is my first report, please correct me if I have missed anything.

To reproduce

{
"yetone/avante.nvim",
event = "VeryLazy",
lazy = false,
version = false, -- set this if you want to always pull the latest change
opts = {
-- add any opts here
},
-- 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 = {
"stevearc/dressing.nvim",
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
--- The below dependencies are optional,
-- "hrsh7th/nvim-cmp", -- autocompletion for avante commands and mentions
"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" },
},
},
}

Expected behavior

The default keybind should apply the code to the buffer.

Installation method

Use lazy.nvim:

{
  "yetone/avante.nvim",
  event = "VeryLazy",
  lazy = false,
  version = false, -- set this if you want to always pull the latest change
  opts = {
    -- add any opts here
  },
  -- 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",
  },
}

Environment

at 19:36:37 ➜ nvim -v
NVIM v0.10.2
Build type: Release
LuaJIT 2.1.1713773202
Run "nvim -V1 -v" for more info

Repro

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
  spec = {
    -- add any other plugins here
  },
})
@ZacJMagee ZacJMagee added the bug Something isn't working label Dec 21, 2024
@brewinski
Copy link
Contributor

brewinski commented Dec 21, 2024

Hey @ZacJMagee would you be able to share the LLM output too? It would be helpful to see to diagnose the issue. It would also be helpful to see the source files if that's possible.

@ZacJMagee
Copy link
Author

Hey @brewinski

Here is my input and the LLM output.

I was just trying to have it write me a .gitingore when I found this issue.
Then I created a blank py file to try again and I had the same issue.

I have since been able to get it to work but I am not sure how.

It seems that the output itself was the issue. In the screenshot you can see that the output that was giving me the error was not formatted or displayed correctly.

Output that was giving me the error.
image

Output that worked.
image

Output from the LLM that gave me the error.

can you please write me a git ignore for python, I also have a google token that needs to be ingored

I'll create a comprehensive .gitignore file for Python projects that includes Google token files. I'll create a new file:

Filepath: .gitignore
Replace lines: 0-0

# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# Virtual Environment
venv/
env/
ENV/
.env
.venv
pip-log.txt
pip-delete-this-directory.txt

# IDE specific files
.idea/
.vscode/
*.swp
*.swo
.DS_Store

# Google API tokens and credentials
google_token.json
token.json
credentials.json
client_secrets.json
*.credentials
*_token.*

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

This .gitignore file includes:

  1. Common Python-specific files and directories
  2. Virtual environment directories
  3. IDE-specific files
  4. Various Google token/credential file patterns
  5. Distribution and packaging files
  6. Test and coverage reports

If your Google token file has a different name pattern, let me know and I can add it to the list.

@brewinski
Copy link
Contributor

brewinski commented Dec 22, 2024

Thanks @ZacJMagee that's very helpful. I think I was able to find and fix the rendering issue and the apply issue.

The rendering problem was a file type / language detection issue for files that weren't part of the sidebar context. The issue applying the changes to new files was a result of trying to make sure the llm hadn't suggested changes to overlapping line numbers.

I've raised the PR that should hopefully solve this issue. #991. If you get a change to test the change-set, let me know if it resolves your issue.

@ZacJMagee
Copy link
Author

Thanks @ZacJMagee that's very helpful. I think I was able to find and fix the rendering issue and the apply issue.

The rendering problem was a file type / language detection issue for files that weren't part of the sidebar context. The issue applying the changes to new files was a result of trying to make sure the llm hadn't suggested changes to overlapping line numbers.

I've raised the PR that should hopefully solve this issue. #991. If you get a change to test the change-set, let me know if it resolves your issue.

Glad I could help, I have not been able to replicate the bug since!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants