ionide-vscode-fsharp icon indicating copy to clipboard operation
ionide-vscode-fsharp copied to clipboard

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

Open MangelMaxime opened this issue 2 years ago • 5 comments

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

MangelMaxime avatar Sep 23 '21 13:09 MangelMaxime

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:!

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 avatar Sep 23 '21 14:09 baronfel

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:

  • what other syntax-level elements do we want to tag?
  • are these mappings the best we can do?
  • if we need more types of values, what commonly-used scopes are used in various themes that we might be able to piggy-back on top of?

baronfel avatar Sep 24 '21 19:09 baronfel

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 avatar Sep 24 '21 19:09 baronfel

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)....

baronfel avatar Sep 24 '21 20:09 baronfel