JetBrains/resharper-fsharp

Semantic highlighting of parameters

drhumlen opened this issue ยท 6 comments

This will make it easier to visually distinguish between the name of a function and its parameters when definining it.

 let somelongname barfoo someotherparam onelast = ....

Here it would be easier to spot that somelongname is the function name, and the rest are parameters.

It will also make it easier to distinguish between local let bindings/values and the parameters from the outside.

Other languages have this distinction (e.g. javascript). Imo it's even more useful in F# because there's no symbols ( ) look for.


It would also be useful to have semantic highlight when a function is called. So that when you invoke/call somelongname myparameter yetanotherparameter true, you could easily see that somelongname is being called, and the rest are just passed to it as params.

Simpler suggestion that can still give a lot of clarity:

Semantic highlighting of anything that is a function.

let add a b = a + b
let add5 = add 5
let sum = add5 10

add would be in italics here (since it's a function int -> int -> int).
As would add5 as it's also a function int -> int ... which can be really hard to see
sum is just a value (15 : int), so no special highlighting here.

let doOnX f x = f x

Here the f parameter is a function and should be in italic. x is ... an unknown generic type 'a should be formatted as normal(?).

Sometimes it's hard to distinguish functions from regular values in F#. Semantic highlighting could help out a lot here I think.

Thoughts?

Thoughts?

I like the idea to be able to highlight it differently. A separate highlighting for partial application would also be great to have.

I'm actually trying to get this thing done now but I guess it's kinda hard to do it with parameter as I still can't really find a "transition" between FSharpValue and FSharpParameter.

Looks kinda like this and I already like it because I can easily spot methods and funcs but it's still not ideal as I'm quite a fan of having parameters highlited differently too.

image

Simpler suggestion that can still give a lot of clarity:

Semantic highlighting of anything that is a function.

let add a b = a + b
let add5 = add 5
let sum = add5 10

add would be in italics here (since it's a function int -> int -> int).
As would add5 as it's also a function int -> int ... which can be really hard to see
sum is just a value (15 : int), so no special highlighting here.

let doOnX f x = f x

Here the f parameter is a function and should be in italic. x is ... an unknown generic type 'a should be formatted as normal(?).

Sometimes it's hard to distinguish functions from regular values in F#. Semantic highlighting could help out a lot here I think.

Thoughts?

Quoting myself here. I just discovered that this exact feature is implemented now. Not sure how long this feature has been here since none of the color schemes I've been using has differntiated functions from values (currently using "Rider Dark").

But this is working now, which is Very Nice ๐Ÿ‘ I'm closing the issue, but feel free to re-open if any of the other things discussed here is still relevant.

@drhumlen I'm glad you like it! We've decided to not change any defaults with new highlighting capabilities. I also have an option to highlight parameters differently too, but it's in my custom fcs build and my PR enabling this feature is basically ignored by dsyme. Can't help it. Also, values of literals are properly shown in tooltips now :)

@En3Tho: The icing on the cake would be an underline or something on a function that is being invoked/applied parameters to. Kinda like a b c in the picture you posted, but with an underline under a since it is invoked. That would be a solid 10/10.

But I'm really happy with the way it is now too. Great work! :D Maybe some day @dsyme will have some feedback on your PR