Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wider default fsharp_max_value_binding_width, also take width of pattern of binding into account #1936

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
#### 4.6.0-alpha-005

* Fix Idempotency problem when destructing a record inside a lambda argument. [#1922](https://github.com/fsprojects/fantomas/issues/1922)
* Update FCS to 41.0.0-preview.21472.3 [#1927](https://github.com/fsprojects/fantomas/pull/1927)

#### 4.6.0-alpha-004

* Initial Fantomas.Client release.

#### 4.6.0-alpha-003

* Fix Update record should indent from the curly brace instead of the identifier. [#1876](https://github.com/fsprojects/fantomas/issues/1876)

#### 4.6.0-alpha-002

* Fix Update style of lambda argument. [#1871](https://github.com/fsprojects/fantomas/issues/1871)

#### 4.6.0-alpha-001

* Update to FCS 40.0.1-preview.21352.5

#### 4.5.5 - 10/2021

* Improve: Provide more information when string merge failed. [#1904](https://github.com/fsprojects/fantomas/issues/1904)
Expand Down
64 changes: 43 additions & 21 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ let owner = "Anh-Dung Phan"
let tags =
"F# fsharp formatting beautifier indentation indenter"

let fantomasClientVersion = "0.3.1"

// (<solutionFile>.sln is built during the building process)
let solutionFile = "fantomas"
//// Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
Expand Down Expand Up @@ -168,7 +170,9 @@ Target.create
"src/Fantomas/bin"
"src/Fantomas/obj"
"src/Fantomas.CoreGlobalTool/bin"
"src/Fantomas.CoreGlobalTool/obj" ]
"src/Fantomas.CoreGlobalTool/obj"
"src/Fantomas.Client/bin"
"src/Fantomas.Client/obj" ]
|> List.iter Shell.cleanDir)

Target.create
Expand All @@ -180,13 +184,20 @@ Target.create
let file =
sprintf "src/%s/%s.fsproj" project project

Xml.poke file "Project/PropertyGroup/Version/text()" version
Xml.poke
file
"Project/PropertyGroup/Version/text()"
(if project = "Fantomas.Client" then
fantomasClientVersion
else
version)

setProjectVersion "Fantomas"
setProjectVersion "Fantomas.CoreGlobalTool"
setProjectVersion "Fantomas.CoreGlobalTool.Tests"
setProjectVersion "Fantomas.Tests"
setProjectVersion "Fantomas.Extras")
setProjectVersion "Fantomas.Extras"
setProjectVersion "Fantomas.Client")

// --------------------------------------------------------------------------------------
// Build library & test project
Expand Down Expand Up @@ -241,7 +252,11 @@ Target.create
{ defaultArgs with
Properties =
[ "Title", project
"PackageVersion", nugetVersion
"PackageVersion",
(if project = "Fantomas.Client" then
fantomasClientVersion
else
nugetVersion)
"Authors", (String.Join(" ", authors))
"Owners", owner
"PackageRequireLicenseAcceptance", "false"
Expand All @@ -263,7 +278,8 @@ Target.create

pack "Fantomas"
pack "Fantomas.Extras"
pack "Fantomas.CoreGlobalTool")
pack "Fantomas.CoreGlobalTool"
pack "Fantomas.Client")

