MaxGabriel / brittany-vscode-extension

VSCode formatting extension for the brittany Haskell code formatter
MIT License
9 stars 1 forks source link

brittany VSCode extension

This extension calls the brittany program to format Haskell source code. It's implemented with the VSCode formatting API, and supports both full-document and specific ranges.

Because it's based on VSCode's formatting API, you use it via VSCode's standard formatting commands:

Source code for this extension is available on Github.

Requirements

The brittany formatter must be installed as a command line program. See the brittany README for details.

To work with the formatting API, VSCode must recognize your source code file as a haskell file. Add this to your User Preferences (⌘ , or Ctrl ,) to set this up:

"files.associations": {
    "*.hs": "haskell",
}

I'm not familiar with brittany's support for literate Haskell (.lhs) or Haskell C interface code (.hsc), so I don't know if it would work for those.

Extension Settings

brittany Configuration

brittany itself can be configured globally at ~/.config/brittany/config.yaml, as well as brittany.yaml in the directory brittany is called from. For standalone files, brittany is called from the same directory as the file being formatted. If your file is part of a workspace, brittany will be called from the root directory of that workspace.

Caveats