Set up Eglot with elixir-ls

By on

To set up Eglot with elixir-ls, first install both elixir-mode and Eglot using your preferred Emacs package manager. With straight.el:

;; Elixir: elixir-mode
(straight-use-package 'elixir-mode)

;; Language server client: Eglot
(straight-use-package 'eglot)

Check out the repository for elixir-ls inside the ~/.emacs.d/ directory, and build1 it using mix elixir_ls.release:

git clone ~/.emacs.d/elixir-ls
cd ~/.emacs.d/elixir-ls
mix deps.get
mix elixir_ls.release

In ~/.emacs.d/init.el, add the path to the file to the server programs list:

;; Add elixir-ls to Eglot's server programs list
(add-to-list 'eglot-server-programs '(elixir-mode "~/.emacs.d/elixir-ls/release/"))

Evaluate the init.el file by running M-x eval-buffer (or by restarting Emacs) to reload the configuration.

Now, run M-x eglot in any Elixir file to start the language server.


Because elixir-ls in a local repository, pull in changes through Git and rebuild the language server to update it in the future:

cd ~/.emacs.d/elixir-ls
git pull
mix deps.get
mix elixir_ls.release