SAFE-Stack / SAFE-template

dotnet CLI template for SAFE project
MIT License
282 stars 88 forks source link

Format with Fantomas #428

Closed nojaf closed 3 years ago

nojaf commented 3 years ago

Hello,

Apologies for not opening an issue first, it might be easier to talk about this when seeing the impact. So, in short, I'd like to add Fantomas to this template in order to gain some more exposure.

Fantomas follows the Microsoft F# style guide by default so that would be the main selling point of having it here.

I could add some more things (FAKE targets, tweaks in configuration, add it to the minimal template, ...) but I wanted to hear first if you are interested in any of this.

Thank you for your time.

theimowski commented 3 years ago

Hi @nojaf - thanks for this. Yes I'd definitely like to see Fantomas in the template! Will review the changes in a bit. General question: I know there's a VS Code setting for Ionide that invokes Fantomas formatting when you save the file - can we add it to the PR as well? Also what about other editors - VS, Rider - do they have a setting like this?

nojaf commented 3 years ago

When it comes to editors, the story is a bit more complex. There is short cut in Rider Reformat Code and I believe there would be a similar thing in Visual Studio (@deviousasti any ideas?) However, these will format the code with a version of Fantomas that is bundled with the editor.

In Ionide this is a version of Fantomas found on NuGet. Visual Studio is using the source of Fantomas and this is tied closely to the master branch or latest stable. Rider uses a fork of Fantomas (that is only updated when they release).

So in terms of formatting, the FAKE targets might be a more interesting route to explore. Because there the repository controls the Fantomas version.

theimowski commented 3 years ago

Understood - I'm happy to get this in when review comments get addressed. I'd also like to get a 👍 from @isaacabraham @theprash @Krzysztof-Cieslak

deviousasti commented 3 years ago

Hey @nojaf, as you've rightly pointed out, FantomasVS deploys both versions - stable and bleeding edge which can be selected from.

There's also a format on save feature, and can be enabled from Options > F# Tools > Formatting.

I'd like to support a feature where if a Fantomas version is specified in dotnet's global.json tools, to use that if possible. That way there's likely to be less of a mismatch with formatting tests in the build pipeline.

theimowski commented 3 years ago

This is great, thanks again @nojaf