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

Add option to disable brittany #79

Closed
cideM opened this issue May 3, 2018 · 8 comments
Closed

Add option to disable brittany #79

cideM opened this issue May 3, 2018 · 8 comments

Comments

@cideM
Copy link

cideM commented May 3, 2018

This extension is extremely nice and works perfectly out of the box, with one small issue, which is a matter of preference and not a bug. brittany works, but it seems extremely tame and mostly leaves my code unchanged. As a front end developer by day, I am used to the luxury of prettier, which parses the code into an AST and the reformats it aggressively. The closest thing in Haskell land appears to be hindent. It takes the following line

data Bull = Fools | Twoo deriving (Eq, Show)

and reformats it to

data Bull
    = Fools
    | Twoo
    deriving (Eq, Show)

whereas brittany doesn't change the line.

Now I understand that not everyone will want that, but since VSC does not support choosing from among multiple formatters it is up to each individual formatter/extension to offer configuration options to disable the formatter/extension. See these issues and specifically

We have always recommended extensions to either ship more fine-grained, e.g. have a separate formatter extension (and let the user decide by installing/uninstalling) or to add an option to enable/disable their formatter (more commonly used).

@ElvishJerricco
Copy link

The latest versions of brittany does data and import formatting. I think you might be using an outdated version of HIE if you're not seeing this?

@cideM
Copy link
Author

cideM commented May 3, 2018

I just ran the setup once more

$ git clone https://github.com/haskell/haskell-ide-engine --recursive
$ cd haskell-ide-engine && make build

and it seemd to use brittany 0.11 which appears to be the most recent version, but it still doesn't reformat data. Regardless, the point about being able to disable it still stands. I did actually check to see if I could just create a PR myself but to be honest I couldn't even figure out when or where the call to format document even happens. It doesn't register itself to the formatting API, at least not in the way that is outlined in the VSC docs.

@simonchatts
Copy link

I would also appreciate such an option, but for the opposite reason: I find brittany a bit aggressive in reformatting (I personally prefer stylish-haskell). eg I've failed to persuade brittany to avoid reformatting

    parser =  Estimated <$> decimal <* char ':' <*> decimal <* char '*'
          <|> Time      <$> decimal <* char ':' <*> decimal
          <|> OnTime    <$  string "On time"
          <|> Cancelled <$  string "Cancelled"
          <|> Delayed   <$  string "Delayed"
          <|> NoReport  <$  string "No report"

into

    parser =
        Estimated
            <$> decimal
            <*  char ':'
            <*> decimal
            <*  char '*'
            <|> Time
            <$> decimal
            <*  char ':'
            <*> decimal
            <|> OnTime
            <$  string "On time"
            <|> Cancelled
            <$  string "Cancelled"
            <|> Delayed
            <$  string "Delayed"
            <|> NoReport
            <$  string "No report"

There may well be a workaround for this case, but in general, it would be a shame if an unnecessary tight coupling here was a (bad) reason not to adopt hie. "A particular opinion on source formatters" and "everything else hie does awesomely" are two very different beasts.

@wz1000
Copy link
Collaborator

wz1000 commented Jul 4, 2018

@simonchatts I'm confused. HIE doesn't force you to format your code, it just exposes LSP requests that allow you to do that. If your code is being automatically formatted, it probably has something to do with your client.

As far as I know, HIE never automatically formats your code without receiving a request from the client.

@simonchatts
Copy link

@wz1000 Is there a configuration option that prevents vscode-hie-server sending formatting requests to HIE?

@Rhywun
Copy link

Rhywun commented Jul 5, 2018

@wz1000 I think the issue is that the OP (and I) would like the option to use a different formatter. I.e. disable brittany, install a different one and use that.

@ElvishJerricco The latest version of brittany does not seem to touch data declarations. This is mentioned in the readme too.

@newhoggy
Copy link

I've found recently that the code formatter is running despite options turning it off:

  // Format a file on save. A formatter must be available, the file must not be auto-saved, and editor must not be shutting down.
  "editor.formatOnSave": false,

  // Timeout in milliseconds after which the formatting that is run on file save is cancelled.
  "editor.formatOnSaveTimeout": 750,

@jneira
Copy link
Member

jneira commented Jan 9, 2020

Now there is an option to choose floskell instead brittany. @cideM, @Rhywun feel free to reopen (or open a new one) if that does not resolve the issue for you

@jneira jneira closed this as completed Jan 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants