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

Syntax highlighting: symbols #23

Closed
kubaPod opened this issue Oct 25, 2022 · 3 comments
Closed

Syntax highlighting: symbols #23

kubaPod opened this issue Oct 25, 2022 · 3 comments

Comments

@kubaPod
Copy link

kubaPod commented Oct 25, 2022

Hi, I decided to give it a try. Is there any documentation about customizing styles used for WL files? Especially to enable highlighting without affecting the whole vs-code colors with the BrentonWL theme?

That was the side note, the main issue is here:

image

  • UpdateTarget has two colors
  • System symbols like Attributes and HoldAll have different coloring
  • Square brackets have orange, pink and blue coloring, is it correct? Maybe there's logic behind it but I'd prefer a single color anyway
  • notice bin[root, key] = {} line, the bin is pale blue like a full name symbols e.g. FrontEnd\UpdateDynamicObjects`

I guess most of the I could fix with custom theme but maybe they manifest something that requires fixing so I decided to post it.

Thanks for your work on code tools.
Best

@bostick
Copy link

bostick commented Oct 25, 2022

A lot of these questions are about VSCode in general, and not this extension specifically, but I will try to respond.

For the side note:

I googled "VSCode customize color theme" and this:

https://code.visualstudio.com/docs/getstarted/themes#_customizing-a-color-theme

may be helpful for you.

It is an open issue for VSCode to enable different themes for different filetypes:

microsoft/vscode#20652

The different colors for UpdateTarget are because the WL syntax highlighting has special handling of function application syntax.

Symbols like foo in foo[] are highlighted different than just foo by itself.

But this does not extend to x // foo syntax because it would be too cumbersome to implement inside the syntax highlighting rules.

It is important to understand that syntax highlighting is only an approximation to the actual semantics of the language.

No real parsing or analysis is being done; only tokens are being examined with regexes.

Attributes is a function and HoldAll is a constant (for lack of a better term for symbols that are not functions). That's why they are colored differently.

Square brackets have different colors because that is what VSCode does:

https://code.visualstudio.com/blogs/2021/09/29/bracket-pair-colorization

A very useful command is available on the command palette:

Developer: Inspect Editor Tokens and Scope

This opens a popup where the cursor is and gives information about the currently selected token:

the various scopes and the specific color that it has

Also, it looks like you do not have semantic highlighting enabled.

If you turn on the setting for Wolfram: Semantic tokens, you will see things like Module variables being colored differently and other nice additions.

@kubaPod
Copy link
Author

kubaPod commented Oct 26, 2022

@bostick Thanks for feedback, indeed after posting I noticed that my problem's nature is mostly vscode related. I will try to come up with a custom theme then.

Yes, I was confused about Module variables as well because I did enable it but maybe something went of in chaos of trying to make it work.

Now I am getting somewhere:

image

An issue I faced is that I can't distinguish With variables/parameters from function patterns:

image
image

Btw, it became a discussion so you can close this issue at any time if you feel like it.

@bostick
Copy link

bostick commented Oct 26, 2022

Right, I gave both With variables/parameters and function patterns the scope of variable.parameter.

I could certainly work to give them different scopes, since it seems like you are interested in giving them different colors (I presume).

(closing but feel free to respond)

@bostick bostick closed this as completed Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants