Allow to lookup Elixir source files under configured location #277
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Greetings!
elixir_sense
usesmod.module_info(:compile)[:source]
in order to retrieve the source file for a module. While it works for regular Elixir files and dependencies, it fails for the Elixir sources (i.e., for the applications like:elixir
,:ex_unit
,:eex
that ship with Elixir) if Elixir was built in a sandboxed environment. That happens, for example, on NixOS as it returns a path to a build location that no longer exists:("/build/source" refers to a location that contained Elixir source while it was being built inside a sandbox.)
Despite that, on NixOS it's easy to install the Elixir source as a package and provide the path to it as an environment variable.
Click me to get NixOS-specific info!
flake.nix:
This PR makes
ElixirSense.Location
to look up Elixir sources under the configured location as a fallback. This will allow for code navigation to Elixir sources to work on environments like NixOS.Sadly, I have no idea how to write tests for this, so any suggestion is appreciated. Meanwhile I tested it manually on my machine in an IEX session:
If this PR is merged, I will open another one in https://github.com/elixir-lsp/elixir-ls that will read
$ELIXIR_SRC
at the server startup and configure:elixir_sense
accordingly.