Note: ElixirLS from Source

December 4, 2024
elixir

While the standard ElixirLS installation works well for most developers, running it from source provides access to the latest features and improvements. Recently, after discussing this setup with a colleague, I realized others might benefit from learning how to implement this configuration.

Before proceeding, ensure you have Erlang and Elixir installed on your system. While I personally use Mise for version management, asdf works as well.

Begin by cloning the ElixirLS repository and installing its dependencies:

git clone [email protected]:elixir-lsp/elixir-ls.git
cd elixir-ls
mix deps.get

Next, compile and install ElixirLS. I recommend storing it in ~/.local/share for better organization. The installation commands vary slightly depending on your shell:

For Fish shell users:

env MIX_ENV=prod mix compile
env MIX_ENV=prod mix elixir_ls.release2 -o ~/.local/share/elixir-ls

For Bash or ZSH users:

MIX_ENV=prod mix compile
MIX_ENV=prod mix elixir_ls.release2 -o ~/.local/share/elixir-ls

Editor Configuration

After installation, the executables will be available in ~/.local/share/elixir-ls. You’ll need to configure your editor to use this installation.

For Zed, add the following to your configuration:

"lsp": {
  "elixir-ls": {
    "binary": {
      "path": "/Users/<you>/.local/share/elixir-ls/language_server.sh"
    }
  }
}
  • Neovim users can reference my configuration on GitHub.
  • VSCode users should update the elixirLS.languageServerOverridePath setting.

To maintain the latest version of ElixirLS, simply pull the latest changes from the repository and recompile:

cd elixir-ls
git pull
MIX_ENV=prod mix compile
MIX_ENV=prod mix elixir_ls.release -o ~/.local/share/elixir-ls

This setup ensures you always have access to the most recent ElixirLS features and improvements while maintaining a clean, organized development environment.

Make and jump into directory easily Comparisons in Javascript