mini.nvim icon indicating copy to clipboard operation
mini.nvim copied to clipboard

mini.pairs not working

Open LeoLee53 opened this issue 2 years ago • 6 comments

Contributing guidelines

Module(s)

mini.pairs

Description

when trying to insert any paired symbols, an error message would pop up and a 0 will inserted instead.

Neovim version

v0.9.5

Steps to reproduce

  1. setup mini.pairs in config
  2. restart nvim
  3. try to input any paired symbols, like "(".

Expected behavior

No response

Actual behavior

an error message will show up, and a 0 will be inserted instead. image

LeoLee53 avatar May 05 '24 09:05 LeoLee53

There is a not proper Lua pattern set up for ( character in the config. I can not help more without seeing how 'mini.pairs' is set up.

echasnovski avatar May 05 '24 10:05 echasnovski

I used the default setup using require(“mini.pairs”).setup()

LeoLee53 avatar May 05 '24 10:05 LeoLee53

I used the default setup using require(“mini.pairs”).setup()

It doesn't look like it, because with basic require('mini.pairs').setup() everything works on all supported Neovim versions.

Would you mind executing the following command which will put some lines at the start of current buffer, copy those lines and paste here?

:lua vim.fn.append(0, vim.split(vim.inspect(MiniPairs.config), '\n'))

echasnovski avatar May 05 '24 11:05 echasnovski

sure, here's the config I got through the command:

{
  mappings = {
    ['"'] = {
      action = "closeopen",
      neigh_pattern = "[^\\].",
      pair = '""',
      register = {
        cr = false
      }
    },
    ["'"] = {
      action = "closeopen",
      neigh_pattern = "[^%a\\].",
      pair = "''",
      register = {
        cr = false
      }
    },
    ["("] = {
      action = "open",
      neigh_pattern = "[^\\].",
      pair = "()"
    },
    [")"] = {
      action = "close",
      neigh_pattern = "[^\\].",
      pair = "()"
    },
    ["["] = {
      action = "open",
      neigh_pattern = "[^\\].",
      pair = "[]"
    },
    ["]"] = {
      action = "close",
      neigh_pattern = "[^\\].",
      pair = "[]"
    },
    ["`"] = {
      action = "closeopen",
      neigh_pattern = "[^\\].",
      pair = "``",
      register = {
        cr = false
      }
    },
    ["{"] = {
      action = "open",
      neigh_pattern = "[^\\].",
      pair = "{}"
    },
    ["}"] = {
      action = "close",
      neigh_pattern = "[^\\].",
      pair = "{}"
    }
  },
  modes = {
    command = false,
    insert = true,
    terminal = false
  }
}

also, this is the setup i have in my config image

LeoLee53 avatar May 05 '24 20:05 LeoLee53

sure, here's the config I got through the command:

Hmm, this look about right.

Would you mind trying to reproduce this with clean config in which only 'mini.pairs' installed and active? For this:

  • Create a '~/.config/nvim-minipairs' directory and file 'init.lua' inside of it.
  • Paste the following code in that 'init.lua' file:
    local path_package = vim.fn.stdpath('data') .. '/site/'
    local mini_path = path_package .. 'pack/deps/start/mini.nvim'
    if not vim.loop.fs_stat(mini_path) then
      vim.cmd('echo "Installing `mini.nvim`" | redraw')
      local clone_cmd = { 'git', 'clone', '--filter=blob:none', 'https://github.com/echasnovski/mini.nvim', mini_path }
      vim.fn.system(clone_cmd)
      vim.cmd('packadd mini.nvim | helptags ALL')
      vim.cmd('echo "Installed `mini.nvim`" | redraw')
    end
    
    require('mini.pairs').setup()
    
  • From command line execute NVIM_APPNAME=nvim-minipairs nvim and wait for 'mini.nvim' to be installed.
  • Enter Insert mode and try to reproduce the error.

Also it would be helpful to share a bit more info:

  • Does this happen after every press of "(" or only in some situations? If not always, then what are the situations.
  • The full Neovim version info. Like the whole output of nvim --version. There might be a different source of Lua or something.
  • OS.
  • Keyboard layout.

echasnovski avatar May 06 '24 08:05 echasnovski

Thanks for the step-by-step guide. I'll give it a go and keep you updated when I got time. For now I'll just use nvim-autopairs as a replacement.

LeoLee53 avatar May 06 '24 10:05 LeoLee53