How to lazy-load the plugin windwp/nvim-autopairs?

I would like to know how to put the setup part associated with the “InsertEnter” event

use {'windwp/nvim-autopairs', event = "InsertEnter"}

I have these lines below

-- nvim-autopairs plugin settings
-- you need setup cmp first put this after cmp.setup()
-- use 'windwp/nvim-autopairs'
	check_ts = true,
  map_cr = true, --  map <CR> on insert mode
  map_complete = true, -- it will auto insert `(` after select function or method item
  auto_select = true -- automatically select the first item

1 Like

You can use event = 'InsertEnter' with cmp, then use after when you set up nvim-autopairs and put your configuration in separate files (e.g. in ~/.config/nvim/lua/config/autopairs.lua)

use {
   event = 'InsertEnter',
   config = [[require('config.cmp')]]
use {
   after = 'nvim-cmp',
   config = [[require('config.autopairs')]]

The only problem I spend some time figuring out was the use of brackets, I just remove them and the suggested code started working properly.