ionide / ionide-vscode-fsharp

VS Code plugin for F# development
http://ionide.io
MIT License
860 stars 279 forks source link

Syntax highlight: Should the "number symbol" be of the same color as the number? #1590

Open MangelMaxime opened 3 years ago

MangelMaxime commented 3 years ago

Hello,

when writing let x = 43s the s is not of the same color as the numbers.

image

I think it would looks better if it was having an uniform color. What do you think?

Same goes for unit16, etc.

image

open-collective-bot[bot] commented 3 years ago

Hey @MangelMaxime :wave:,

Thanks for backing our project. If possible, We will handle your issue with priority support. To make sure we don't forget how special you are, we added a backer label to your issue.

Thanks again for backing us :tada:!

baronfel commented 3 years ago

We don't currently get any scope information from FCS for the literals or suffixes in the values, so if you wanted to fix this it would require a change to the semantic classification services upstream.

Right now these are done based off of the typecheck resolutions but it would likely need more sources of information to be able to include syntax from the syntax tree instead of just the typed tree.

baronfel commented 3 years ago

I did a super-basic syntax walker + constant-value scope, and initial results are promising:

image

What you're seeing here is that the whole constant value, numeric and format string, is tagged with the 'SemanticClassificationType.Value' DU case, and this result is fused with the other semantic highlighting that we get from the typecheck results. The current version of FCS we use gives us a relatively limited number of SemanticClassifivationType DU cases, but FCS 40 exposes this as an enum that we can use more flexibly.

Next questions would be:

baronfel commented 3 years ago

Right now this is implemented in FSAC, but this kind of AST walker, unlike the position-directed traversal that's already there, would be a prime candidate for pushing into FCS.

baronfel commented 3 years ago

The upshot of this syntax-level colorization is we may not need as much/anything in the textmate grammars. Especially if we split up tokens from parsing (which is fast) and checking (which is slow)....