Giter Club home page Giter Club logo

vscode-fantomas-fmt's Introduction

fantomas-fmt README

vscode extension that uses the awesome fantomas to format fsharp files.

Requirements

  • dotnet core 2.1
  • fantomas-tool
    If missing, the extension will try to install it automatically. In case of problem, try to install it manually by running the following command:
    dotnet tool install fantomas-tool -g
    

Extension Settings

This extension contributes the following settings:

  • fantomas.indent: set number of spaces for indentation (default = 4). The value should be between 1 and 10.
  • fantomas.pageWidth: set the column where we break to new lines (default = 80). The value should be at least 60.
  • fantomas.semicolonEOL: enable semicolons at the end of line (default = false).
  • fantomas.noSpaceBeforeArgument: disable spaces before the first argument of functions when there are parenthesis (default = true). For methods and constructors, there are never spaces regardless of this option.
  • fantomas.spaceBeforeColon: enable spaces before colons (default = false).
  • fantomas.noSpaceAfterComma: disable spaces after commas (default = true).
  • fantomas.noSpaceAfterSemiColon: disable spaces after semicolons (default = true).
  • fantomas.indentOnTryWith: enable indentation on try/with block (default = false).
  • fantomas.noSpaceAroundDelimiter: disable spaces after starting and before ending of lists, arrays, sequences and records (default = true).
  • fantomas.keepNewlineAfter: set the max length of any expression in an if expression before formatting on multiple lines (default = 40).
  • fantomas.maxIfThenElseShortWidth: set the max length of any expression in an if expression before formatting on multiple lines (default = 40).
  • fantomas.strictMode: enable strict mode (ignoring directives and comments and printing literals in canonical forms) (default = false).

Troubleshooting

  1. Format on save is not working
    Try to change setting "editor.formatOnSaveTimeout" to a higher value than 750 (e.g. 3000)

License

MIT ยฉ Paolo Dellepiane

vscode-fantomas-fmt's People

Contributors

dependabot[bot] avatar fangyi-zhou avatar leizongmin avatar akoslukacs avatar

Stargazers

cryptofxro avatar Joshua Passos avatar Andrejs Agejevs avatar Jin-Wook Chung avatar Paolo Dellepiane avatar  avatar Edon Gashi avatar  avatar Sean Powell avatar zakaluka avatar Bo avatar  avatar Johny Xu avatar Gregor Beyerle avatar Sebastian Brandt avatar Dag Brattli avatar Tobias Burger avatar

Watchers

James Cloos avatar

vscode-fantomas-fmt's Issues

Unable to format code on Linux - `./fantomas: No such file or directory`

Environment

VsCode on Fedora Linux 33, with fantomas installed using dotnet tool install -g fantomas-tool

Issue

Triggering Fantomas with Ctrl-Shift-P >Format document gives the following error

[fantomas-fmt] Command failed with exit code 127: ./fantomas "/home/cfosli/.vscode/extensions/paolodellepiane.fantomas-fmt-0.3.0/fantomas.tmp.fs"/bin/sh: ./fantomas: No such file or directory
[fantomas-fmt] format failed

Additional info

I can use fantomas fine from the commandline, but I don't have a fantomas executable in the project directory.
It is located in ~/.dotnet/tools/fantomas since I installed it as a global tool, as suggested in the extension README.
It is available in $PATH, so in the commandline I can simply fantomas <filename>

Solution

See PR #21

Unable to format the code

Hi, nothing happens when I click Format Document
fantomas

error

There is no option: editor.formatOnSaveTimeout in VS code editor.

.NET info

.NET Core SDK (reflecting any global.json):
Version: 3.1.301
Commit: 7feb845744

Runtime Environment:
OS Name: Windows
OS Version: 10.0.18363
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.1.301\

Host (useful for support):
Version: 3.1.5
Commit: 65cd789777

.NET Core SDKs installed:
2.1.801 [C:\Program Files\dotnet\sdk]
3.0.100 [C:\Program Files\dotnet\sdk]
3.1.301 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

VS code verion:

Version: 1.49.1 (user setup)
Commit: 58bb7b2331731bf72587010e943852e13e6fd3cf
Date: 2020-09-16T23:27:51.792Z
Electron: 9.2.1
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Windows_NT x64 10.0.18363

formatting in vscode always fail

Always get this information when formatting in vs code :
image

And here is the log output :
image

The temp file is written correctly, but the source file remains the old format. I've tried to restart my computer, doesn't help.

Not working with git bash on windows

Hi, I usually use git bash as a terminal, and when this setting is enabled:

