Elm mode for Emacs.
- Syntax highlighting.
- Intelligent indentation.
- Integration with elm-make.
- Integration with elm-repl.
- Integration with elm-reactor.
- Integration with elm-package.
- Integration with elm-oracle
- Integration with elm-format
elm-mode
indentation is based on cycling: every time you insert a new
line there will be one or more indentation levels available for you to
choose from. The exact number is printed in the minibuffer either as
Sole indentation
or Indent cycle (n)...
where n
is the number of
available indentations to choose from. If the automatic indentation
level was not the one you expected simply hit TAB
to cycle through the
list (note that hitting any other key will cancel the cycle).
If your Emacs has package.el
(which is automatically the case
for Emacs >= 24), you can install elm-mode
from the package in
MELPA.
Add this repo to your load-path and (require 'elm-mode)
. Ensure that
the following dependencies are available:
This package assumes you are runing Emacs 24 or later.
The following bindings are available in elm-mode
:
Keybinding | Description |
---|---|
C-c C-c | Compile the current buffer. |
C-u C-c C-c | Compile the current buffer, specifying the output file. |
C-c M-c | Compile the Main.elm file. |
C-u C-c M-c | Compile the Main.elm file, specifying the output file. |
Keybinding | Description |
---|---|
C-c C-l | Load the current file in a REPL. |
C-c C-p | Push the current region to a REPL. |
C-c C-e | Push the current decl. to a REPL (requires haskell-mode ). |
Keybinding | Description |
---|---|
C-c C-n | Preview the current buffer in a browser. |
C-u C-c C-n | Preview the current buffer in a browser in debug mode. |
C-c C-m | Preview the Main.elm file in a browser. |
C-u C-c C-m | Preview the Main.elm file in a browser in debug mode. |
Keybinding | Description |
---|---|
C-c C-d | View a function's documentation in a browser. |
C-c C-i | Import a module from one of the dependencies. |
C-c M-k | Open the package catalog. |
C-u C-c M-k | Open the package catalog, refreshing the package list first. |
The following bindings are available in the package list buffer:
Keybinding | Description |
---|---|
g | Refresh package list. |
n | Next package. |
p | Previous package. |
v | View package in browser. |
m | Mark package for installation. |
i | Mark package for installation. |
u | Unmark package. |
x | Install marked packages. |
The following functionality requires elm-format to be
installed. elm-format
does not come with the Elm installer so you
will have to install it manually.
Keybinding | Description |
---|---|
C-c C-f | Automatically format the current buffer. |
Set or customize elm-format-on-save
to t
to apply elm-format
on
the current buffer on every save.
The following functionality requires elm-oracle to be
installed. elm-oracle
does not come with the Elm installer so you
will have to install it manually.
Keybinding | Description |
---|---|
C-c C-t | Show the type of the function at point in the minibuffer. |
elm-mode
supports auto completion through elm-oracle
. To
enable basic completion (either with company-mode
or Emacs'
completion-at-point
) add elm-oracle-setup-completion
to the
elm-mode-hook
like so:
(add-hook 'elm-mode-hook #'elm-oracle-setup-completion)
If you want to use company
for autocompletion all you need to do
is add the provided backend to the provider list:
(add-to-list 'company-backends 'company-elm)
The company
backend supports company-quickhelp
as well to display
documentation snippets for the autocompletion candidates.
If you prefer to use auto-complete
as your completion backend you
can instead do the following after setting up auto-complete
according to its manual:
(add-hook 'elm-mode-hook #'elm-oracle-setup-ac)
Note that the completion process is synchronous so you should set
ac-auto-start
to a large value or to nil
otherwise you will
experience slowdown. This will be improved in the future.
Here's a screenshot of auto-complete
in action: