Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elm VSCode plugin does not format on save

I have copied the following question from the Elm Slack channel for posterity.

I am having trouble getting the Elm VSCode plugin to format on save. I have set the absolute path to my global install of elm-format in settings.json. I have also set format on save for elm:

"[elm]": {
    "editor.formatOnSave": true,
  },

I am on an Ubuntu machine, and format does not happen on save or with Ctrl-Shift-I. Does anyone see something that I might be missing?

like image 246
bgins Avatar asked Feb 04 '23 16:02

bgins


2 Answers

  1. Install elm-format

  2. Install the extension Elm Language Support for VSCode, which includes syntax and error highlighting

  3. Configure VS code settings.json:

"[elm]": {
    "editor.formatOnSave": true
},
like image 66
hien Avatar answered Feb 06 '23 07:02

hien


The format on save timeout should not be an issue with VSCode 1.42 (Q1 2020)
See "Better handling of slow save operations":

VS Code allows extensions to change a file's contents when saving files to disk.
Features like Format on Save and Fix on Save are examples.

However, saving is a critical operation and extensions doing processing during a save must finish quickly so that the actual save operation can proceed.

"Quickly" used to be enforced by VS Code with timeouts that would make VS Code cancel extension save participation.
That enforcement guaranteed speedy saving but could be frustrating because sometimes expected processing would not happen.

With this release, we have given up the timeout-based approach and instead show a progress notification that allows you to cancel extensions participating in save ("Save Participants").
The notification lets you know that save operations are running and you can decide if you want to wait for a save participant to finish or not.

https://media.githubusercontent.com/media/microsoft/vscode-docs/vnext/release-notes/images/1_42/save-participant.png

like image 25
VonC Avatar answered Feb 06 '23 07:02

VonC