Recompiling ElixirLS
If you’re using the ElixirLS extension in VSCode and your project uses a newer version of Elixir and/or Erlang/OTP than what the extension uses, you may not be getting all of the features that ElixirLS provides.
As Dragosh
Mocrii
discovered, IntelliSense (aka ElixirSense) and the “jump to definition” features
won’t work for functions and macros imported with use
.
As of this writing, I’m using Erlang 25.1.2 and Elixir 1.14.2, but ElixirLS seems to be using Erlang 22.x and Elixir 1.12.x.
The solution is to recompile ElixirLS with the versions of Elixir and Erlang that your project uses.
Dragosh gives a set of instructions in his blog post. You can also refer to the vscode-elixir-ls README.
I’ve distilled these two sources into a set of instructions that works well for me (at least on MacOS) and posted them to a Gist, which I’ve also included below to save you a click.
# First time only
git clone --recursive git@github.com:elixir-lsp/vscode-elixir-ls.git
cd vscode-elixir-lsp
# Second and subsequent times
cd vscode-elixir-lsp
git pull && git submodule update --recursive
# Always
npm install
cd elixir-ls
asdf local erlang {desired version}
asdf local elixir {desired version}
asdf install # should do nothing, but just to be safe
cd ..
rm *.vsix
npx vsce package
code --install-extension *.vsix --force