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

Possible bug when triggering snippet before the completion menu has opened for the first time #77

Open
medwatt opened this issue May 2, 2022 · 0 comments

Comments

@medwatt
Copy link

medwatt commented May 2, 2022

I noticed a weird behavior recently when I changed the keyword length from 1 to 4. First let me give the steps to reproduce:

  • Set ultisnips keyword length from 1 to some high number that doesn't cause the completion menu to open.
  • Open a file that has snippets defined.
  • Trigger a snippet as defined by vim.g.ultisnipsexpandtrigger.
  • Try to jump to the next tabstop with tab. The tab key doesn't do anything.
  • Now, go into insert mode and try to jump to the next tabstop. Instead, the function call gets printed.

Here's a video showing the "bug". In the first part, I show that everything works fine when the snippet is triggered after the completion menu has opened. In the second part, I set the keyword length to 4, trigger the plugin, and then try to jump to the next tabstop. It doesn't work.

ultisnips.mp4

Here's a minimal setup.

cmp.setup({

    completion = {
        -- completeopt = "menu,menuone,preview,noinsert",
        completeopt = "menuone,noselect",
    },

    snippet = {
        expand = function(args)
            vim.fn["UltiSnips#Anon"](args.body)
        end,
    },

    sources = {
        { name = "nvim_lsp" },
        { name = "ultisnips", keyword_length = 4},
        { name = "buffer", keyword_length = 4},
        { name = "nvim_lua" },
        { name = "path" },
        -- more sources
    },

    mapping = {

        ["<Up>"] = cmp.mapping.select_prev_item(),
        ["<Down>"] = cmp.mapping.select_next_item(),
        ['<C-Space>'] = cmp.mapping.complete(),

        ["<CR>"] = cmp.mapping.confirm({
            behavior = cmp.ConfirmBehavior.Replace,
            select = false,
        }),

        ["<C-e>"] = cmp.mapping.close(),

        ["<Tab>"] = cmp.mapping(
        function(fallback)
            cmp_ultisnips_mappings.compose {"jump_forwards", "select_next_item"}(fallback)
        end, {"i", "s"}),

        ["<S-Tab>"] = cmp.mapping(
        function(fallback)
            cmp_ultisnips_mappings.compose {"jump_backwards", "select_prev_item"}(fallback)
        end, {"i", "s"}),

    },

})
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