dstein64 / nvim-scrollview

A Neovim plugin that displays interactive vertical scrollbars and signs.
MIT License
546 stars 10 forks source link

opening a large file with a lot of error slows down nvim #121

Open OneOfOne opened 11 months ago

OneOfOne commented 11 months ago

When opening a large file with a lot of errors (ex react-native/index.js because it uses typescript in a javascript file), it slows nvim to almost 1fps.

Is there a way to dynamically disable signs if there's more than X amount?

dstein64 commented 11 months ago

Hi @OneOfOne. Thanks for reporting the issue.

Is the Vim option mousemoveevent set?

:set mousemoveevent?

I just added a few optimizations (38dd65977432ab1f3b1b706a4198216e5d168c50, 0f286e8c97c46e8c854651ad1851550cd654ede8, e8befc94ea66194700495d2f71419ba112634b0b). Is the problem resolved?

OneOfOne commented 11 months ago

It is not set, gonna try with the latest commits.

OneOfOne commented 11 months ago

Nope, still used 50-100% cpu and can barely move, with the mouse or the keyboard.

You can try locally, I think you might need Lsp setup with tsserver but turning off this addon solves the issue, where running LspStop doesn't change anything.

❯ mkdir /tmp/x && cd /tmp/x
mkdir: created directory '/tmp/x'
❯ yarn add react-native
❯ vim ./node_modules/react-native/index.js
dstein64 commented 11 months ago

Following the steps you posted, I can see that there are many errors, with an entire column of "E" signs created by nvim-scrollview.

However, movements work fine for me without any slowdown.

nvim-scrollview creates floating windows to show the scrollbar and signs. I wonder if the creation of many such windows is causing another plugin to slow down.

Under the same environment, with index.js loaded and LSP and other plugins running, if you disable nvim-scrollview with :ScrollViewDisable, presumably everything works fine. From there, with everything working fine, what happens if you manually create many floating windows? Do you encounter the same slowdown?

The following script creates a floating window for each row.

" create_floats.vim

let height = winheight(0)
let width = winwidth(0)

for row in range(height)
  let buf = nvim_create_buf(v:false, v:true)
  call nvim_buf_set_text(buf, 0, 0, 0, 0, [string(row)])
  let popup = nvim_open_win(buf, 0, {
        \   'relative':  'editor',
        \   'row':       row,
        \   'col':       width - 2,
        \   'width':     2,
        \   'height':    1,
        \   'focusable': v:false,
        \   'style':     'minimal',
        \ })
endfor

The script can be sourced from the index.js buffer.

:source /path/to/create_floats.vim

Separately, if you load a large file without using LSP, but there are still many scrollview signs, do you still encounter the issue? This scenario can be tested with the following commands, which loads the builtin.txt help file (which is large) and creates many textwidth signs (if you don't see these, then the steps aren't functioning as intended).

:help builtin.txt
:only
:ScrollViewEnable
:ScrollViewEnable textwidth
:set textwidth=1