HiPhish / nvim-ts-rainbow2

Rainbow delimiters for Neovim through Tree-sitter
https://gitlab.com/HiPhish/nvim-ts-rainbow2
Apache License 2.0
338 stars 35 forks source link

[Bug]: nvim-cmp window reactivates rainbow after it's been disabled #51

Closed mystilleef closed 1 year ago

mystilleef commented 1 year ago

Neovim version

master

Language affected

No response

Query

No response

Strategy

No response

Description

When the `nvim-cmp` completion window becomes visible `rainbow` reactivates itself even after it's been disabled.
mystilleef commented 1 year ago

Here's a video showing the issue.

https://github.com/HiPhish/nvim-ts-rainbow2/assets/273399/baabf441-d1c2-49c4-aeb0-0770211a3531

HiPhish commented 1 year ago

How do you disable this plugin? Here are a couple of scenarios I have tried out:

Here is a sample buffer:

x = [[[[[[[[]]]]]]]]
print(((x)))

If I insert another [] pair inside the list the highlighting turns on in the second case. Note that there is no completion popup window, so this has nothing to do with nvim-cmp.

I do know where the problem lies, but I cannot fix it. When the plugin attaches to a new buffer a callback is registered for on_changedtree (see :h LanguageTree:register_cbs()). However, there is no way of removing the callback again, and so the callback lingers on even after disabling rainbow highlights. There is a destroy method, but it does not actually do anything.

I can add a one-line little hack so the callback is aborted. This is not ideal since the callbacks will build up and consume memory, but at least it solves the visual problem.

HiPhish commented 1 year ago

I have pushed an update to master which fixes the issue for me. Please report back if it works for you.

mystilleef commented 1 year ago

The latest update fixes the issue. Thanks!

I use TSDisableRainbow. I turn off all colors in Insert mode and reenable them in Normal mode.

I am closing this issue.