Elixir

From WikEmacs
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Elixir support in Emacs is pretty good ! How can we turn Emacs as an Elixir IDE ?

   "Emacs has the best integration and best code completion (with alchemist) but it is emacs, and is only really great if you are comfortable with it."[a redditer]


Also note that Spacemacs ships an Elixir layer.

Elixir-mode - the basics

elixir-mode (in melpa) provides syntax highlighting, indentation and navigation support. More tooling come with Alchemist.

inf-elixir

Like most inf-* packages, inf-elixir (in melpa) provides an easy way to open an Elixir REPL (IEx shell) either in the context of a project or independent from any.

exunit.el

exunit.el (in melpa) provides an easy way to run tests in a mix project.

Alchemist - Elixir tooling

Alchemist (in melpa) features:

  • Mix integration (prompt for a command, with completion of the available ones, compile the project, run the expression in contect,…)
  • Mix Hex integration (get package info, show dependencies, search packages,…)
  • Testing (run the test suite, the last test, the test at point, …)
  • Compile & Execution of Elixir code
  • Inline code evaluation
  • Inline macro expanding
  • Documentation lookup
  • Definition lookup
  • Powerful IEx integration
  • Smart code completion
  • Elixir project management
  • Phoenix support (list all files/controllers/channels/etc)
  • Integration with company-mode (completion framework)

It adds an Alchemist menu and it has documentation. However, Alchemist has not been updated in over three years, and has many known issues.

Alchemist works as a server & client model, where the Alchemist server is written in Elixir and Emacs takes the part of the client. For each Elixir mix project Alchemist starts an independent server in the background. If an Elixir file gets opened in a buffer, Alchemist checks if a server is running for the current project or not and starts a new one if needed. If there is no Elixir mix project found, Alchemist starts a general unique server.

Editing templates

web-mode works well to edit eex templates.