Skip to content

wclr/purescript-tidy

 
 

Repository files navigation

purescript-tidy

A syntax tidy-upper (formatter) for PureScript.

Install

npm install -g purs-tidy

Usage

You can use purs-tidy to format files in place or via STDIN / STDOUT (which is useful for editor integration):

# Formatting a collection of files in place:
$ purs-tidy format-in-place "src/**/*.purs"

# Using STDIN to format a file:
$ purs-tidy format < MyFile.purs

Configuration

You can see all configuration that purs-tidy accepts using the --help flag for the command you are using:

$ purs-tidy format-in-place --help

Some common options include:

  • --indent to set the number of spaces used in indentation, which defaults to 2 spaces
  • --arrow-first or --arrow-last to control whether type signatures put arrows first on the line or last on the line (purty-style), which defaults to arrow-last.

Development

Running bin

spago -x ./bin/spago.dhall build
./bin/index.js --help

Running test

To accept snapshot tests:

spago -x ./test/spago.dhall test -a "--accept"

Generating the built-in operator table

spago -x ./script/spago.dhall run -m GenerateDefaultOperatorsModule

Auto-formatting in VS Code

First, install the Run on Save extension so that you can execute a command when your file is saved. Then, add this to your settings.json:

  "emeraldwalk.runonsave": {
    "commands": [
      {
        "match": ".purs",
        "cmd": "$TIDY_DIR/bin/index.js format-in-place ${relativeFile}"
      }
    ]
  }

...where $TIDY_DIR is replaced with the location of a checkout of purescript-tidy.

About

A syntax tidy-upper for PureScript.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PureScript 96.3%
  • Dhall 3.5%
  • JavaScript 0.2%