Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Bracket coloring inconsistent #44

Open
benediktms opened this issue May 27, 2023 · 8 comments
Open

Bracket coloring inconsistent #44

benediktms opened this issue May 27, 2023 · 8 comments

Comments

@benediktms
Copy link

benediktms commented May 27, 2023

Describe the bug

I've noticed that some highlighting is inconsistent: Sometimes a bracket gets highlighted, sometimes it doesn't, sometimes the order of colors is not what is expected. So far I've tested this on TypeScript (+ TSReact) and Rust files.

(also it seems the magenta color is actually more greenish but that's out of scope for this problem)
Steps to reproduce

Steps to reproduce the behavior.

I've defined some custom colors:

vim.api.nvim_set_hl(0, "TSRainbowYellow", { fg = "#FFD700" })
vim.api.nvim_set_hl(0, "TSRainbowMagenta", { fg = "#DA70D6" })
vim.api.nvim_set_hl(0, "TSRainbowBlue", { fg = "#87CEFA" })

and then set the plugin up like so:

local opts = {
	rainbow = {
		enable = true,
		strategy = require("ts-rainbow").strategy.global,
		hlgroups = {
			"TSRainbowYellow",
			"TSRainbowMagenta",
			"TSRainbowBlue",
		},
		query = {
			"rainbow-parens",
			tsx = "rainbow-tags",
		},
	},
}
require("nvim-treesitter.configs").setup(opts)

Expected behavior
All brackets shoudlbe highlighted, and cycle through the defined colors yellow -> magenta -> blue -> yellow etc.

Screenshots
Rust
image

TypeScript
image

@HiPhish
Copy link
Owner

HiPhish commented May 27, 2023

The Rust snippet looks fine on my machine and I don't see what is supposed to be the problem in your screenshot (except for the colours being different).

Screenshot_20230527_230617

The Typescript query was missing some patterns, I have added them now. I have no idea why your colours are off like that. What do you see when you execute :highlight TSRainbowYellow?

@benediktms
Copy link
Author

benediktms commented May 28, 2023

@HiPhish regarding the Rust screenshot: on my machine it seems like the colors don't get cycled correctly, e.g. on the third line, at the match statement, I would expect the {..} to be TSRainbowMagenta, but they are uncolored.

Regarding the off color, it seems to be an issue with the way I've set up TSRainbowMagenta. :highlight TSRainbowMagenta prints out:

TSRainbowMagenta xxx cleared

I assume that the plugin just falls back on a default color, but this also seems to stop the color cycling.

EDIT: I updated the TSRainbowBlue color to #87CEEB and after double checking, the output for TSRainbowBlue also does not seem to match:

TSRainbowBlue  xxx ctermfg=12 guifg=#458588

@benediktms
Copy link
Author

I also found the tsx files are missing some highlights for components with children. I showcased it here: https://github.com/HiPhish/nvim-ts-rainbow2/compare/master...benediktms:nvim-ts-rainbow2:showcase-missing-brackets-highlights?expand=1

@HiPhish
Copy link
Owner

HiPhish commented Jun 4, 2023

I guess you mean to the { ... } in React? I have added it now, can you please test?

As for the original issue, is the way the screenshot above looks what you expect?

@benediktms
Copy link
Author

I've tested this again with the same colors I mentioned above, but the bracket highlight still does not seem to like my colors:
image

@HiPhish
Copy link
Owner

HiPhish commented Jun 21, 2023

Where and when are you defining your highlight groups? What happens if you set your highlight groups manually while the buffer is open (e.g. :hi TSRainbowRed guifg=#ff0000 or whatever colour you want)

Colour schemes usually clear all highlight groups, so if you define your own highlight groups before Vim set the colour scheme your settings will be wiped out.

@benediktms
Copy link
Author

ahh thanks for pointing that out! I didn't even take that into consideration. It works now, for the most part, however the color rotation still sometimes does not work correctly, see screenshow below of a .tsx file:

Screenshot 2023-06-23 at 10 21 20

The type declaration File[] is missing the brackete highlights, as well as brackets for the for (...) loop

@HiPhish
Copy link
Owner

HiPhish commented Jul 3, 2023

This plugin is now deprecated because of upcoming changes to nvim-treesitter. The new rainbow plugin is here: rainbow-delimiters.nvim (GitHub mirror). Please file an issue over there if the problem still persists.

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

No branches or pull requests

2 participants