fantomas-for-vs
fantomas-for-vs copied to clipboard
Fantomas < 5.0 breaks nested lists
On latest F# Formatter
extension for VS2022, formatting this
let webApp =
choose
[ GET
>=> choose [
route "/" >=> indexHandler "world"
routef "/hello/%s" indexHandler ]
setStatusCode 404 >=> text "Not Found" ]
becomes this
let webApp =
choose
[ GET
>=> choose [ route "/" >=> indexHandler "world"; routef "/hello/%s" indexHandler ]
note the setStatusCode ...
item and closing ]
is dropped.
To be clear, I mean this is fixed by upstream fantomas
but fantomas-for-vs
still ships 4.5.1.
To be clear, I mean this is fixed by upstream
fantomas
butfantomas-for-vs
still ships 4.5.1.
I think you can upgrade Fantomas tool and the extension will pick it up.
Hmm. I updated to 5.2.1 locally but it doesn't seem to get picked up by the VS2022 extension. :/
Hmm... I would check you have the latest extension version. I think it doesn't get autoupdates.
You can see the detected version if you induce the formatting to fail, (for example format selection on a empty line)
I actually can't induce my version to fail on a blank line. It never shows an error message. F# Formatting
is not even available in the dropdown.
I did notice that when I tried to update using dotnet
commands in my project (the giraffe example) it complained that fantomas 5.2.1 can't be installed with net5.0
, it requires net6.0
. Then I changed the framework to net6.0
and rebuilt and it complains again that it can't work with net6.0
, and that it needs net6.0
(😕 )
Sorry, this is all pretty new stuff to me coming from Linux-land.
Hello,
There might be some confusion between the framework and SDK versions.
What do you get when you run dotnet --version
? And do you have a global.json
file?
dotnet --version
yields 7.0.200
.
Which is interesting because NET7.0 is not available as an option in the VS2022 project settings dropdown.
My project does not have a global.json
file.
Ok, and to be clear you've installed Fantomas in your local folder via:
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local fantomas --version 5.2.1
?
What does dotnet tool list
give you?
Just did those. Now shows this:
dotnet tool list
Package Id Version Commands Manifest
------------------------------------------------------------------------------------------------------------
fantomas 5.2.1 fantomas C:\Users\mbac3\projects\giraffe-example\.config\dotnet-tools.json
So, closing and restarting VS2022 and reformatting the code above still shows the buggy behavior.
Either this is still using an old version somehow (not sure how to diagnose further), or perhaps the problem above is not actually fixed, or there is a different issue.
Let me dig further.
Ok, thanks. And to double-check, formatting the file using the command line does not give the problem right? dotnet fantomas ./folder/file.fs
Yup.
Running from CLI
Running from VS2022
Before format
After format
🤔
Hmm, weird. Could you create a script (f.ex script.fsx
) (next to minimal.fs
) with:
#r "nuget: Fantomas.Client, 0.8.0"
open System
open System.IO
open Fantomas.Client.Contracts
open Fantomas.Client.LSPFantomasService
let service : FantomasService = new LSPFantomasService()
// this path needs to be absolute and exist
let filePath = Path.Combine(__SOURCE_DIRECTORY__, "minimal.fs")
service.VersionAsync(filePath).Result
|> printfn "%A"
And execute that by running dotnet fsi script.fsx
?
This will run the same mechanic that is used inside the IDE plugin to detect your Fantomas version.
I'm wondering what kind of response you will get.
Sure.
cat .\script.fsx
#r "nuget: Fantomas.Client, 0.8.0"
open System
open System.IO
open Fantomas.Client.Contracts
open Fantomas.Client.LSPFantomasService
let service : FantomasService = new LSPFantomasService()
// this path needs to be absolute and exist
let filePath = Path.Combine(__SOURCE_DIRECTORY__, "minimal.fs")
service.VersionAsync(filePath).Result
|> printfn "%A"
dotnet fsi .\script.fsx
{ Code = 5
FilePath = "C:\Users\mbac3\projects\giraffe-example\minimal.fs"
Content = Some "5.2.1+9f769d838c9cb1a07dc0c6616871f5bebe91bb40"
SelectedRange = None
Cursor = None }
Thank you, btw.
Thanks, good to see that this part is working out. @deviousasti I believe this might be a problem in the plugin. Is there any way @mbacarella can get some logs of what happens in the plugin?