Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support full semantic highlighting #54

Closed
madrussa opened this issue Jun 4, 2021 · 6 comments
Closed

Support full semantic highlighting #54

madrussa opened this issue Jun 4, 2021 · 6 comments

Comments

@madrussa
Copy link

madrussa commented Jun 4, 2021

First thing, your theme is lovely.

It would be really good if Eva theme could enable semantic highlighting properly. I find it extremely useful to be able to identify variables that are actually parameters. This means I can avoid overwriting them or quickly seeing where they're used

On line 16 we can see assetId is yellow, but on lines 17 and 18 the assetId param is white.
image

If we toggle the semanticHightlighting setting to true (overriding the theme)

Now on lines 17 and 18 the assetId param usage is coloured the same (yellow).
image

This does however mean that a lot of the colours in the file have changed. On line 21 asset is now orange because it reflects the const usage on line 17. I guess there'll be a lot of these little nuances to get right and would likely require a separate "Eva Dark Semantic" theme.

Keep up the great work!

@fisheva
Copy link
Owner

fisheva commented Jun 4, 2021

Could you please copy the code below? So that I can use it for testing, thank you!

@madrussa
Copy link
Author

madrussa commented Jun 4, 2021

Sure, here is a much simpler example.

Typescript:

import React, { HTMLProps } from "react";
import cx from "classnames";
import styles from "../my-styles.module.scss";

type TProps = {
	children: React.ReactNode;
	className?: string;
};

type TComponentProps = HTMLProps<HTMLDivElement> & TProps;

const Container: React.FunctionComponent<TComponentProps> = ({ children, className, ...htmlProps }) => {
	return (
		<div {...htmlProps} className={cx(styles.container, className)}>
			{children}
		</div>
	);
};

export default React.memo(Container);

Semantic Hightlighting: Off
image

Semantic Hightlighting: On
image


Also when paramters are pushed onto multiple lines they are no longer yellow:

Semantic Hightlighting: Off
image

Semantic Hightlighting: On
image


Hopefully the following article will be of some use:
https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide

@fisheva
Copy link
Owner

fisheva commented Jun 4, 2021

First, thank you for taking me to discover this feature of VSCode, I haven't opened it before. The link you provided is also very helpful, thank you so much!

I am going to learn how the code is colored when this feature is turned on. Then deal with the problem you mentioned and reply to you.

@Flo4604
Copy link

Flo4604 commented Jun 4, 2021

I completely agree, your theme is really nice and thank you for taking the time and effort to implement that feature as I too think it would be very useful

@fisheva
Copy link
Owner

fisheva commented Jun 6, 2021

After reading the Semantic Highlighting Guide, and using it in Eva Theme on my personal computer, I find it solves some problems, but brings some new problems.

I have always wanted to mark parameters in functions, the Syntax Highlighting couldn't do it, the Semantic Highlighting makes it.
123

But Semantic Highlighting has a rule that I feel not good. As long as it is turned on, some predefined rules will be enforced. Can't add exact rules from zero like Syntax Highlighting.
WX20210606-235904@2x

The Semantic Highlighting rule is overlaid on the Syntax Highlight rule. Moreover, the granularity of Semantic Highlighting is not as exact as Syntax Highlighting. One Semantic Highlighting rule can often cover multiple Syntax Highlighting rules.

I tried to write a Semantic Highlighting rule, without color, hoping to disable it, but failed.
WX20210607-005735@2x

And Semantic Highlighting rules do not support transparent colors.
WX20210607-011211@2x

Regardless of whether the semantic analysis of Semantic Highlighting is correct, this excessively intrusive change to the existing color system makes me cautiously turn it on.

So I won't open Semantic Highlighting in Eva Theme for the time being unless I can find a way to disable the predefined Semantic Highlighting rules and then add exact new rules one by one (Or when I have written all the Semantic Highlighting rules ?).

You can still force it on through the Semantic Highlight Enabled setting: true, then uses predefined rules.

@madrussa
Copy link
Author

madrussa commented Jun 7, 2021

Thanks for looking into this, I appreciate that this behaviour can be tricky. I look forward to more updates from you!

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

No branches or pull requests

3 participants