RRethy / vim-illuminate

illuminate.vim - (Neo)Vim plugin for automatically highlighting other uses of the word under the cursor using either LSP, Tree-sitter, or regex matching.
2.23k stars 53 forks source link

Vim slows to a crawl on Elixir file with many pipes. #169

Closed Hermanverschooten closed 1 year ago

Hermanverschooten commented 1 year ago

As mentioned in https://github.com/LunarVim/LunarVim/issues/4213, there is an issue when an Elixir file has many lines starting with a pipe. Vim becomes very unresponsive.

@LostNeophyte researched the issue and traced it back to this plugin.

To reproduce:

Take a default lunarvim install (eg Docker version).
:TSInstall elixir (just to be sure)
Create a file called test.ex
insert the line: |> IO.inspect()
Now yank that line and paste it say 80 times.

Using :TSBufDisable illuminate alleviates the problem.

Output from :IlluminateDebug

buf_should_illuminate 3 true
config {
  delay = 120,
  filetype_overrides = {},
  filetypes_allowlist = {},
  filetypes_denylist = { "dirvish", "fugitive", "alpha", "NvimTree", "lazy", "neogitstatus", "Trouble", "lir", "Outline", "spectre_panel", "toggleterm", "DressingSelect", "TelescopePrompt" },
  min_count_to_highlight = 1,
  modes_allowlist = {},
  modes_denylist = {},
  providers = { "lsp", "treesitter", "regex" },
  providers_regex_syntax_allowlist = {},
  providers_regex_syntax_denylist = {},
  under_cursor = true
}
started true
provider table: 0x0101a07c80 treesitter
`termguicolors` true

Expected behavior Vim should remain as responsive as ever.

RRethy commented 1 year ago

Seems like a issue with nvim-treesitter being slow, the fix mentioned in that issue is probably the best that can be done, you could also increase the delay for elixir files. There's not much that can really be done since Neovim is single threaded and treesitter queries can be slow sometimes.

If #168 ever gets implemented, it would help here a bit too.

RRethy commented 1 year ago

I'm going to close this since it's primarily a treesitter issue, not a vim-illuminate issue. Your best bet would be using the regex provider or the lsp provider.