smoother bracket expansion
Sam-programs opened this issue · comments
expanding brackets draws the cursor 2 twice
it firstly moves to here and draws it when escape is pressed in the remap
{
|}
then here when the remap is done
{
|
}
this makes a visual stutter which is very annoying
in between frames it looks like there are 2 cursors
{
| |
}
while making my own autopairs i also faced this issue i found a solution for my autopairs
by returning this in the enter key remap
'<CR><CMD>normal ====k$<CR><right><CR>'
this way escape is never pressed
now am not really sure how nvim-autopairs is structured
but i noticed that on nvim-autopairs.lua:586 this return statement gets ran
return utils.esc(rule:get_map_cr({ rule = rule, line = line, color = col, bufnr = bufnr }))
using the new keys makes the bracket expansion only draw the cursor once
because <CMD> doesn't trigger a cursor redraw (not 100% sure)
return utils.esc('<CR><CMD>normal ====k$<CR><right><CR>')
you might want to also check the return statement on line 575
update i made fully working one in insert mode
https://github.com/Sam-programs/autopairs.nvim/blob/main/lua/autopairs.lua#L346
i don't know how to integrate it into nvim-autopair
this method is a bit risky for custom pairs as i wasn't able to replicate the == formatting perfectly
the first method is safe tho