Home

Awesome

elm-vim

logo

Features

  1. Syntax highlighting
  2. Automatic indentation
  3. Function completion
  4. Build and package commands
  5. Code formatting and linting
  6. Documentation lookup
  7. REPL integration

Check out this ElmCast video for more detail.

Installation

If you don't have a preferred installation method, I recommend installing vim-plug, and then simply add Plug 'elmcast/elm-vim' to your plugin section:

NOTE: If you are using vim-polyglot, you need to disable its default elm plugin by adding let g:polyglot_disabled = ['elm'] to your config file.

Requirements

First, make sure you have the Elm Platform installed. The simplest method to get started is to use the official npm package.

npm install -g elm

In order to run unit tests from within vim, install elm-test

npm install -g elm-test

For code completion and doc lookups, install elm-oracle.

npm install -g elm-oracle

To automatically format your code, install elm-format.

npm install -g elm-format

Mappings

The plugin provides several <Plug> mappings which can be used to create custom mappings. The following keybindings are provided by default:

KeybindingDescription
<LocalLeader>mCompile the current buffer.
<LocalLeader>bCompile the Main.elm file in the project.
<LocalLeader>tRuns the tests of the current buffer or 'tests/TestRunner'.
<LocalLeader>rOpens an elm repl in a subprocess.
<LocalLeader>eShows the detail of the current error or warning.
<LocalLeader>dShows the type and docs for the word under the cursor.
<LocalLeader>wOpens the docs web page for the word under the cursor.

You can disable these mappings if you want to use your own.

let g:elm_setup_keybindings = 0

Integration

Ale

The preferred linter to use with elm-vim is Ale. It should work out of the box.

Syntastic

Syntastic support should work out of the box, but we recommend the following settings:

let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1

let g:elm_syntastic_show_warnings = 1

YouCompleteMe

let g:ycm_semantic_triggers = {
     \ 'elm' : ['.'],
     \}

Neocomplete

call neocomplete#util#set_default_dictionary(
  \ 'g:neocomplete#sources#omni#input_patterns',
  \ 'elm',
  \ '\.')

Usage

:help elm-vim
let g:elm_jump_to_error = 0
let g:elm_make_output_file = "elm.js"
let g:elm_make_show_warnings = 0
let g:elm_syntastic_show_warnings = 0
let g:elm_browser_command = ""
let g:elm_detailed_complete = 0
let g:elm_format_autosave = 1
let g:elm_format_fail_silently = 0
let g:elm_setup_keybindings = 1

Screenshots

errors and completion

Credits

License

Copyright © Joseph Hager. See LICENSE for more details.