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

Select prev/next immediately closes menu for some snippets #9

Closed
mikehaertl opened this issue Nov 9, 2023 · 1 comment
Closed

Select prev/next immediately closes menu for some snippets #9

mikehaertl opened this issue Nov 9, 2023 · 1 comment

Comments

@mikehaertl
Copy link

Some snippets cause the menu to immediately close, when selected with prev/next in the menu. They also insert a messed up version of the snippet.

Here is an example snippet:

{
  "msg": {
    "prefix": ["msg"],
    "body": [
      "[$1] $2"
    ]
  }
}

If I type ms the menu opens:
image

If I now just select the first item (i.e. <c-j> without confirming!), the menu closes immediately and inserts the first part of the template:

image

This happens since commit 18ff44c (Improve Symbol handling).

It does not happen for all snippets. I could not find out what exactly makes some snippets cause this problems, while others still work fine.

My nvim-cmp config:

  cmp.setup({
    snippet = {
      expand = function(args)
        vim.fn['vsnip#anonymous'](args.body)
      end,
    },
    mapping = {
      ['<C-j>'] = cmp.mapping(cmp.mapping.select_next_item(), {'i', 'c'}),
      ['<C-k>'] = cmp.mapping(cmp.mapping.select_prev_item(), {'i', 'c'}),
      ['<CR>'] = function(fallback)
        if cmp.visible() and
          cmp.get_selected_entry() and
          not (cmp.get_selected_entry().source.name == 'nvim_lsp_signature_help') then
          cmp.confirm({
            select = false,
          })
        else
          fallback()
        end
      end
    },
    sources = cmp.config.sources({
      { name = 'vsnip' },
    }),
  })
@mikehaertl
Copy link
Author

The issue goes away if I disable the https://github.com/andymass/vim-matchup plugin. So it must probably get fixed there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant