Emacs - Elixir Setup Configuration Wiki

How do you start emacs? From a terminal (then it should inherit your PATH), the GUI or via a systemservice and emacsclient?

If you use one of the latter two versions, please try to start emacs via terminal and check if the problem exists there as well. If it works then, stick to that method of starting or provide the PATH in a way that it works for your means of starting.

Not sure how you provide additional PATHes to macOS GUI or system services though…

I start from GUI application before, just try running from terminal with emacs . and still got the same problem :face_with_raised_eyebrow:

after trying open without gui using emacs -nw . the elixir-ls now working

1 Like

after finding this issue I try reinstall emacs itself by follow the guide on spacemacs page (install with brew install emacs-plus) and setup spacemacs again

it’s now working!!
thanks all and sorry for spamming :sweat_smile:

1 Like

Hi @axelson. Is it possible to configure lsp-mode (e.g., to point it to Elixir sources) so go-to-definition would work for core Erlang/Elixir modules? As it says in README:

You may want to install Elixir and Erlang from source, using the kiex and kerl tools. This will let you go-to-definition for core Elixir and Erlang modules.

I use Nix to build Elixir and Erlang from source, but I still can’t jump to core Elixir modules (though jumping to project’s code and dependencies work).

Hmm, I haven’t tried that personally so I’m not quite sure how you would set that up.

Just wondering and asking for options.
How do you refactor, i.e. rename a function?

I currently use iedit, but it’s per buffer only and sometimes not really useable because it doesn’t know scopes.

What do you use?

Manfred

Personally I just refactor mostly manually. If I’m renaming a function I’ll use multi cursor mode to select all the references to that function in the current file and then rename them all at once (if it’s a public function I might use projectile-replace).

1 Like

Yeah @charje I currently have the same problem as you. Elglot and flymake work fine for Python and Rust for me but not Elixir.

I realized that linting with flymake works just great in an elixir project with a mix.exs. It’s just lone elixir files that don’t have linting

Thats strange because the files I’m having issues with all belong to an elixir project with a mix.exs file.

If you use helm-ag you can use helm-do-ag for search in folder and then C-c C-e to open edit buffer with all the things you searched.

Here is the video tutorial on that (it shows python, but it doesn’t really matter): https://www.youtube.com/watch?v=XAHVwhTsF-g

1 Like

Yep, this is pretty good.
Thanks

I was updating my environment to use the latest versions of things and I hit a problem with elixir-ls. I figured out a quick fix so just posting here in case someone has the same problem. I’m using Ubuntu 18.04.

After updating elixir-ls and running $ mix elixir_ls.release I tried to connect from Emacs. But it didn’t work and I noticed this message in the elixir-ls::stderr buffer…

/opt/elixir-ls/release/language_server.sh: 8: /home/my_home/.asdf/asdf.sh: Bad substitution

This answer on SO pointed me in the right direction
https://stackoverflow.com/a/20616103/1502519

And so the quick fix was to change the first line in release/language_server.sh
from #!/usr/bin/env sh to #!/bin/bash

I think this only happens now because of a somewhat recent commit…
https://github.com/elixir-lsp/elixir-ls/commit/b2749e76a35c4e1a7ae7385fd60d06f1756b0583#diff-9b8bec26e21a66d10d7d863a16ddbf97

Actually, I just tested now and just removing the line from that commit also works as a quick fix.

What shell runs when you run the command /usr/bin/env sh?

Perhaps there’s a more universal way to write that line:

[ -f “$HOME/.asdf/asdf.sh” ] && . “$HOME/.asdf/asdf.sh”

/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

5 Likes