Skip to content

rtfeldman/elm-vim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

elm-vim

Elm support for Vim.

Compatibility

This plugin requires the error reporting features from Elm Platform 0.15.1 or above.

Features

  • 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.

Install

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

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.

Completion and Docs

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.

Format Source

To auto format your elm source code, you must have elm-format on your path. Install it from the github page

Usage

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] calls elm-make with the given file. If no file is given it uses the current file being edited.

  • :ElmMakeMain attempts to call elm-make with "Main.elm".

  • :ElmTest calls elm-test with the given file. If no file is given it attempts to run the tests in 'Test[filename].elm'.

  • :ElmRepl runs elm-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.

Mappings

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)

Settings

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

Indentation

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.

Credits

  • Other vim-plugins, thanks for inspiration (elm.vim, ocaml.vim, haskell-vim)
  • Contributors of elm-vim

License

The BSD 3-Clause License - see LICENSE for more details

Releases

No releases published

Packages

No packages published

Languages

  • Vim Script 100.0%