lexical-lsp / lexical

Lexical is a next-generation elixir language server
775 stars 77 forks source link

Jump to Elixir source definition #772

Open rodrigues opened 2 weeks ago

rodrigues commented 2 weeks ago

Hey, thanks for all the amazing work with lexical.

Jumping to erlang core code (e.g. :timer.minutes(5)) is working great, getting to asdf erlang source.

I can't jump to elixir core code though (e.g. Supervisor.init(...)) (elixir 1.16.3, erlang 26.2.5, eglot).

I imagine it's not an issue, it's just not implemented yet, right?

It would be so great to have this.

Cheers!

scohen commented 2 weeks ago

Correct. I’m actually not sure why erlang works but elixir doesn’t, but we don’t index the elixir source. I’ll investigate soon

miguno commented 2 weeks ago

For elixir-ls (another LSP for elixir), the solution to this problem is to install elixir from source, i.e., to use a self-compiled elixir version.

elixir-ls uses a launcher script called elixir-ls/launch.sh, which you can customize. For fixing the "go to definition" issue, I had to add the following line to the launcher script to make sure that the self-compiled version of elixir is found before any other elixir versions (I normally manage elixir versions with mise; that's why I want to put the self-compiled version on the $PATH only for elixir-ls, but not in general).

export PATH="/path/to/your/self-compiled/elixir/bin:$PATH"

This allowed me to use Go To Definition etc. from neovim via elixir-ls.

Perhaps this solution for elixir-ls applies to this issue for lexical, too?

rodrigues commented 1 week ago

hi @miguno, thanks for the suggestion.

I've just tried it locally, prepending to $PATH in start_lexical.sh the elixir compiled from source (1.16.3), it didn't work:

[jsonrpc] e[10:56:30.052] --> textDocument/definition[26] {"jsonrpc":"2.0","id":26,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///.../application.ex"},"position":{"line":14,"character":25}}}
[jsonrpc] e[10:56:30.086]   <-- textDocument/definition[26] {"id":26,"result":null,"jsonrpc":"2.0"}