altermo / ultimate-autopair.nvim

A treesitter supported autopairing plugin with extensions, and much more

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Installing ultimate-autopair causes luasnip to malfunction

IsWladi opened this issue · comments

The plugin itself works fantastically, but it causes an unintended interaction with another plugin (luasnip).

Expected Behavior

While in insert mode and using cmp to accept a snippet with , the snippet expands correctly, and I can move through different parts of the snippet using Alt + o to go back and Alt + e to go forward.
Expected Behavior

Current Behavior

If I do not have ultimate-autopair.nvim installed, the snippets work fine. However, upon installing it, the keymaps for moving within the snippet no longer work (Alt + o to go back and Alt + e to go forward).
Current Behavior

System Information

Operating System: WSL2
NeoVim Version: 0.10.0
Ultimate-autopair.nvim Commit installed: 042587c

Minimal Config

--Lazy install
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
  {
    {
      {'L3MON4D3/LuaSnip',
        event = {"BufReadPre", "BufNewFile"},
        dependencies = {
          { "rafamadriz/friendly-snippets" }
        },
        config = function()

          --lua snippets
          local ls = require "luasnip"
          local t = ls.text_node
          local i = ls.insert_node
          local s = ls.snippet

          ls.config.set_config {
            history = true
          }

          require("luasnip.loaders.from_vscode").lazy_load()

          -- is my expansion key
          vim.keymap.set({ "i", "s" }, "<M-e>", function()
            if ls.expand_or_jumpable(1) then
              ls.expand_or_jump(1)
            end
          end, { silent = true, desc = "[snippets] go to next" })

          -- is my jump forward keymap
          vim.keymap.set({ "i", "s" }, "<M-o>", function()
            if ls.jumpable(-1) then
              ls.jump(-1)
            end
          end, { silent = true, desc = "[snippets] go to previus" })
        end
      },
      {'hrsh7th/nvim-cmp',
        dependencies = {
          {'saadparwaiz1/cmp_luasnip'},
        },
        config = function()
          local cmp          = require('cmp')
          local cmp_select   = {behavior = cmp.SelectBehavior.Select}
          local cmp_mappings = cmp.mapping.preset.insert({
            ['<C-p>']        = cmp.mapping.select_prev_item(cmp_select),
            ['<C-n>']        = cmp.mapping.select_next_item(cmp_select),
            ['<Tab>']        = cmp.mapping.confirm({ select = true }),
          })

          cmp.setup({
            mapping = cmp_mappings,
            sources = {
              {name = 'luasnip'},
            },
          })
        end
      },
      {
        'altermo/ultimate-autopair.nvim',
        enabled=true,
        event={'InsertEnter','CmdlineEnter'},
        branch='v0.6', --recommended as each new version will have breaking changes
        opts={
          --Config goes here
        },
      }
    },
  }

})

Ultimate-autopair uses <M-e> for the fastwarp function (see :h ultimate-autopair-map-fastwarp-config).
So disable (or remap) it:

require('ultimate-autopair').setup{
    fastwarp={
        enable=false,
    }
}

Thank you! It works perfectly now :D