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

don't update_range without query #12

Closed Gordin closed 1 year ago

Gordin commented 1 year ago

Fixes this bug: WindowsTerminal_otYNITFOHJ

I'm not sure what causes this, but here it happens when I tried to add a comment, after I typed the space behind --.

alexpw commented 1 year ago

Confirmed the commit from @Gordin resolves it.

The context for me was writing a lua comment within the table of my nvim config plugins, like the OP pic.

Minimum to reproduce:

HiPhish commented 1 year ago

I cannot reproduce the problem with the minimal example. I do remember having that issue at some point during development and having the same workaround for a while before I removed it. Do you have the comment grammer installed? Which version or commit of the plugin are you using?

I want to replicate the issue before I include code to handle the case. My personal hunch is that it could be due to the comment grammar; the comment lanugage get injected into a lot of other languages, but it does not have a query defined.

alexpw commented 1 year ago

Which version or commit of the plugin are you using?

commit 6bcb1472c321a15eef5a7a015b4fefa8758e6513 (HEAD -> master, origin/master, origin/HEAD)
NVIM v0.9.0-dev-1184+g0ecb4d725

Do you have the comment grammer installed?

Yes

My personal hunch is that it could be due to the comment grammar; the comment lanugage get injected into a lot of other languages, but it does not have a query defined.

Ah, that explains it! If I TSUninstall comment and reopen the file, I can't reproduce it anymore.

HiPhish commented 1 year ago

OK, I can replicate the issue in Neovim 0.9 (pre-release), but not in 0.8.3. I'll take a deeper look into it. Thank you both for bringing it up.

HiPhish commented 1 year ago

The issue should now be fixed in 7711a873d1f16a9f3049715b63cdd71973108871, please verify. I opted for a different solution: if there is no query defined we do not set up any callback in the first place. This should be more performant because we run the check only once per parser, we do not create a callback, and we save a pointless function call.

If the issue is fixed this PR becomes obsolete.

HiPhish commented 1 year ago

Just to be sure there is no misunderstanding: you can now re-install the comment grammar again. It should no longer cause any issues.

alexpw commented 1 year ago

The issue should now be fixed in 7711a87, please verify.

Verified, 7711a87 fixes it and resolves this issue.

HiPhish commented 1 year ago

Thank you. I am now closing this PR as no longer relevant.

HiPhish commented 1 year ago

Can you please provide a sample Vue file as well? It needs to cover the various way of writing Vue, such as embedding different languages (e.g. embedding Javascript and embedding Typescript). If Vue does not allow to have two script blocks then you can create separate test files.

See the files under test/highlight for examples of what I mean.

HiPhish commented 1 year ago

Sorry, wrong PR.