Sawtaytoes / vscode-colormate

ColorMate: The best Semantic highlighting for VSCode
GNU General Public License v3.0
7 stars 0 forks source link

Function highlighted in python even when excluded from colormate.semanticTokenTypes #3

Open MalcolmMielle opened 10 months ago

MalcolmMielle commented 10 months ago

That's kinda of all in the title :). My settings only have property in the parameters but function names are still highlighted in python.

Also, is it possible to specify a color theme? The default one is kinda clashing with my base color theme.

Sawtaytoes commented 10 months ago

Excluded colors still coloring

semanticTokenTypes is only part of what gets highlighted. There are both Semantic Tokens and TextMate Tokens that can be highlighted by ColorMate, and both have default values.

You're probably running up against the entity.name.function TextMate token.

You can either:

  1. Exclude entity.name.function from colormate.excludedTextMateTokenScopes.
  2. Set colormate.hasDefaultTextMateTokenScopes which removes all defaults.

These are the current defaults:

[
  "entity.name.function",
  "entity.name.section.markdown",
  "entity.name.tag",
  "entity.other.attribute-name",
  "support.type.property-name.json",
  "variable.other.property",
  "variable.other.readwrite.alias",
]

ColorMate targets both token types because semantic tokens miss a lot and don't allow the same fine-grained granularity that TextMate tokens have. The only issue is that TextMate tokens are per-language plugin whereas Semantic Tokens are both generic and global (which is why there's also an option to disable ColorMate on specific languages).

Changing the Color Theme (hashing algorithm)

You can change the Lighting and Saturation for both light and dark themes, but I haven't included a way to modify the CRC8 color hashes. It's literally a 100% conversion

It's literally as simple as this with a CRC8 hex hookup table for each red, green, and blue value:

character.charCodeAt(0) % 256

If it's a big thing for you, you could submit a PR to add a way to change it. Either change the CRC8 algorithm or add your own.

The way this works is based on how Colorcoder worked for Sublime Text. I got so used to those colors that I transplanted that Python algorithm into JS and surprisingly got it to work.