karb94 / neoscroll.nvim

Smooth scrolling neovim plugin written in lua
MIT License
1.46k stars 36 forks source link

Scrolling not smooth when using nvim-treesitter-context #64

Closed akriese closed 2 years ago

akriese commented 2 years ago

I am not sure whether to post this here or in the nvim-treesitter-context issues.

When scrolling with the above mentioned plugin enabled and some context is shown in the first lines of the window, the scrolling gets somewhat whacky. I guess this is due to treesitter-context updating the info on each movement (each step of the scrolling), which is time consuming when added up. Does anyone know a way of telling nvim-treesitter-context to analyze the position in the buffer just after the scrolling is finished?

Here is a gif of the problem. One can see smooth scrolling in the first buffer, where no context is shown. In the second buffer, the plugin shows some context and scrolling starts to stutter. GIF 9-12-2022 2-52-28 PM

This is merely a small aesthetic problem, but I thought I'd ask here as neoscroll is all about smoothness :)

akriese commented 2 years ago

Nevermind, I fixed the issue by using the pre and post hooks to disable and enable the context plugin like so:

local ts_ctx = require("treesitter-context")
require("neoscroll").setup {
    -- ...
    pre_hook = function(_) ts_ctx.disable() end,
    post_hook = function(_) ts_ctx.enable() end
}

Runs like butter again. Thanks for the great work!