nvim-autopairs
nvim-autopairs copied to clipboard
smoother custom pairs
https://github.com/windwp/nvim-autopairs/pull/396 sorry for bringing this up again but i tested nvim_win_set_cursor and it never broke the undo blocks only arrow keys broke them
vim.keymap.set("i", "<C-r>", function()
local set_cursor = vim.api.nvim_win_set_cursor
local r,c = unpack(vim.api.nvim_win_get_cursor(0))
set_cursor(0,{r,c + 1})
set_cursor(0,{r - 1,c + 2})
set_cursor(0,{r - 1,c - 2})
set_cursor(0,{1,0})
set_cursor(0,{r,c})
end)
jump_to_last_pair is safe to add to make custom pairs smoother
On mapping, I want to use mapping by key only. Using API functions like set_cursor or set_text might interfere with other plugins. I'm not sure what you mean by 'smoother.' What does this pull request aim to achieve?.
well say we define a custom rule for lua then's
rule("then","end","lua")
the cursor moves/draws twice when we press n
the|
thene|nd
thenend|
because of ctrl-g it's more noticable in single byte pairs like adding a custom () pair
i think i found a better way with lazy drawing
yea lazyredrawing seems to make everything super clean with no weird cursor movements
@windwp here is what i mean by smoother
https://github.com/windwp/nvim-autopairs/assets/130783534/eddad57e-8dd3-4aa8-9347-1e3a609f0aa1
in the video it moves the cursor 2 times at second 5 and second 6(the end),
i am not even using vim.api.*
functions anymore just setting lazy-redrawing
and sorry for the quality i didn't have my obs setup properly while recording this
also can't we pre-escape keys in utils.lua
instead of having to call utils.esc
each time we use them?
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.