Emacs - Elixir Setup Configuration Wiki

which is presented in the path, bu
t how can I change it to access language_server.bat?

Got it, in lsp-clients.el, find “language_server.sh”, replace it with “language_server.bat”, it is working fine now, thx for your help!

1 Like

I’m glad you got it figured out! I’ve submitted a PR upstream: https://github.com/emacs-lsp/lsp-mode/pull/703

1 Like

Instead of changing your packages sourcode which might shoot yourself in the foot on updates of the package, you might want to customize lsp-clients-elixir-server-executables value.

1 Like

Thx NobbZ, that exactly the variable I changed in lsp-clients.el though I don’t know what it is used for at the moment. Thanks for your tips!

It is a defcustom, that means that you can change its value through M-x customize.

And it is actually the name of the script that gets used to start the server. @axelson did a pull request that actually changes the default based on the operating system.

Anyone who needs to start another script, should override the default through the customize menu (but as far as I remember, setq in the config should work as well.

HI guys, I got this message when I start the server:

error in process filter: Symbol’s value as variable is void: spacemacs-jump-handlers-elixir-mode

what does it mean?

I tried lsp-elixir the other day. It tries to compile everything and run the node. Which of course doesn’t make sense in the dev mode. Plus start time is hilarious. I think approach needs to be changed to parsing, etc. Somehow even c++ clangd can work without recompilation (or it’s well hidden).

Quick follow up for posterity. use-package looks to be included in spacemacs. So that’s not relevant to your case @DavidCheuk.

error in process filter is a message from lsp-mode itself. Unfortunately my elisp-foo isn’t strong enough to help you much, you’re probably better off asking the lsp-mode maintainers.

If you write your own Elixir Language Server that uses parsing instead of compilation you could use it from Emacs just fine, you just need to add your server to the exec-path. Also let’s try to keep this thread focused on Emacs integration with Language Servers.

Thank you for reminding me to stack on topic!

Would be cool if there will be a config for elixir-mode to have the same indentation as mix format.

Yeah the Elixir mode formatting could definitely use some love. I wonder if you could use mix format as a testing oracle for it, to ensure that the behaviors match

Is there a way to get Web Mode + Elixir to load in .leex (Live EEX) files?

Edit: I managed to associate web-mode with .leex files using the instructions under “Install” and “Associate an engine” here: http://web-mode.org/

2 Likes

Beautiful. Thank you for the wonderful documentation. It was almost trivial setting up LSP for Elixir (and for other languages as well in the process).

2 Likes

I’m glad that it was helpful to you!

1 Like

Update 2:
Looks like there is nothing to do with ExMachine. But with import form which used in conn_case.ex
The problem is import Ecto.{Query, Changeset} when it’s in using block (which is macro of ExUnit.CaseTemplate)

Update:
I found the cause of the problem.
it is somehow related to ExMachine, which I didn’t start before ExUnit starts in test_helper.exs.
After I added {:ok, _} = Application.ensure_all_started(:ex_machina) to it, all other tests which use factories stop showing me errors.
But when I’m in test_helper.exs it continues to show errors like:

    ** (FunctionClauseError) no function clause matching in ElixirSense.Core.Source.tokenize_prefix/1
        (elixir_sense) lib/elixir_sense/core/source.ex:152: ElixirSense.Core.Source.tokenize_prefix({:ok, [{:"{", {1, 1, nil}}, {:atom, {1, 2, nil}, :ok}, {:",", {1, 5, 0}}, {:identifier, {1, 7, nil}, :_}, {:"}", {1, 8, nil}}, {:match_op, {1, 10, nil}, :=}, {:alias, {1, 12, nil}, :Application}, {:., {1, 23, nil}}, {:paren_identifier, {1, 24, nil}, :ensure_all_started}, {:"(", {1, 42, nil}}, {:atom, {1, 43, nil}, :ex_machina}, {:")", {1, 54, nil}}, {:eol, {1, 55, 1}}]})
        (elixir_sense) lib/elixir_sense/core/source.ex:138: ElixirSense.Core.Source.which_func/1
        (elixir_sense) lib/elixir_sense/providers/signature.ex:19: ElixirSense.Providers.Signature.find/5
        (language_server) lib/language_server/providers/signature_help.ex:4: ElixirLS.LanguageServer.Providers.SignatureHelp.signature/3
        (language_server) lib/language_server/server.ex:425: anonymous fn/3 in ElixirLS.LanguageServer.Server.handle_request_async/2

Thanks for Wiki! It was very helpful.
But I have one problem with elixir_ls (MacOS Mojave, Emacs 26-HEAD, Spacemacs dev branch)
I was able to setup it with Spacemacs, and it works mostly ok.
But with all *_test.exs files I have this error:

LSP :: an exception was raised:
    ** (FunctionClauseError) no function clause matching in Code.ensure_loaded/1
        (elixir) lib/code.ex:985: Code.ensure_loaded({{:., [], [Ecto, :{}]}, [], [Query, Changeset]})
        (elixir_sense) lib/alchemist/helpers/module_info.ex:64: Alchemist.Helpers.ModuleInfo.get_module_funs/1
        (elixir_sense) lib/alchemist/helpers/module_info.ex:52: Alchemist.Helpers.ModuleInfo.has_function?/2
        (elixir) lib/enum.ex:2948: Enum.find_list/3
        (elixir_sense) lib/elixir_sense/core/introspection.ex:628: ElixirSense.Core.Introspection.find_imported_function/2
        (elixir_sense) lib/elixir_sense/core/introspection.ex:602: ElixirSense.Core.Introspection.actual_mod_fun/4
        (elixir_sense) lib/elixir_sense/providers/docs.ex:12: ElixirSense.Providers.Docs.all/4
        (elixir_sense) lib/elixir_sense.ex:50: ElixirSense.docs/3
        (language_server) lib/language_server/providers/signature_help.ex:4: ElixirLS.LanguageServer.Providers.SignatureHelp.signature/3

The Code.ensure_loaded error look like:

But I haven’t seen the no function clause matching in ElixirSense.Core.Source.tokenize_prefix/1 before, please file an issue (ideally with a reproduction case!) on Issues · elixir-lsp/elixir-ls · GitHub and we’ll try to take a look at it. Thanks!

Thanks, @axelson, for aggregating all of this knowledge and laying out the installation steps. I was able to get it all set up relatively quickly :+1:.

1 Like

Working great for me. Also to note it looks like JakeBecker’s repo is now the more active one (elixir-ls org now looks stalled).

1 Like