nvim-ts-rainbow icon indicating copy to clipboard operation
nvim-ts-rainbow copied to clipboard

Neovim freezes in large file when only opening bracket is inserted

Open rouge8 opened this issue 3 years ago • 9 comments

Describe the bug

I'm seeing extremely slow performance inserting ([ around line 150 in a ~1600 line file. It takes ~20 seconds for the [ to insert. 😵

Steps to reproduce

  1. Open https://github.com/rouge8/jit.rs/blob/2a3e5dbc7d603f465c1f3083c655613d9a69b87d/tests/merge_test.rs#L147
  2. After line 147, type let tree = BTreeMap::from([
  3. Wait ~20 seconds after typing the [ before it appears.

Expected behavior

Text should insert instantly.

rouge8 avatar Nov 26 '21 21:11 rouge8

I can't reproduce this:

https://user-images.githubusercontent.com/36493671/143666498-da804aac-cf62-40c1-a767-81ee3ab9895c.mp4

p00f avatar Nov 27 '21 03:11 p00f

I even tried downloading the entire project, it inserts instantly

p00f avatar Nov 27 '21 03:11 p00f

(I do have rainbow enabled there, they are all different shades of blue/grey)

p00f avatar Nov 27 '21 03:11 p00f

Interesting, it must be an interaction between plugins or something… I’ll try debugging more

rouge8 avatar Nov 27 '21 03:11 rouge8

I can still reproduce with a minimal set of plugins:

Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate', 'branch': '0.5-compat'}
Plug 'p00f/nvim-ts-rainbow'

What looks different in your recording is that you're autocompleting the ), so you're typing:

let tree = BTreeMap::from()

and then inserting the [. Admittedly that still is slow for me...

rouge8 avatar Nov 27 '21 14:11 rouge8

And this is my Treesitter config:

lua <<EOF
require'nvim-treesitter.configs'.setup {
  ensure_installed = "maintained",
  ignore_install = {},
  highlight = {
    enable = true,
    disable = {"rst"},
    additional_vim_regex_highlighting = false,
  },
  rainbow = {
    enable = true,
    extended_mode = true,
    max_file_lines = nil,
  },
  matchup = {
    enable = true,
  },
}
EOF

rouge8 avatar Nov 27 '21 14:11 rouge8

I can reproduce this when I disable https://github.com/jiangmiao/auto-pairs

p00f avatar Nov 27 '21 15:11 p00f

fwiw you can get around this without an autopair plugin by inserting the closing bracket first, and if you want to delete the brackets then delete the opening one first

p00f avatar Nov 27 '21 15:11 p00f

This might be related to https://github.com/steelsojka/pears.nvim/issues/11#issue-864786260

p00f avatar Nov 30 '21 14:11 p00f