VSCode ElixirLS: Jump to definition for stdlib functions?

I am using VSCode + Elixir_LS

I have a piece of code that look slike:

    {:ok, pid} = Agent.start_link(fn -> %{} end)
    Agent.update(pid, fn map -> Map.put(map, :hello, :world) end)
    Agent.get(pid, fn map -> Map.get(map, :hello) end )

if I put mouse cursor over Agent.updat, it shows me the spec, the documentation, and examples.

However, if I hit ‘gd’ (jump to def in VSCode/Vim), it can’t find the definition.

Question: In VSCode/Elixir_LS, is there a way to jump to the definition (actual source code) of Elixir stdlib funcs ?

If the answer is no, is there some other IDE combo that will let me do this ?

You need to install Elixir from source, otherwise there’s no source to jump to.

Thanks for the insightful response.

Step 3 of

requires not merely cloning the source, but building it.

I’m on a weird Linux setup where running the newly built binary might be problematic. Can you offer insights on why Elixir_LS requires a newly built elixir rather than just a directory containing the sources ?

Thanks!

1 Like

Currently the issue is that if elixir was not compiled from source then ElixirLS doesn’t know where to get the source from, and specifically the source for the specific version of Elixir that you’re using. One idea is to download or configure elixir sources that could be used (although we’d have to make sure that the versions matched) in that case.

So a working solution would probably involve detecting:

iex(2)> Enum.module_info[:compile][:source]
'/home/build/elixir/lib/elixir/lib/enum.ex'

And then interactively prompting the user to download the elixir source code to a location on their file system (or possibly stashing it in the .elixir_ls directory) and then finishing jumping.

This ElixirSense issue has some further discussion:

So it is doable, but no one has done it yet.

1 Like

So I’ve been able to get ElixirLS intellisense to work with VSCode, but it’s insanely slow to find completions, definitions and flat out can’t find references most of the time. I have my own built in alias that basically turns ioip to |> IO.inspect(label: "", limit: :infinity. When I try to use it, it often is slow like molasses, but what is worse is that even if I try to use it a few minutes later, it can no longer find it and spins a while.

I’ve basically given up on ElixirLS–I also had to downgrade to a previous version in order to find the latest that still supports Elixir 1.8.x. So I’m no using vscode-elixir instead and it’s a ton faster and has a lot of the features I need/want but for whatever reason, intellisense no longer works at all.

/boggle