nvim-autopairs icon indicating copy to clipboard operation
nvim-autopairs copied to clipboard

smoother custom pairs

Open Sam-programs opened this issue 1 year ago • 7 comments

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

Sam-programs avatar Oct 07 '23 05:10 Sam-programs

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?.

windwp avatar Oct 15 '23 09:10 windwp

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

Sam-programs avatar Oct 15 '23 09:10 Sam-programs

i think i found a better way with lazy drawing

Sam-programs avatar Oct 15 '23 10:10 Sam-programs

yea lazyredrawing seems to make everything super clean with no weird cursor movements

Sam-programs avatar Oct 15 '23 10:10 Sam-programs

@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

Sam-programs avatar Oct 17 '23 10:10 Sam-programs

also can't we pre-escape keys in utils.lua instead of having to call utils.esc each time we use them?

Sam-programs avatar Oct 17 '23 11:10 Sam-programs

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.

stale[bot] avatar Dec 16 '23 11:12 stale[bot]