autolist.nvim
autolist.nvim copied to clipboard
cmp and smart-pairs <CR> confict
Hey, I really like the idea for your plugin, but unfortunately after installing it, it wasn't working.
I use ZhiyuanLck/smart-pairs for pairs and hrsh7th/nvim-cmp for completion, and to make them both work I had to configure like this issue suggests
require 'cmp'.setup {
mapping = cmp.mapping.preset.insert {
['<CR>'] = cmp.mapping(function ()
if not cmp.confirm { select = false } then
require 'pairs.enter'.type()
end
end)
}
}
Do you have any suggestion on how to make your plugin work with this workaround?
yeah, I'll have to look into that, let me get back to you
Thanks! I really look forward trying it out :D
For now, using o to go to a newline works perfectly even with checkboxes
Huh, it seems that the order you load the plugins matter, from someone on reddit. Play around with it, and see what happens.
Could you please point me to that Reddit post? I tried moving around the use declaration but it didn't worked
@ignamartinoli https://www.reddit.com/r/neovim/comments/wynye9/comment/im072yl/?utm_source=share&utm_medium=web2x&context=3
You could also play around with moving the require setup
I have LSP configured as
use {
'neovim/nvim-lspconfig',
config = function () require 'lsp' end,
requires = {
'antoinemadec/FixCursorHold.nvim',
'hrsh7th/cmp-nvim-lsp',
'L3MON4D3/LuaSnip',
'hrsh7th/cmp-path',
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/nvim-cmp',
'onsails/lspkind-nvim',
'saadparwaiz1/cmp_luasnip',
{
'kosayoda/nvim-lightbulb',
config = function () require 'nvim-lightbulb'.setup {
autocmd = { enabled = true }
} end
},
'nvim-telescope/telescope.nvim',
{
'ray-x/lsp_signature.nvim',
config = function () require 'lsp_signature'.setup {
hint_prefix = ' '
} end
},
{
'williamboman/mason.nvim',
config = function () require 'mason'.setup() end
},
{
'williamboman/mason-lspconfig.nvim',
config = function () require 'mason-lspconfig'.setup() end
}
}
}
Nothing happens if I do
use {
'gaoDean/autolist.nvim',
after = 'nvim-cmp',
config = function () require 'autolist'.setup() end
}
If I do this
use {
'gaoDean/autolist.nvim',
after = 'hrsh7th/nvim-cmp',
config = function () require 'autolist'.setup() end
}
I get the following error
Dependency hrsh7th/nvim-cmp for { "autolist.nvim" } not found
I am unfamiliar with lsps and packer, but could the error be because nvim-cmp isn't in the root of the packer, instead in "neovim/nvim-lspconfig", so the after can't access it? Also, is autolist's use before lspconfig's use?
Not sure where you define your setup for nvim-cmp, but you want to call require("autolist").setup() after defining the cmp.mappings when you setup nvim-cmp.
Nothing happens if I do
use { 'gaoDean/autolist.nvim', after = 'nvim-cmp', config = function () require 'autolist'.setup() end }
This won't work because autolist's setup is called after nvim-cmp is loaded, but not after nvim-cmp's setup is loaded (since you don't define it as such).
Check out my config - I managed to get it working with nvim-cmp: https://github.com/axieax/dotconfig/blob/4d193fdb081328c98e3b704639c92eeb0decc2eb/nvim/lua/axie/plugins/init.lua#L825-L834
I did some tests, and the issue is on the cmp-nvim mapping.
I have this mapping set to make both cmp-nvim and smart-pairs work together
cmp.setup {
['<CR>'] = cmp.mapping(function ()
if not cmp.confirm { select = false } then
require 'pairs.enter'.type()
end
end)
}
If I have the mapping set like this now autolist.nvim works but smart-pairs don't
cmp.setup {
mapping = cmp.mapping.preset.insert {
['<CR>'] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = true }
}
}
I found this link: https://github.com/windwp/nvim-autopairs#mapping-cr
It's from another popular auto-pairing plugin, on how to make it work with cmp, it may be useful. I switched to nvim-autopairs and now it your plugin works perfectly, really love it
Oh cool, thanks. Imma close this now, but this this thread is probably gonna be referenced by more people having the same problem.