Emacs - Elixir Setup Configuration Wiki

Hi there!
Thanks for the guide! :slight_smile:
I am using Spacemacs and eglot. The guide is not totally accurate.
package-install is prohibited in Spacemacs.

  1. You should add eglot in dotspacemacs-additional-packages instead.

  2. Then you need to add in dotspacemacs/user-config:

(require 'eglot)
(add-to-list 'eglot-server-programs '(elixir-mode "/home/nicolas/elixir-ls/release/language_server.sh"))
  1. To make your life easier and not having to type M-x eglot in any Elixir file, you may add in dotspacemacs/user-config AFTER (require 'eglot):
(add-hook 'elixir-mode-hook 'eglot-ensure)

Lastly, three things:

  1. The elixir layer in Spacemacs does not play well with Eglot. It calls lsp-mode from the Spacemacs lsp layer. If you want to use eglot in Spacemacs, you should add directly elixir-mode in dotspacemacs-additional-packages. Do not add the elixir layer.
  2. If you fail to add the require 'eglot instruction appropriately, eglot will randomly stop working on Emacs restart, and you will be prompted the error described in this GitHub issue.
  3. You can find my full .spacemacs dot file for more guidance on my GitHub.
2 Likes