altermo / ultimate-autopair.nvim

A treesitter supported autopairing plugin with extensions, and much more
MIT License
487 stars 4 forks source link

Undo mappings in insert mode don't work as expected #82

Open phanen opened 4 months ago

phanen commented 4 months ago
for _, char in ipairs({ '<space>', '-', '_', ':', '.', '/' }) do
  vim.keymap.set('i', char, char .. '<c-g>u')
end

After mappings, insert <space> or - cannot insert a undo point as expected.

altermo commented 4 months ago

The feature to solve this, which is falling back to keymapping, is on the TODO list. But until I get to that part of the TODO list, you can use this config:

require'ultimate-autopair'.init({
    require'ultimate-autopair'.extend_default({
        --Your config
    }),
    {profile='map',p=-1,
        {'i',' ',function () return vim.api.nvim_replace_termcodes(' <C-g>u',true,true,true) end},
        {'i','-',function () return vim.api.nvim_replace_termcodes('-<C-g>u',true,true,true) end},
    },
})
phanen commented 4 months ago

This workaround seems also adding cmap. image

altermo commented 4 months ago

Fixed