// This takes the list of external projects defined above, does a git checkout of the specified repo and tag,
// tries to build the project, then reformats with fantomas and tries to build the project again. If this fails
Expand Down Expand Up @@ -349,25 +365,31 @@ Target.create "TestExternalProjects" (fun _ -> testExternalProjects externalProj
Target.create "TestExternalProjectsFailing" (fun _ -> testExternalProjects externalProjectsToTestFailing)

// Workaround for https://github.com/fsharp/FAKE/issues/2242
let pushPackage additionalArguments =
Directory.EnumerateFiles("bin", "*.nupkg", SearchOption.TopDirectoryOnly)
|> Seq.iter
(fun nupkg ->
let args =
[ yield "push"
yield! additionalArguments
yield nupkg ]
let pushPackage nupkg =
let args = [ yield "push"; yield nupkg ]

CreateProcess.fromRawCommand "dotnet" ("paket" :: args)
|> CreateProcess.disableTraceCommand
|> CreateProcess.redirectOutput
|> CreateProcess.withOutputEventsNotNull Trace.trace Trace.traceError
|> CreateProcess.ensureExitCode
|> Proc.run
|> ignore)
CreateProcess.fromRawCommand "dotnet" ("paket" :: args)
|> CreateProcess.disableTraceCommand
|> CreateProcess.redirectOutput
|> CreateProcess.withOutputEventsNotNull Trace.trace Trace.traceError
|> CreateProcess.ensureExitCode
|> Proc.run
|> ignore


Target.create "Push" (fun _ -> pushPackage [])
Target.create
"Push"
(fun _ ->
Directory.EnumerateFiles("bin", "*.nupkg", SearchOption.TopDirectoryOnly)
|> Seq.filter (fun nupkg -> not (nupkg.Contains("Fantomas.Client")))
|> Seq.iter pushPackage)

Target.create
"PushClient"
(fun _ ->
Directory.EnumerateFiles("bin", "Fantomas.Client.*.nupkg", SearchOption.TopDirectoryOnly)
|> Seq.tryExactlyOne
|> Option.iter pushPackage)

let git command =
CreateProcess.fromRawCommandLine "git" command
Expand Down
24 changes: 24 additions & 0 deletions docs/Daemon mode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Fantomas Daemon mode

## Introduction

As part of the `4.6` release, we've introduced a new feature where end-user can control the version of Fantomas that is being used inside an IDE.
In previous iterations, the editor tooling would typically reference the [Fantomas](https://www.nuget.org/packages/Fantomas) or [Fantomas.Extras](https://www.nuget.org/packages/Fantomas.Extras) nuget package and use the [CodeFormatter](../src/Fantomas/CodeFormatter.fsi) api to handle formatting.
The major drawback of this approach is that shared [FCS](https://www.nuget.org/packages/FSharp.Compiler.Service/) dependency needed to be exactly the same.
So the editor is in control of which version of Fantomas is being used.
Each version of Fantomas theoretically can have a different outcome as the style guides may have changed over time.

## Solution

To tackle this problem, we introduce two new concepts: `--daemon` mode for the [fantomas-tool](https://www.nuget.org/packages/fantomas-tool) and [Fantomas.Client](https://www.nuget.org/packages/Fantomas.Client).
`--daemon` would launch the commandline application as a sort of [LSP server](https://microsoft.github.io/language-server-protocol/) and `Fantomas.Client` could connect to this and proxy format requests.
Editor tooling would be able to launch your pinned version of `fantomas-tool` as a daemon service and interact with it outside-of-process.

## End-user impact

End-users don't have to worry about `Fantomas.Client` or the `--daemon` flag. They only need to install a compatible version of `fantomas-tool`.
Be it locally or globally. The first compatible version is `4.6.0-alpha-004`, all higher version should work as well.
Local versions have precedence over the global version.

The nice thing about this approach is that you can upgrade Fantomas at your own pace.
When new versions drop, you can dedicate a separate commit in source control and it won't interfere with your other commits.
18 changes: 12 additions & 6 deletions docs/Documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ For the overview how to use the tool, you can type the command
dotnet fantomas --help

```
USAGE: dotnet fantomas [--help] [--recurse] [--force] [--profile] [--fsi <string>] [--stdin] [--stdout] [--out <string>] [--check] [--version] [<string>...]
USAGE: dotnet fantomas [--help] [--recurse] [--force] [--profile] [--fsi <string>] [--stdin] [--stdout] [--out <string>] [--check] [--daemon] [--version] [<string>...]

INPUT:

Expand All @@ -31,9 +31,10 @@ OPTIONS:
--profile Print performance profiling information.
--fsi <string> Read F# source from stdin as F# signatures.
--stdin Read F# source from standard input.
--stdout Write the formatted source code to standard output.
--stdout Write the formatted source code to standard output.
--out <string> Give a valid path for files/folders. Files should have .fs, .fsx, .fsi, .ml or .mli extension only.
--check Don't format files, just check if they have changed. Exits with 0 if it's formatted correctly, with 1 if some files need formatting and 99 if there was an internal error
--daemon Daemon mode, launches an LSP-like server to can be used by editor tooling.
--version, -v Displays the version of Fantomas
--help display this list of options.

Expand Down Expand Up @@ -80,6 +81,10 @@ Or usage with `find` on unix:

`find my-project/ -type f -name "*.fs" -not -path "*obj*" | xargs dotnet fantomas --check`

### Daemon mode

`--daemon` should not be used directly by end-users. Learn more about this feature in the [Daemon mode documentation](./Daemon%20mode.md)

## Configuration

Fantomas ships with a series of format options.
Expand Down Expand Up @@ -110,7 +115,7 @@ fsharp_record_multiline_formatter=character_width
fsharp_max_array_or_list_width=40
fsharp_max_array_or_list_number_of_items=1
fsharp_array_or_list_multiline_formatter=character_width
fsharp_max_value_binding_width=40
fsharp_max_value_binding_width=80
fsharp_max_function_binding_width=40
fsharp_max_dot_get_expression_width=50
fsharp_multiline_block_brackets_on_same_column=false
Expand Down Expand Up @@ -699,8 +704,9 @@ let myArray =

### fsharp_max_value_binding_width

Control the maximum width for which let and member value bindings should be in one line.
Default = 40.
Control the maximum expression width for which let and member value/property bindings should be in one line.
The width is that of the pattern for the binding plus the implementating expression but not the keywords (e.g. "let").
Default = 80.

`defaultConfig`

Expand All @@ -724,7 +730,7 @@ type MyType() =

### fsharp_max_function_binding_width

Control the maximum width for which let and member function bindings should be in one line.
Control the maximum width for which function and member bindings should be in one line.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Member bindings will look at two settings currently.
Example.

Default = 40.

`defaultConfig`
Expand Down
47 changes: 35 additions & 12 deletions fantomas.sln
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
# Visual Studio Version 17
VisualStudioVersion = 17.0.31825.309
MinimumVisualStudioVersion = 15.0.26124.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".paket", ".paket", "{B570C54C-2FEA-4A94-A8C5-FD4157A94DE7}"
ProjectSection(SolutionItems) = preProject
paket.dependencies = paket.dependencies
EndProjectSection
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fantomas", "src\Fantomas\Fantomas.fsproj", "{7EA16279-A5F1-4781-A343-4375A04BCE6F}"
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fantomas", "src\Fantomas\Fantomas.fsproj", "{7EA16279-A5F1-4781-A343-4375A04BCE6F}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this mean? Or did this happen automatically by VS?

EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fantomas.Tests", "src\Fantomas.Tests\Fantomas.Tests.fsproj", "{DED76E41-B89F-47BA-84C5-3AB0BECFA767}"
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fantomas.Tests", "src\Fantomas.Tests\Fantomas.Tests.fsproj", "{DED76E41-B89F-47BA-84C5-3AB0BECFA767}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fantomas.CoreGlobalTool", "src\Fantomas.CoreGlobalTool\Fantomas.CoreGlobalTool.fsproj", "{DC08805B-C6E2-43F3-B381-E60EE88A079D}"
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fantomas.CoreGlobalTool", "src\Fantomas.CoreGlobalTool\Fantomas.CoreGlobalTool.fsproj", "{DC08805B-C6E2-43F3-B381-E60EE88A079D}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fantomas.CoreGlobalTool.Tests", "src\Fantomas.CoreGlobalTool.Tests\Fantomas.CoreGlobalTool.Tests.fsproj", "{DEDE6968-0BE8-4415-9262-8355B82AF2C0}"
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fantomas.CoreGlobalTool.Tests", "src\Fantomas.CoreGlobalTool.Tests\Fantomas.CoreGlobalTool.Tests.fsproj", "{DEDE6968-0BE8-4415-9262-8355B82AF2C0}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fantomas.Benchmarks", "src\Fantomas.Benchmarks\Fantomas.Benchmarks.fsproj", "{B6BC63D5-410D-4DBB-9D45-5638F20BD09B}"
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fantomas.Benchmarks", "src\Fantomas.Benchmarks\Fantomas.Benchmarks.fsproj", "{B6BC63D5-410D-4DBB-9D45-5638F20BD09B}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fantomas.Extras", "src\Fantomas.Extras\Fantomas.Extras.fsproj", "{4088FF76-1DB7-4E68-80FE-E851CE6701AC}"
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fantomas.Extras", "src\Fantomas.Extras\Fantomas.Extras.fsproj", "{4088FF76-1DB7-4E68-80FE-E851CE6701AC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{29F22904-C9E0-40AA-B971-9AE377C17F59}"
ProjectSection(SolutionItems) = preProject
docs\Documentation.md = docs\Documentation.md
docs\Formatting-Elmish-code.md = docs\Formatting-Elmish-code.md
docs\FormattingConventions.md = docs\FormattingConventions.md
docs\index.html = docs\index.html
EndProjectSection
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fantomas.Client", "src\Fantomas.Client\Fantomas.Client.fsproj", "{AA895F94-CCF2-4FCF-A9BB-E16987B57535}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -29,9 +39,6 @@ Global
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7EA16279-A5F1-4781-A343-4375A04BCE6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7EA16279-A5F1-4781-A343-4375A04BCE6F}.Debug|Any CPU.Build.0 = Debug|Any CPU
Expand Down Expand Up @@ -105,7 +112,23 @@ Global
{4088FF76-1DB7-4E68-80FE-E851CE6701AC}.Release|x64.Build.0 = Release|Any CPU
{4088FF76-1DB7-4E68-80FE-E851CE6701AC}.Release|x86.ActiveCfg = Release|Any CPU
{4088FF76-1DB7-4E68-80FE-E851CE6701AC}.Release|x86.Build.0 = Release|Any CPU
{AA895F94-CCF2-4FCF-A9BB-E16987B57535}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AA895F94-CCF2-4FCF-A9BB-E16987B57535}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AA895F94-CCF2-4FCF-A9BB-E16987B57535}.Debug|x64.ActiveCfg = Debug|Any CPU
{AA895F94-CCF2-4FCF-A9BB-E16987B57535}.Debug|x64.Build.0 = Debug|Any CPU
{AA895F94-CCF2-4FCF-A9BB-E16987B57535}.Debug|x86.ActiveCfg = Debug|Any CPU
{AA895F94-CCF2-4FCF-A9BB-E16987B57535}.Debug|x86.Build.0 = Debug|Any CPU
{AA895F94-CCF2-4FCF-A9BB-E16987B57535}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AA895F94-CCF2-4FCF-A9BB-E16987B57535}.Release|Any CPU.Build.0 = Release|Any CPU
{AA895F94-CCF2-4FCF-A9BB-E16987B57535}.Release|x64.ActiveCfg = Release|Any CPU
{AA895F94-CCF2-4FCF-A9BB-E16987B57535}.Release|x64.Build.0 = Release|Any CPU
{AA895F94-CCF2-4FCF-A9BB-E16987B57535}.Release|x86.ActiveCfg = Release|Any CPU
{AA895F94-CCF2-4FCF-A9BB-E16987B57535}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DEBFC920-A647-4859-890D-B59793D27594}
EndGlobalSection
EndGlobal
26 changes: 23 additions & 3 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ source https://api.nuget.org/v3/index.json
framework: netstandard2.0, net5.0, netcoreapp3.1
storage: none

nuget FSharp.Core
nuget FSharp.Compiler.Service ~> 39.0
nuget FSharp.Core 6.0.0-beta.21472.3
nuget FSharp.Compiler.Service 41.0.0-preview.21472.3
nuget FsUnit
nuget FsCheck
nuget Microsoft.NET.Test.Sdk 16.9.1
Expand All @@ -15,6 +15,7 @@ nuget Argu
nuget BenchmarkDotNet
nuget editorconfig
nuget MAB.DotIgnore 3.0.2
nuget Microsoft.SourceLink.GitHub copy_local: true

github: fsprojects/fantomas:829faa6ba834f99afed9b4434b3a1680536474b2 src/Fantomas/CodePrinter.fs

Expand All @@ -23,11 +24,30 @@ group build
source https://api.nuget.org/v3/index.json

nuget Microsoft.Azure.Cosmos.Table
nuget FSharp.Core ~> 5
nuget Fake.Core.ReleaseNotes
nuget Fake.Core.Xml
nuget Fake.DotNet.Cli
nuget Fake.DotNet.Paket
nuget Fake.Tools.Git
nuget Fake.Core.Process
nuget Fake.Core.Target
nuget MSBuild.StructuredLogger 2.1.500
nuget MSBuild.StructuredLogger 2.1.500

group tool
storage: none
source https://api.nuget.org/v3/index.json

nuget FSharp.Core 6.0.0-beta.21472.3
nuget Argu
nuget StreamJsonRpc
nuget Thoth.Json.Net
nuget SerilogTraceListener

group client
storage: none
source https://api.nuget.org/v3/index.json

nuget FSharp.Core 5
nuget StreamJsonRpc
nuget Microsoft.SourceLink.GitHub copy_local: true
Loading