Is code formating working in rescript-vscode?

I installed rescript-vcode@1.0.4.
Syntax highlighting and error alerts are working, but the code formatting is not working.
How can I fix this?

In this sample snippet, I am expecting 3rd line to start from the beginning after the file is saved in vscode. But it is not happening.
Screenshot 2021-01-08 at 12.07.17 PM

1 Like

Hi @akiran

I’m not sure why it’s not working for you, but I have 1.0.4 installed and it seems to be OK for me. I can adjust this code and it always formats back to this:

image

Also, for me, the semicolons are also being automatically removed

Do you see the ReScript language mode in the bottom right corner?

image

silly question: did you npm install your project dependencies?

Yes, I did.

rescript & react app demo I am building is working fine, but the formatting is not working in vscode.

Yes, I see Rescript language mode in the bottom right corner.

I found out that the issue is in my vscode settings
I had this in my settings which is causing the problem.

"editor.defaultFormatter": "esbenp.prettier-vscode"

I removed it and rescript formatting is working fine.

Thanks for the help.

5 Likes

Yep, this was my problem as well. Thanks @akiran

Just for thread completeness, you can have language-specific configurations inside settings.json, so there is no need to remove prettier completely:

  "editor.formatOnSave": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "[rescript]": {
    "editor.defaultFormatter": "chenglou92.rescript-vscode"
  }

Something like this should work.

2 Likes

Thanks, @mxthevs. Also, the last thing for the completeness is that I discovered
formatter has 0 configuration options, typically nice but this formater has a bug core team wont fix with line width, especially bad when using pipes.