Stream: t-compiler/wg-rls-2.0

Topic: semantic highlighting


Pascal (May 23 2019 at 12:02, on Zulip):

hey, i wanted to look into semantic highlighting a bit (just because i was curious). i assume i'll need to get some kind of resolved identifiers map? building on the code from https://github.com/rust-analyzer/rust-analyzer/pull/1305 all i can get for bindings is that their kind is MACRO_CALL. what am I missing? :)

Laurențiu Nicola (May 23 2019 at 12:04, on Zulip):

See https://github.com/rust-analyzer/rust-analyzer/pull/1305/files#diff-7bd880cade5b808a957f2da2c32f6ecdR52

Laurențiu Nicola (May 23 2019 at 12:04, on Zulip):

You should get a reference to the macro definition

matklad (May 23 2019 at 12:04, on Zulip):

Hm, why macro calls?

matklad (May 23 2019 at 12:05, on Zulip):

I think you should check this variant: https://github.com/rust-analyzer/rust-analyzer/pull/1311/files#diff-6a30d8b895db7e4b6fba39666fe0aaabR13

matklad (May 23 2019 at 12:05, on Zulip):

Basically, if two AstPtr<ast::Pat> are the same, that's the same binding, and you can color it in the same color

matklad (May 23 2019 at 12:05, on Zulip):

does this make sense?

Pascal (May 23 2019 at 12:06, on Zulip):

re macros: I have no clue, I just wanted to know what node kind to match on so i added format!("{:?}", node.kind()) and got MACRO_CALL :shrug:

Laurențiu Nicola (May 23 2019 at 12:07, on Zulip):

Don't look at node.kind(), look at the result of classify_name_ref

Pascal (May 23 2019 at 12:07, on Zulip):

ah, so you're saying it should be in the NAME_REF case as well?

Laurențiu Nicola (May 23 2019 at 12:08, on Zulip):

NAME_REF is a reference to a ..symbol, including macros, but node doesn't contain that information

Laurențiu Nicola (May 23 2019 at 12:08, on Zulip):

NAME is a symbol declaration (or definition)

Laurențiu Nicola (May 23 2019 at 12:12, on Zulip):

What classify_name_ref does is it takes a NAME_REF and gives you back the definition of that name, like a MacroByExampleDef for macros. That ends up wrapping an AstId, which could presumably be hashed or used otherwise to assign a color

Pascal (May 23 2019 at 12:12, on Zulip):

i think i'm a bit confused how that match node.kind() works :D i'll play around with it a bit

Pascal (May 23 2019 at 12:12, on Zulip):

thanks

Laurențiu Nicola (May 23 2019 at 12:12, on Zulip):

If you're using RA in VS Code, try the "Show Syntax Tree" command

Laurențiu Nicola (May 23 2019 at 12:12, on Zulip):

node is just an AST node, without any semantic information

Pascal (May 23 2019 at 20:08, on Zulip):

super trivial first version just to see if it's doable: https://github.com/rust-analyzer/rust-analyzer/pull/1319

Pascal (May 25 2019 at 11:34, on Zulip):

@matklad hm, testing highlighting via html output will mean that for the rainbow stuff i'll need to figure out how best to get the color calc code in there. it depends on a seedable rng which is an external dependency but i might just inline it

matklad (May 25 2019 at 11:35, on Zulip):

For testing, you can only set the css class to hash, without adding any JS magic

Pascal (May 25 2019 at 11:35, on Zulip):

nah, that's too boring

matklad (May 25 2019 at 11:39, on Zulip):

Hm, you can also generate css itself on the server-side :thinking:

Pascal (May 25 2019 at 11:42, on Zulip):

good idea! that also makes implementing a --rainbow flag easier

std::Veetaha (Mar 10 2020 at 16:30, on Zulip):

@matklad , @Jeremy Kolb IIRC semantic highlighting landed to stable vscode 1.43 (at least Typescript langua server now has this enabled by default). Should we REMOVE CODE that implements old highlighting?

matklad (Mar 10 2020 at 16:32, on Zulip):

Yup!

matklad (Mar 10 2020 at 16:32, on Zulip):

Though we need to verify that they actually stabilized the prposed API...

std::Veetaha (Mar 10 2020 at 16:32, on Zulip):

Triggered

matklad (Mar 10 2020 at 16:32, on Zulip):

Can't typescript plugin use more API than other plugins?

std::Veetaha (Mar 10 2020 at 16:41, on Zulip):

I don't think so even Though typescript extension is bundled with vscode

Jeremy Kolb (Mar 10 2020 at 16:55, on Zulip):

I tried this yesterday after bumping the engine version and it still failed. I believe semantic tokens is still proposed in vscode

Jeremy Kolb (Mar 10 2020 at 16:59, on Zulip):

I believe that this iteration will see range support added so hopefully the feature will be stabilized

std::Veetaha (Mar 10 2020 at 17:03, on Zulip):

Hmm, so TypeScript does have a Carte Blanche for using proposed APIs?

Jeremy Kolb (Mar 10 2020 at 17:10, on Zulip):

I believe so because it's distributed as part of vscode

Jeremy Kolb (Mar 10 2020 at 17:12, on Zulip):

@std::Veetaha https://github.com/microsoft/vscode/tree/master/extensions/typescript-language-features

matklad (Mar 10 2020 at 17:15, on Zulip):

https://github.com/microsoft/vscode/blob/4e605ec54a58213b2db2e0b2c2d19e17833a46bb/extensions/typescript-language-features/package.json#L11

Jeremy Kolb (Mar 10 2020 at 17:25, on Zulip):

I think all of those extensions have it set

Jeremy Kolb (Mar 10 2020 at 17:27, on Zulip):

https://github.com/microsoft/vscode/blob/04c9b01affe9201c3c96533aba56639e810e940f/src/vs/workbench/contrib/welcome/common/viewsWelcomeContribution.ts#L43

Jeremy Kolb (Mar 10 2020 at 17:27, on Zulip):

I think that's the check

std::Veetaha (Mar 14 2020 at 20:43, on Zulip):

@Jeremy Kolb , is it necessary to start --enable-proposed-api matklad.rust-analyzer even on code-insiders ?

matklad (Mar 14 2020 at 20:52, on Zulip):

Yes

std::Veetaha (Mar 14 2020 at 21:24, on Zulip):

self is assigned a keyword.control token kind, I think this is a bug?

std::Veetaha (Mar 14 2020 at 21:24, on Zulip):

image.png

matklad (Mar 15 2020 at 10:32, on Zulip):

I think it's a bug in the visualisation, compare the output for if and self

std::Veetaha (Mar 16 2020 at 21:45, on Zulip):

Hey guys, is there a way to create a separate semantic tokens color customization rules for different languages? e.g. in typescript member with delcaration modifier is a method declaration (but property with declaration is for property declarations). But in Rust we use member with declaration modifier as property declaration and these conflict in my eyes ...

matklad (Mar 16 2020 at 21:50, on Zulip):

Good question. I think, in the conv layer, we should add “rust” modifier to
all tokens.

std::Veetaha (Mar 16 2020 at 22:16, on Zulip):

Hmm, there is none as per vscode inspect tool:
image.png

std::Veetaha (Mar 16 2020 at 22:19, on Zulip):

There just is no way to express the intention for filtering particular languages in vscode's editor.tokenColorCustomizationsExperimental config

matklad (Mar 17 2020 at 08:11, on Zulip):

There's none because we should add that modifier, it's not there yet

std::Veetaha (Mar 17 2020 at 10:07, on Zulip):

Ah, I just interprededshould as already

Jeremy Kolb (Mar 17 2020 at 11:56, on Zulip):

Isn't that what https://github.com/microsoft/vscode/wiki/Semantic-Highlighting-Overview#token-classification is for?

std::Veetaha (Mar 17 2020 at 20:01, on Zulip):

There is no word about specifying the language name as a modifier, e.g. TypeScript doesn't add typescript modifier. I think this is a hole in the protocol. There must be some strictly-defined way to set the language of the token (taking into account quasi quotation this has to be on the token level)

Jeremy Kolb (Mar 17 2020 at 23:44, on Zulip):

Hm. The semantic highlighting setting can be controlled by language (that is explicitly called out). I think they infer the language based on the provider or whatever

Jeremy Kolb (Mar 17 2020 at 23:46, on Zulip):

Somewhere I read that the editor.semanticHighlighting.enabled setting can become lang.semanticHighlighting.enabled

Jeremy Kolb (Mar 17 2020 at 23:49, on Zulip):

doesn't answer your question though...

Jeremy Kolb (Mar 17 2020 at 23:49, on Zulip):

you may want to open an issue in the vscode-languageclient repo

Jeremy Kolb (Mar 26 2020 at 14:06, on Zulip):

This was just merged into vscode: https://github.com/microsoft/vscode/pull/93378

Jeremy Kolb (Mar 26 2020 at 14:07, on Zulip):

I think that may address the per language concern?

Jeremy Kolb (Mar 26 2020 at 14:07, on Zulip):

Sorry I have 0 time to work on anything lately

std::Veetaha (Mar 26 2020 at 18:53, on Zulip):

Thanks, Jeremy, this is what I wanted

Laurențiu Nicola (Apr 23 2020 at 06:06, on Zulip):

Is this normal? Why are there scopes for so many languages?

image.png

image.png

matklad (Apr 23 2020 at 08:25, on Zulip):

Bad UI

matklad (Apr 23 2020 at 08:25, on Zulip):

This is the header of the rule which matches the scope

matklad (Apr 23 2020 at 08:26, on Zulip):

IE, this is a rule from the color theme, and, among the N things there, there's one that matches default mapping of semantic tokens to textmate scopes

Laurențiu Nicola (Apr 23 2020 at 08:59, on Zulip):

Ah, it's CSS

apiraino (Apr 23 2020 at 10:24, on Zulip):

Laurențiu Nicola said:

Ah, it's CSS

still funny, imo :-)

Last update: Sep 22 2020 at 01:15UTC