Emacs - Elixir Setup Configuration Wiki

/bin/sh is linked to dash which is the default for sh in Ubuntu

The problem seems to come from the second part of that line where asdf.sh is sourced although using a dot here seems to be POSIX compliant. So I don’t think there is anything wrong with that line per se.

running sh ~/.asdf/asdf.sh gives a similar error to the one I observed earlier
/home/my_home/.asdf/asdf.sh: 8: /home/my_home/.asdf/asdf.sh: Bad substitution

So even though the asdf.sh has #!/usr/bin/env bash at the top it seems to be ignored because it is called via sh

Thanks for figuring out more about the issue. I’m tracking this as:

1 Like

Thanks for your help with this! And for all your input in this thread!!! - it has help me a lot to get a nice setup in Emacs :slight_smile:

1 Like

Thanks for your kind words!

Also, I’ve merged https://github.com/elixir-lsp/elixir-ls/pull/118 which addresses this by changing language_server.sh to run bash instead of sh.

1 Like

I’m just getting back into Elixir dev and setting up Spacemacs again. I got round this by filtering out several folders by adding the following to dotspacemacs/user-config()

  (with-eval-after-load 'lsp-mode
    (add-to-list 'lsp-file-watch-ignored ".elixir_ls$")
    (add-to-list 'lsp-file-watch-ignored "deps$")
    (add-to-list 'lsp-file-watch-ignored "_build$"))

Not sure if there’s a more compact way of doing that but it seems to be working!

Thanks to everyone who’s been updating the configuration information and working on the plugin and layers. Works really well and nice to be in Emacs rather than VS Code so far.

I’ve also added

(push '("*exunit-compilation*" :dedicated t :position bottom :stick t :height 0.4) popwin:special-display-config)

Which makes the exunit test output always appear at the bottom in Spacemacs and close automatically with C-g


Awesome! I’ve been meaning to figure out how to accomplish that.

1 Like

This is pure gold :smiley: Thank you!

1 Like

I’ve added the popwin line to the wiki, seems popular! :slight_smile:


Cool, thank you for the suggestion. I’m currently using doom-emacs, I think the snippet should work properly.

Thanks for adding it! I promoted it on the slack as well and some people enjoyed it there. I also added :noselect t to the snippet (at the recommendation of someone on the Slack) so that the compilation buffer doesn’t take focus when you run the tests.

1 Like

I actually prefer it to be selected so it’s easier to navigate to failing output and jump to the test. Each to their own though!

1 Like

If anyone wants to use flycheck with eglot, I wrote a simple wrapper which replaces flymake with flycheck https://github.com/akash-akya/eglot-flycheck-adaptor

1 Like

Update: I finally solved my flycheck problems (yes, from July 2019). I’ve got lsp checking (dialyzer & elixir compiler) and credo working in a chain. The key was this: (setq lsp-flycheck-live-reporting nil). Disabling that prevents lsp from stomping on the value in flycheck-check-syntax-automatically. I think they are trying to replace that, but at least in a project the size of mine you cannot be running flycheck on idle/new line etc. I’ve long run it only on enable and save. Every now and then I’ll save before the last check finished and things get out of a sync so I do a quick s e b

Relevant configs:

  (add-hook 'elixir-mode-hook
    (lambda ()
      (setq lsp-flycheck-live-reporting nil)
      (setq-local flycheck-check-syntax-automatically '(mode-enabled save))))

  (add-hook 'lsp-after-initialize-hook
            (lambda ()
              (lsp--set-configuration `(:elixirLS, lsp-elixir--config-options))
              (flycheck-add-next-checker 'lsp 'elixir-credo)))

Care, as it can completely bork the checking of lsp (at least it did ~a month ago when I tried to tackle this again).

The core of the issue is how lsp-mode interacts with flycheck.
The idea is that lsp runs the checker when it is needed by lsp specification, and only then.

By disabling that, your dialyzer checkers can stop working properly.

So, as I said earlier, the proper solution is to implement credo linter as part of the elixir-ls (or as a standalone plugin for the elixir-ls. I don’t know if elixir-ls supports plugins). And I am pretty sure such a contribution will be welcome

It is not just credo that doesn’t work for me. The compiler and dialyzer checkers also get stuck and stop updating unless I disable lsp-flycheck-live-reporting. It seems odd they’d document a customizable variable that can “completely bork … lsp” and not document that fact?

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.
1 Like

Btw, if you guys and gals agree I can edit the wiki directly. Didn’t realize I could do it.

Go for it! That’s why it’s a wiki. That all looks like good information :+1:
I don’t use eglot so the instructions tend to lag a bit.

1 Like

Done editing the Spacemacs eglot configuration in the wiki!

1 Like

Indeed, I still have some problems… But the other configuration didn’t work well for Spacemacs anyway :/.