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

Duplicate snippets with Luasnip preset #1081

Closed
2 tasks done
dpetka2001 opened this issue Jan 25, 2025 · 4 comments
Closed
2 tasks done

Duplicate snippets with Luasnip preset #1081

dpetka2001 opened this issue Jan 25, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@dpetka2001
Copy link

dpetka2001 commented Jan 25, 2025

Make sure you have done the following

  • Updated to the latest version of blink.cmp
  • Searched for existing issues and documentation (try <C-k> on https://cmp.saghen.dev)

Bug Description

After commit c4eafc1, when you have Luasnip enabled in your personal configuration and you also set snippets.preset = "luasnip", you get duplicate snippets. Reverting to the previous commit does correctly show snippets only one time.

After c4eafc1 screenshot

Image

Before c4eafc1 screenshot

Image

Somehow the prefetch on insert gets duplicate items for Luasnip snippets.

Relevant configuration

snippets = {
  preset = "luasnip",
},

neovim version

NVIM v0.11.0-dev-1633+g851137f679

blink.cmp version

main

@dpetka2001 dpetka2001 added the bug Something isn't working label Jan 25, 2025
@albnavarro
Copy link

I have a similar case, but I noticed that the duplication occurs only when using the new syntax preset = "luasnip":

return {
    "saghen/blink.cmp",
    lazy = false, 
    dependencies = {
        "L3MON4D3/LuaSnip",
        version = "v2.*",
        dependencies = { "rafamadriz/friendly-snippets" },
        config = function()
            --- I had to add this option compared to the old syntax
            require("luasnip.loaders.from_vscode").lazy_load()
        end,
    },
    version = "v0.11.0",
    opts = {
        snippets = {
            preset = "luasnip",
        },

       .....

With the previous syntax this does not happen.

return {
    "saghen/blink.cmp",
    lazy = false, 
    dependencies = {
        "L3MON4D3/LuaSnip",
        version = "v2.*", 
        dependencies = { "rafamadriz/friendly-snippets" },
    },
    version = "v0.11.0",
    opts = {
        snippets = {
            expand = function(snippet)
                require("luasnip").lsp_expand(snippet)
            end,
            active = function(filter)
                if filter and filter.direction then
                    return require("luasnip").jumpable(filter.direction)
                end
                return require("luasnip").in_snippet()
            end,
            jump = function(direction)
                require("luasnip").jump(direction)
            end,
        },
        ...

@ruslanSorokin
Copy link
Contributor

ruslanSorokin commented Jan 26, 2025

Seems to be introduced in 712af9f

@Saghen Saghen closed this as completed in f0f34c3 Jan 26, 2025
@Saghen
Copy link
Owner

Saghen commented Jan 26, 2025

Thanks @ruslanSorokin

@Saghen Saghen marked this as a duplicate of #1094 Jan 27, 2025
@Saghen Saghen marked this as a duplicate of #1160 Feb 6, 2025
@Saghen Saghen marked this as a duplicate of #1192 Feb 10, 2025
@helins
Copy link
Contributor

helins commented Mar 2, 2025

I have not yet identified under what conditions but there seems to be edge cases where duplicates are still produced.

It happened to me twice today that at some point, duplicates would start showing up until I restart Nvim.

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

5 participants