Home

Awesome

This project is deprecated. For modern Elm support in VSCode use https://marketplace.visualstudio.com/items?itemName=Elmtooling.elm-ls-vscode (GitHub: https://github.com/elm-tooling/elm-language-client-vscode)


Elm support for Visual Studio Code

Error highlighting

Feature overview

Elm Installation

Global Installation

Follow this guide.

Project (Local) Installation

Run npm install --save-dev elm

Then, in .vscode/settings.json, add the following:

"elm.compiler": "./node_modules/.bin/elm",
"elm.makeCommand": "./node_modules/.bin/elm-make"

For Windows

"elm.compiler": ".\\node_modules\\.bin\\elm",
"elm.makeCommand": ".\\node_modules\\.bin\\elm-make"

Feature details

Syntax highlighting

Syntax highlighting is essential. The full language is supported. Fenced code blocks in markdown files are highlighted too. Can we improve the highlighting further? Please create an issue!

Error highlighting

We support error highlighting on save. If you check Auto save under File, you should get feedback immediately.

Error highlighting

This is marked experimental because we still have to improve the project detection.

Hover info - Function information

Function info

You can hover over a function and get the signature and comment.

Document and Workspace symbols

Use context menu "Go to definition" or F12. Alt+F12 to Peek

Go to definition

Ctrl+Shift+O for document symbols and Ctrl+T for workspace symbols

Search/browse document symbols and workspace symbols

Code Actions (Lightbulb on errors and warnings with fixes)

Tip - use Ctrl+. to invoke code action when the lightbulb is visible

Code actions

Integration with Elm Package (Browse and install packages)

Ctrl+Shift+P - Elm browse packages

Browse packages

Ctrl+Shift+P - Elm install package

Install package

Local Project Intellisense (experimental)

vscode-elm will scan your projects to build intellisense results. Assumption your files match the layout of elm-format

Example behaviors are:

important note regarding performance

With elm.userProjectImportStrategy set to "dynamicLookup" (default), every hover or autocomplete action will trigger a scan of the first few lines of every file in your src directory (not the elm-stuff directory). This is done to establish an accurate list of module names but could be slow for exceptionally large projects.

In testing with the Elm SPA example project no slowdown was noticed, but if your project slows down try one of these alternate settings:

REPL integration

REPL

Not sure about the output of a function? Test it from inside the editor.

Open the actions menu and use one of the following commands:

Reactor integration

Reactor support

Reactor is the webserver which comes with Elm.

We support starting / stopping from within the editor.

Integration with Elm Make

Snippets

We support snippets for the basic language features. To use them, press Ctrl+Space and start typing. Or start with some characters and use Ctrl+Space for autocompletion.

Want to know more? Look at the snippet definitions

Formatting with Elm-format

elm-format is supported via the editor's Format Code command. To format your code using elm-format, press Shift+Alt+F on Windows, Shift+Option+F on Mac, or Ctrl+Shift+I on Linux.

You can also configure elm-format to run on save by enabling editor.formatOnSave in your settings.

// settings.json
{
    "[elm]": {
        "editor.formatOnSave": true
    }
}

On Windows you may need to add editor.formatOnSaveTimeout:

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

Elm-format - local installation

If you have elm-format installed locally add this line to '.vscode/settings.json'

"elm.formatCommand": "./node_modules/.bin/elm-format"

For Windows

"elm.formatCommand": ".\\node_modules\\.bin\\elm-format"

Elm-analyse integration

Elm-analyse is a tool that allows you to analyse your Elm code, identify deficiencies and apply best practices. The integration enables vscode to show any problems identified by elm-analyse as linting warnings in your code.

Elm-analyse

With a button to stop the elm-analyse process

Elm-analyse stop

To install elm-analyse

// bash/console
{
    npm install elm-analyse -g
}

Commands:

When running, any issues will show up in the problems window (Ctrl+Shift+M), F8 to cycle. Issues will also show up as green linting warnings in your code.

NOTE: This is an early version

Elm-analyse settings:

Clean Build Artifacts

You can delete your elm-stuff/build-artifacts directly from vscode by using Elm: Clean build artifacts command.

Acknowledgements

How to contribute

Imposter syndrome disclaimer: I want your help. No really, I do.

There might be a little voice inside that tells you you're not ready; that you need to do one more tutorial, or learn another framework, or write a few more blog posts before you can help me with this project.

I assure you, that's not the case.

This project has some clear Contribution Guidelines and expectations that you can read here.

The contribution guidelines outline the process that you'll need to follow to get a patch merged. By making expectations and process explicit, I hope it will make it easier for you to contribute.

And you don't just have to write code. You can help out by writing documentation, tests, or even by giving feedback about this work. (And yes, that includes giving feedback about the contribution guidelines.)

Thank you for contributing!

Contributing and copyright

The project is hosted on GitHub where you can report issues, fork the project and submit pull requests. Please read the CONTRIBUTING document for more information.

The library is available under MIT license, which allows modification and redistribution for both commercial and non-commercial purposes.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Maintainer(s)

Past Maintainer(s)