Random characters inserted after <cr>
pablo-abc opened this issue · comments
Description
Regardless of the file type, after a specific update, calling autopairs_cr()
causes random characters to appear on the file. E.g.
-- before pressing <cr>
local test = {|}
-- after pressing <cr>
local test = {
�ýal! ====
�ku�@7
|}
This started to happen since this commit: f611dc2
If I install autopairs using the commit right before it (3b664e8) everything works as expected.
Attached a minimal config that reproduces the bug
Mapping bug
1.If you report a bug about indent. Please remember that plugin doesn't do anything about indent.
It just trigger the indent of your vim config so if you have wrong indent config then it will do wrong indent.
You can check by select a block of code and press ==
2. provide result of command :verbose imap <cr>
.
Steps to reproduce
No response
Minimal config
local ensure_packer = function()
local fn = vim.fn
local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
fn.system({ 'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path })
vim.cmd [[packadd packer.nvim]]
return true
end
return false
end
local function map(mode, lhs, rhs, opts)
local options = { silent = true }
if opts then
options = vim.tbl_extend('force', options, opts)
end
vim.keymap.set(mode, lhs, rhs, options)
end
local packer_bootstrap = ensure_packer()
map(
'i',
'<CR>',
function()
return require('nvim-autopairs').autopairs_cr()
end,
{ expr = true }
)
return require('packer').startup(function(use)
-- Packer can manage itself
use 'wbthomason/packer.nvim'
use {
"windwp/nvim-autopairs",
-- It fails with this commit and onwards
commit = "f611dc2788d7f904148a4217646c82f006f19b25",
-- Replace with next line to show it working
-- commit = "3b664e8277c36accec37f43414d85a3b64feba5f",
config = function()
require("nvim-autopairs").setup {
map_cr = false
}
end
}
if packer_bootstrap then
require('packer').sync()
end
end)
nvim-autopairs already replaces the key codes like <cmd>
when the mapping tries to replace them it makes the already-replaced keys become text that gets displayed.
set replace_keycodes to false so the mapping doesn't try to escape the keys again.
{ expr = true,replace_keycodes = false}
the reason it broke is in that commit i added <cmd>,other keys that were used before that commit didn't break after getting escaped twice.
how can this be fixed in integration with cmp?
how can this be fixed in integration with cmp?
Where does the cmp integration use autopairs_cr
?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.