How to expands snippets using nvim-compe and vim-vsnip?


I’m trying to get LSP snippets to work using nvim-compe and vim-vsnip (and the vsnip integration plugin). I am seeing the snippets in the completion window, but it is not clear to me how to expand the snippet.

The vim-vsnip docs give a few maps to use, but I haven’t seen them work at all in my experience.

Here is gif of me attempting to expand the snippet. I try by hitting <CR> and by hitting <C-j>.

I am wondering if I have goofed something up really bad before I start deleting other stuff. Thanks!

Here are the maps that I've set (sorry, little messy currently)
          on_attach = function(_, bufnr)
            -- require("completion").on_attach()
            local function map(...)
              vim.api.nvim_buf_set_keymap(bufnr, ...)
            local map_opts = {noremap = true, silent = true}

            map("n", "df", "<cmd>lua vim.lsp.buf.formatting()<cr>", map_opts)
            map("n", "gd", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<cr>", map_opts)
            map("n", "dt", "<cmd>lua vim.lsp.buf.definition()<cr>", map_opts)
            map("n", "K", "<cmd>lua vim.lsp.buf.hover()<cr>", map_opts)
            map("n", "gD", "<cmd>lua vim.lsp.buf.implementation()<cr>", map_opts)
            -- map("n", "<c-k>", "<cmd>lua vim.lsp.buf.signature_help()<cr>", map_opts)
            map("n", "1gD", "<cmd>lua vim.lsp.buf.type_definition()<cr>", map_opts)
            map("n", "gr", "<cmd>lua require'telescope.builtin'.lsp_references{}<cr>", map_opts)
            map("n", "g0", "<cmd>lua require'telescope.builtin'.lsp_document_symbols{}<cr>", map_opts)
            map("n", "gW", "<cmd>lua require'telescope.builtin'.lsp_workspace_symbols{}<cr>", map_opts)

            vim.cmd [[map <expr> <C-j>   vsnip#expandable()  ? '<Plug>(vsnip-expand)'         : '<C-j>']]
            vim.cmd [[smap <expr> <C-j>   vsnip#expandable()  ? '<Plug>(vsnip-expand)'         : '<C-j>']]

            vim.cmd [[imap <expr> <C-l>   vsnip#available(1)  ? '<Plug>(vsnip-expand-or-jump)' : '<C-l>']]
            vim.cmd [[smap <expr> <C-l>   vsnip#available(1)  ? '<Plug>(vsnip-expand-or-jump)' : '<C-l>']]

            vim.cmd [[imap <expr> <Tab>   vsnip#jumpable(1)   ? '<Plug>(vsnip-jump-next)'      : '<Tab>']]
            vim.cmd [[smap <expr> <Tab>   vsnip#jumpable(1)   ? '<Plug>(vsnip-jump-next)'      : '<Tab>']]
            vim.cmd [[imap <expr> <S-Tab> vsnip#jumpable(-1)  ? '<Plug>(vsnip-jump-prev)'      : '<S-Tab>']]
            vim.cmd [[smap <expr> <S-Tab> vsnip#jumpable(-1)  ? '<Plug>(vsnip-jump-prev)'      : '<S-Tab>']]

            map("i", [[<silent><expr> <C-Space>]], [[compe#complete()]], map_opts)
            map("i", [[<silent><expr> <CR>]], [[compe#confirm('<CR>')]], map_opts)
            map("i", [[<silent><expr> <C-e>]], [[compe#close('<C-e>')]], map_opts)
            map("i", [[<silent><expr> <C-f>]], [[compe#scroll({ 'delta': +4 })]], map_opts)
            map("i", [[<silent><expr> <C-d>]], [[compe#scroll({ 'delta': -4 })]], map_opts)

Hmm, it seem’s related to this issue and incorrectly porting the mapping to lua.

I set the maps using vim.cmd [[ ... ]] and removed vim-endwise and now it seems to work.