karb94/neoscroll.nvim

`nzz` and `Nzz` not working

filipekiss opened this issue · 2 comments

First of all, thanks for the plugin. It's really great and works flawlessly 99% of the time.

I have a mapping that makes my n maps to nzz, so the search term is always kept in the center of the screen.

When using neoscroll, for some reason, nzz puts me on the line before the actual search term, so I'm "stuck" since the 'next' is always the ocurrence I just found.

Not sure if there's an easy way to fix this, but it would be great to keep my nzz mappings and still use neoscroll for zz.

Steps to reproduce:

  • nnoremap n nzz
  • Setup neoscroll:
neoscroll.setup({
   		-- All these keys will be mapped to their corresponding default scrolling animation
   		mappings = {
   			"<C-u>",
   			"<C-d>",
   			"<C-b>",
   			"<C-f>",
   			"<C-y>",
   			"<C-e>",
   			"zt",
   			"zz",
   			"zb",
   		},
   		hide_cursor = true, -- Hide cursor while scrolling
   		stop_eof = true, -- Stop at <EOF> when scrolling downwards
   		use_local_scrolloff = false, -- Use the local scope of scrolloff instead of the global scope
   		respect_scrolloff = false, -- Stop scrolling when the cursor reaches the scrolloff margin of the file
   		cursor_scrolls_alone = true, -- The cursor will keep on scrolling even if the window cannot scroll further
   	})
  • Open a large file an search for anything. Press n to go to the next match and see that the cursor actually lands on the line before it

This issue doesn't happen in smaller files. If the content fits in the window, it works as expected

I'm a bit confused. If you use nnoremap for your mapping you shouldn't see any neoscroll related motion as it will ignore any mappings within you mapping. For your mapping to work with Neoscroll mappings you should use nmap n nzz. I've tried this mapping and it looks like it's working properly for me. If this mapping doesn't work for you please share a specific text where I can reproduce the issue.

It must have been some weird configuration on my side, you're completely right. I changed some mappings and no longer can reproduce. Closing this. Thanks for your time.