autolist.nvim
autolist.nvim copied to clipboard
`<CR>` compatibility with autopairs.nvim
In the recent update, autolist depecrated the custom mapping function in favor for native mapping. But this change caused some regressions.
Previously resolved issues with autopairs (https://github.com/gaoDean/autolist.nvim/issues/43) is now a problem again.
Any straightforward way to fix this? Why not bring back the custom mapping functions? I honestly don't see how the "native" method is better in this context.
With vim.keymap.set, you can set a lua function that just calls whichever function is being overrided. If autolist is being overrided, you can do the vim.keymap.del, you can delete it if autolist is being overrided, or you can call autolist when you are mapping another plugin.
In my opinion, this is much more configurable and easier to setup for niche cases.
what am i saying. i think ill add a resolve_conflict mapping or smth that detects for any
wait i got a good idea (tell me if this is a bad idea) ill just add a new_bullet_hook that can run whatever function u want
sorry I'm just using you as a rubber ducky heres a solution if u want
vim.keymap.set("i", "<CR>", function()
-- run autolist-new-bullet after the <cr> of nvim-autopairs-cr
-- timeout of 0ms delays enough for my computer but u might need to adjust
local timeoutms = 0
vim.loop.new_timer():start(timeoutms, 0, vim.schedule_wrap(function()
require("autolist").new_bullet()
end))
return require("nvim-autopairs").autopairs_cr()
end, { expr = true, noremap = true })
sorry I'm just using you as a rubber ducky heres a solution if u want
vim.keymap.set("i", "<CR>", function() -- run autolist-new-bullet after the <cr> of nvim-autopairs-cr -- timeout of 0ms delays enough for my computer but u might need to adjust local timeoutms = 0 vim.loop.new_timer():start(timeoutms, 0, vim.schedule_wrap(function() require("autolist").new_bullet() end)) return require("nvim-autopairs").autopairs_cr() end, { expr = true, noremap = true })
I use "ZhiyuanLck/smart-pairs" have the same problem, I tried this and it worked, thanks!
require("pairs"):setup({
enter = {
enable_mapping = true,
enable_cond = false,
enable_fallback = function()
-- https://github.com/gaoDean/autolist.nvim/issues/77
vim.loop.new_timer():start(0, 0, vim.schedule_wrap(function()
require("autolist").new_bullet()
end))
require('pairs.utils').feedkeys('<cr>')
end,
},
})
sorry I'm just using you as a rubber ducky heres a solution if u want
vim.keymap.set("i", "<CR>", function() -- run autolist-new-bullet after the <cr> of nvim-autopairs-cr -- timeout of 0ms delays enough for my computer but u might need to adjust local timeoutms = 0 vim.loop.new_timer():start(timeoutms, 0, vim.schedule_wrap(function() require("autolist").new_bullet() end)) return require("nvim-autopairs").autopairs_cr() end, { expr = true, noremap = true })
I am experiencing the same issue (autolist and autopairs) and adding this makes <CR> do nothing. I tried changing timeoutms to various number and it still the same. I checked my keybinds for any other <CR> and its only binded to completion_confirm(). Is there an alternative way to make this work with autopairs?