karb94/neoscroll.nvim

Scrolling not smooth when using nvim-treesitter-context

akriese opened this issue · 1 comments

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 :)

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!