ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Elm Format on Save

by evancz ST2/ST3

Sublime Text plugin to run elm-format on save

Labels elm, formatting

Details

Installs

  • Total 417
  • Win 124
  • OS X 187
  • Linux 106
Nov 15 Nov 14 Nov 13 Nov 12 Nov 11 Nov 10 Nov 9 Nov 8 Nov 7 Nov 6 Nov 5 Nov 4 Nov 3 Nov 2 Nov 1 Oct 31 Oct 30 Oct 29 Oct 28 Oct 27 Oct 26 Oct 25 Oct 24 Oct 23 Oct 22 Oct 21 Oct 20 Oct 19 Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7 Oct 6 Oct 5 Oct 4 Oct 3 Oct 2 Oct 1
Windows 0 1 1 1 0 0 3 0 1 2 1 1 0 2 1 0 3 2 1 1 1 7 5 2 2 0 0 1 2 2 3 0 2 2 1 1 3 1 1 1 3 1 3 3 5 0
OS X 1 6 1 4 2 3 1 3 2 1 3 5 3 0 3 4 3 2 0 3 2 2 1 3 4 2 2 2 2 2 0 1 0 3 1 3 2 0 1 3 1 2 2 1 0 2
Linux 0 1 3 2 2 0 0 0 0 1 2 2 1 0 4 2 2 1 2 0 1 1 0 2 3 2 1 1 2 2 1 2 2 0 1 0 1 1 0 0 2 1 2 0 0 1

Readme

Source
raw.​githubusercontent.​com

Elm Format on Save

Run elm-format whenever you save an Elm file.

And add the keyboard shortcut Ctrl+K Ctrl+F (or Cmd+K Cmd+F on Mac) to run elm-format any time you want. No need to save.

Install

  1. Install elm-format
  2. Install Elm Syntax Highlighting for Sublime Text
  3. Press Ctrl+Shift+P (or Cmd+Shift+P on Mac) to open the Command Palette
  4. Select Package Control: Install Package
  5. Select Elm Format on Save

Try saving an Elm file to see if it works. You may see a panel open with troubleshooting advice if something has gone wrong!

Including/Excluding Files

Do you only want elm-format to run on certain files? (e.g. only work code)

Go to Sublime Text -> Preferences -> Package Settings -> Elm Format on Save -> Settings

You will see two panels. The left is all the defaults and the right is your custom overrides. So in the right panel, you can override the default settings with something like:

{
    "on_save": {
        "including": ["my/company/"],
        "excluding": ["src/generated/"]
    }
}

This would mean that you only run elm-format on code that is in the my/company/ directory, but you skip any files in the src/generated directory.

See the left settings panel for more information about how to include and exclude files!

Technical Details

This plugin works by modifying the code in the editor itself.

So when it runs “on save” it is specifically running before the file is saved to disk.

This is really important if you have some elaborate file watching system set up! Other plugins may format after the file is saved to disk, triggering a second save, and thereby degrading the performance of your file watching system.