"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",

the formatter does not work. When I comment it and use powershell it works as intended.

'.' is not recognized as an internal or external command

I can't get the extension to work.

Windows 10
dotnet: 2.1.403

When I try formatting in VS Code I get this error:

image

This is what it looks like in the terminal window that the extension opens:

image

Formatting manually using fantomas <filePath> works as expected.

Getting started guide

Hi, Thanks for nice plugin. I was thinking of installing and hooking up in Fake but if vs code is giving it then I would be better of changing my development pipeline.

But I couldn't find out any getting started guide or even commands that I can fire up. Even format command is not working for F# files.

it would be great if you can provide some getting started guide to use this tool.

[Request] Auto format on save

Hey, great plugin, it would be great if it respects the VS Code option "editor.formatOnSave": true, and formats the file on each save

Project still maintained?

Hi,

I noticed that this project did not get any updates anymore. I assume you are using the fantomas that ships with Ionide!?
If so, could you please disable the addin from the gallery? It's the first on shown if you search for "Fantomas".
If not, then please excuse my question. Just trying to find out what's the easiest thing for users to get started.

Steffen

Indent match case in new line

Formatting gives me linter warnings because the case body is not indented:

image

Any way to configure it to this?

image

Thanks!

Crash when formatting document in VSCode

This extension appears to be crashing VSCode when I run the Format Document option from the context menu for the following code.

open System
open System.Linq

type Parent = { Id: int; Alias: string; }

type Book = { 
    Id: int;
    ParentUser: Parent;
    Tagline: string;
    Title: string;
    Visible: bool;
    CreatedDate: DateTime }

[<EntryPoint>]
let main argv =

    let books = [| { Id = 1; ParentUser = { Id = 1; Alias = "ParentBook"; }; Tagline = "BattaBoom"; Title = "clear"; Visible = true; CreatedDate = DateTime.UtcNow }|]

    let bookId = 1

    let res = 
        books 
        |> Seq.filter (fun book -> book.Id = bookId)
        |> Seq.map(fun item -> {| Id = item.Id; ParentId = item.ParentUser.Id; ParentAlias = item.ParentUser.Alias; Tagline = item.Tagline; Title = item.Title; Visible = item.Visible; CreatedDate = item.CreatedDate |})
        |> Seq.head

    printfn "result %A" res

    0 // return an integer exit code

fantomas-fmt version 0.0.21

Version: 1.33.0 (system setup)
Commit: 0dd516dd412d42323fc3464531b1c715d51c4c1a
Date: 2019-04-04T15:14:46.685Z
Electron: 3.1.6
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
OS: Windows_NT ia32 10.0.18362

Unable to format document

Hi, nothing happens when I click Format Document
fantomas

error

There is no option: editor.formatOnSaveTimeout in VS code editor.

.NET info

.NET Core SDK (reflecting any global.json):
Version: 3.1.301
Commit: 7feb845744

Runtime Environment:
OS Name: Windows
OS Version: 10.0.18363
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.1.301\

Host (useful for support):
Version: 3.1.5
Commit: 65cd789777

.NET Core SDKs installed:
2.1.801 [C:\Program Files\dotnet\sdk]
3.0.100 [C:\Program Files\dotnet\sdk]
3.1.301 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

VS code verion:

Version: 1.49.1 (user setup)
Commit: 58bb7b2331731bf72587010e943852e13e6fd3cf
Date: 2020-09-16T23:27:51.792Z
Electron: 9.2.1
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Windows_NT x64 10.0.18363

Inconsistent configuration between fantomas and fantomas-fmt

Description

In fantomas (version 2.9.2.0, the latest one on VS Code), the flag noSpaceBeforeColon is enabled by default.

fantomas --help
 --noSpaceBeforeColon: Disable spaces before colons (default = true).

In fantomas-fmt on VS Code on Windows, the flag "enable space before colon" is enabled by default.

image

I format the code on VS Code terminal, and it works incorrectly no matter if I turn on or turn off the fantomas-fmt flag above. However, if I use the --noSpaceBeforeColon flag in the command line, it works correctly.

fantomas .\TwoFer.fs # Wrong
fantomas .\TwoFer.fs --noSpaceBeforeColon # Right 

Repro code

In my test code here, fantomas-fmt gives me an extra space before every colon.

Also, some settings are changed in fantomas 3.0. Can you also update this plugin?

Thank you very much.

Error formatting a selection

When I try "Format Selection", VSCode responds with "There is no selection formatter for 'fsharp'-files installed.".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.