Skip to content

Insert mode not activated when snippet has default value in the placeholder of the insert node #401

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

Closed
2 tasks done
NicolasGB opened this issue Nov 28, 2024 · 1 comment
Closed
2 tasks done
Labels
bug Something isn't working snippets Built-in provider and library for snippets

Comments

@NicolasGB
Copy link

NicolasGB commented Nov 28, 2024

Make sure you have done the following

  • I have updated to the latest version of blink.cmp
  • I have read the README

Bug Description

When using snippets, in my case it's luasnip If an insert node has a placeholder value, i find myself in normal mode instead of insert mode.

Before the snippets refactor (at least from what i see in main, in the config) I found myself successfully in insert mode even if the snippets had a placeholder. (Up to this afternoon when I updated main and rewrite my config)

Here's a video of me having to go in insert mode:

insert.mode.mp4

Then if i remove the placeholder value from the same snippet:

insert.mode.2.mp4

Is this related to blink? Should i report it to blink_luasnip instead?

I'm also finding issues with expansion if the prefix is not a fullmatch but i've already open an issue

Relevant configuration

-- Snippets
        snippets = {
          expand = function(snippet)
            ls.lsp_expand(snippet)
          end,
          active = function(filter)
            if filter and filter.direction then
              return ls.jumpable(filter.direction)
            end
            return ls.in_snippet()
          end,
          jump = function(direction)
            ls.jump(direction)
          end,
        },
        sources = {
          -- add lazydev to sources
          completion = {
            enabled_providers = { "lsp", "path", "luasnip", "buffer", "lazydev" },
          },
          providers = {
            -- dont show LuaLS require statements when lazydev has items
            lsp = { fallback_for = { "lazydev" } },
            lazydev = { name = "LazyDev", module = "lazydev.integrations.blink" },
            -- Luasnip
            luasnip = {
              name = "luasnip",
              module = "blink_luasnip",

              score_offset = -1,

              opts = {
                use_show_condition = false,
                show_autosnippets = true,
              },
            },
          },
        }

neovim version

v0.11.0-dev-1247+g5897994cb7

blink.cmp version: branch, tag, or commit

main: 59add2d

@NicolasGB NicolasGB added the bug Something isn't working label Nov 28, 2024
@Saghen Saghen added the snippets Built-in provider and library for snippets label Nov 29, 2024
@NicolasGB
Copy link
Author

To add a bit more context, there might be an issue with the way expansion is handled.

After an exchange with @leiserfg I quote his response that may help you find the issue:

What I see happening, is that the trigger is being written to the buffer before calling execute, as if it were a regular text completion. And that messes up the logic to tell luasnip what region of the text to remove before expanding.

I know this is not exactly related to the placeholder part, let me know if you want me to open a different issue.

@Saghen Saghen closed this as completed in 08b59ed Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working snippets Built-in provider and library for snippets
Projects
None yet
Development

No branches or pull requests

2 participants