Emacs - Elixir Setup Configuration Wiki

Hmm, that error makes it sound like the LS has crashed or isn’t configured. Does your *elixir-ls* or *lsp-log* buffers have any errors?

Well, I don’t know the reason, but when I have opened it today, jump to definition has started working.

My problem right now is that my CPU is some times over 95%, and Spacemacs gets unresponsive a few seconds. I do believe that it can be related to Dyalizer. How can I disable it to test if the problem is there?


Your CPU will spike for up to 10-15min (can be even higher if it’s a big project) as dyalixer installs project dependencies and creates it’s cache the first time.

Is the CPU spike from initial project load or are you seeing it will into working on a project?

1 Like

Not dialyzer, the language server will pull deps, compile them and build the initial PLT for dialyzer. The latter can be disabled, but I’m not quite sure how this is done in emacs, and also depends on the LS-client used…

But this will disable the dialyzer feature completely…

1 Like

I wasn’t using Dialyzer with my prior configuration, so it’s not a big deal if I could disable it.

I think the problem is in Dialyzer because sometimes an error is shown on minibufer saying something like ElixirLS Dialyzer had an error. If this happens repeatedly, set "elixirLS.dialyzerEnabled" to false in settings.json to disable it.

After that, CPU comes back to normal levels, but when I try coding again, CPU rocket out until 98 or 99 %. Then the error appears again.


I added a section on how to disable Dialyzer.


Does anyone have Credo and lsp-mode working properly together with Flycheck? I have them sort of both working, but it seems like Credo only gets called when there is a state change with the lsp-ui checker. Once I get a credo warning, it won’t be dismissed until I get a compilation error and then clear that. Also I may not get a credo warning I should get if there is no compile error.

Relevant configs: (I’m using Spacemacs, 26.2, latest everything):

  (add-hook 'elixir-mode-hook
    (lambda ()

  (add-hook 'lsp-after-initialize-hook
            (lambda ()
              (flycheck-add-next-checker 'lsp-ui

I don’t really understand elisp or the internals of Spacemacs, but this is the simplest way I managed to disable dialyzer globally, I think it’s working:

In .spacemacs, in dotspacemacs/user-config:

  (add-hook 'lsp-after-initialize-hook
            (lambda ()
              (lsp--set-configuration `(:elixirLS (:dialyzerEnabled :json-false)))))

edit: No, I don’t think it actually works in the end, I can see [ElixirLS Dialyzer] lines in *lsp-log* anyways, I’d like to see some simple, foolproof solution.

Hello everyone.
Thanks for the great guide!

I’ve got an issue though. While with simple projects where mix.exs is in git root everything works fine.
But when the project folder is in subfolder (for example, I use docker and prefer to have all of my docker files at top level, while project files in subfolder) autocompletion and dializer doesn’t work. It will properly autocomplete kernel and built-in functions but it does not autocomplete my def and defp functions at all.

As far as i know from working with python-language-server you can pass it the location of the project root folder. Is there such a thing in elixir-ls?

I use lsp-mode with spacemacs and lsp-elixir fork of elixir-ls.

Thanks in advance!

1 Like

Hi @Mpanarin :wave:, I’m glad that the guide was helpful for you!

I’ve created a small repo that should replicate the important bits of your setup.
/tmp/mix-example is the git root and /tmp/mix-example/elixir_app is the elixir application.

When you first open a new Elixir file in the elixir application you should see a prompt to choose the root folder:

Since your elixir project is not directly in your git root (/tmp/mix-example) you should select the “Import project by selecting root directory interactively” option. Then you choose the elixir project root:

If you’ve already made the selection for your project you can remove the matching path from the your ~/.emacs.d/.lsp-session-v1 file (there may be a way to edit it nicely from within Emacs but I’m not aware of it).


One thing though I think missing in alchemist. I’ve implemented it with custom function

(defun my-put-iex ()
  (insert "require IEx; IEx.pry"))
(global-set-key (kbd "C-c a p i") 'my-put-iex)

It pastes require IEx; IEx.pry when you press C-c a p i.

C-c a is for user-space functions.
p i is for “paste IEx” :slight_smile:


Great tutorial to get this up and running.
I got it working.

I’m wondering though, since I’m new to Elixir, how do I compile and run code, a module. What is the workflow here?
OK, exunit.el can do this when there is a unit test.
But how do you deal with iex and mix?


1 Like

Hi Manfred and welcome to the forum!

Personally I usually do that in iex directly by editing code (within the context of a mix project), and then typing recompile (docs) which will recompile and reload all files, often times I’ll also hook up exsync which will recompile and reload all the files in your project immediately after you save changes to a file. Another option as you are working on an individual file is to issue r MyModule in iex (docs) which will recompile and reload just that one module.

So usually I do this outside of emacs, although there are ways to load/reload code in the context of emacs.

1 Like

Thanks for this info.

As a side note, I have great success with eglot and eldoc-box.

Flymake/flycheck is still making some trouble.

Having seen how those various little tools work, there is still a large feature set in Alchemist which is not available by those.
Are there people working on Alchemist?
If yes, what is the latest GitHub repo to contribute?


1 Like

Yeah there are still a decent amount of features in Alchemist that would be nice to port over. As far as I know there no one is currently working on Alchemist, some people have tried but it is quite a large code-base and very interconnected which has proven difficult to extract or refactor. If you want to improve/modernize alchemist directly you would want to fork the official alchemist repository: https://github.com/tonini/alchemist.el/. Alternatively if you want to extract specific functionality from it you may want to contribute directly to https://github.com/elixir-editors/emacs-elixir (or possibly https://github.com/elixir-lsp/lsp-elixir.el but that doesn’t have a maintainer right now).

1 Like

I didn’t go through all of the posts here, so I might’ve missed something, but is there some initiative or work being done towards a PR for Spacemacs to replace Alchemist in the Elixir layer?


There currently is not, but that would be a good idea.

1 Like

I opened a PR with additional configurations for elixir layer in spacemacs. Reviews and comments are welcome )


Thanks for opening the PR! I left a couple comments on the PR :slight_smile:

1 Like