quangnguyen30192 / cmp-nvim-ultisnips

nvim-cmp source for ultisnips
Apache License 2.0
145 stars 19 forks source link

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

Open medwatt opened 2 years ago

medwatt commented 2 years ago

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

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.

https://user-images.githubusercontent.com/17733465/166337915-512557db-ed2b-46e5-91f6-f6858e35aba1.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"}),

    },

})