Elm support for Vim.
This plugin requires the error reporting features from Elm Platform 0.15.1 or above.
- Improved Syntax highlighting, including backtick operators, booleans, chars, triple quotes, string escapes, and tuple functions
- Improved Indentation
- Commands and mappings for interfacing with the elm platform
- Auto-complete and Doc strings
- Code formatting
Check out this ElmCast video for more detail.
Elm-vim follows the standard runtime path structure, so you should use a common and well known plugin manager to install it. Do not use elm-vim with other Elm plugins.
- Pathogen
git clone https://github.com/elmcast/elm-vim.git ~/.vim/bundle/elm-vim
- vim-plug
Plug 'elmcast/elm-vim'
- NeoBundle
NeoBundle 'elmcast/elm-vim'
- Vundle
Plugin 'elmcast/elm-vim'
- Manually
- Copy all of the files into your
~/.vim
directory
- Copy all of the files into your
Please be sure all necessary binaries are installed (such as elm-make
, elm-doc
,
elm-reactor
, etc..) from http://elm-lang.org/.
You may also want to install elm-test
with npm install -g elm-test
if you want to run unit tests from within vim.
In order to have completion for all functions inside packages in your elm-package.json
, you must have elm-oracle
on your path. Install it with npm install -g elm-oracle
.
To auto format your elm source code, you must have elm-format
on your path. Install it from the github page
Many of the features are enabled by default. There are no
additional settings needed. All usages and commands are listed in
doc/elm-vim.txt
.
:help elm-vim
-
:ElmMake [filename]
callselm-make
with the given file. If no file is given it uses the current file being edited. -
:ElmMakeMain
attempts to callelm-make
with "Main.elm". -
:ElmTest
callselm-test
with the given file. If no file is given it attempts to run the tests in 'Test[filename].elm'. -
:ElmRepl
runselm-repl
, which will return to vim on exiting. -
:ElmErrorDetail
shows the detail of the current error in the quickfix window. -
:ElmShowDocs
queries elm-oracle, then echos the type and docs for the word under the cursor. -
:ElmBrowseDocs
queries elm-oracle, then opens docs web page for the word under the cursor. -
:ElmFormat
formats the current buffer with elm-format.
Elm-vim has several <Plug>
mappings which can be used to create custom
mappings. Below are some examples you might find useful:
au FileType elm nmap <leader>b <Plug>(elm-make)
au FileType elm nmap <leader>m <Plug>(elm-make-main)
au FileType elm nmap <leader>t <Plug>(elm-test)
au FileType elm nmap <leader>r <Plug>(elm-repl)
au FileType elm nmap <leader>e <Plug>(elm-error-detail)
au FileType elm nmap <leader>d <Plug>(elm-show-docs)
au FileType elm nmap <leader>w <Plug>(elm-browse-docs)
Below are some (default) settings you might find useful to change.
let g:elm_jump_to_error = 1
let g:elm_make_output_file = "elm.js"
let g:elm_make_show_warnings = 0
let g:elm_browser_command = ""
let g:elm_detailed_complete = 0
let g:elm_format_autosave = 0
The current indentation function is still rough, but should work for a lot of cases. It is not always possible to know the perfect indentation level just from context, but we should be able to generate a list of candidates.
- Other vim-plugins, thanks for inspiration (elm.vim, ocaml.vim, haskell-vim)
- Contributors of elm-vim
The BSD 3-Clause License - see LICENSE
for more details