Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
OneOfOne opened this issue Oct 11, 2023 · 4 comments
Open

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

OneOfOne opened this issue Oct 11, 2023 · 4 comments

Comments

@OneOfOne
Copy link

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
Copy link
Owner

dstein64 commented Oct 11, 2023

Hi @OneOfOne. Thanks for reporting the issue.

Is the Vim option mousemoveevent set?

:set mousemoveevent?

I just added a few optimizations (38dd659, 0f286e8, e8befc9). Is the problem resolved?

@OneOfOne
Copy link
Author

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

@OneOfOne
Copy link
Author

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
Copy link
Owner

dstein64 commented Oct 11, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants