VSCode & ElixirLS intellisense

I’m using the ElixirLS extension with VSCode and so far so good. However, my only nuisance is that I don’t get intellisense or jump to definition for functions that are imported from a use. For example, in a live view module (the one that has the mount/render/etc) that uses Phoenix.LiveView, I can’t jump to the definition of assign/2 or assign/3 . Hovering on it shows nothing either.

Additionally, my eex/leex templates have absolutely no intellisense. I am using the YAB for eex/leex extension to get the markup coloring. If I switch the language mode to Embedded Elixir (eex), then my code will have no coloring, no intellisense, basically it’s raw text editing.

So I’ve been working like this for a while, but I wonder if others have managed to get everything working nicely, in which case I’d have to figure out what’s wrong with my configuration. Thanks!

2 Likes

The only thing that kinda bothers me is that eex files do not format properly when you mix Embed Elixir with HTML blocks. Because of this, our code looks like crap if we use any kind of autoformatting.

To be honest, I haven’t noticed that I don’t get IntelliSense on eex files until you brought it up.

So I was able to finally fix the IntelliSense for imported functions and macros via use. Turns out the ElixirLS VSCode extension that ships on the marketplace comes with the language server that was built using Elixir 1.8 and Erlang 21, which are older versions than what my system has. Building the language server using my system’s Elixir and injecting that inside the extension did the trick. I wrote a quick post on my blog about all the steps https://dragoshmocrii.com/fix-vscode-elixirls-intellisense-for-code-imported-with-use/

Unfortunately, the eex/leex files still don’t have any IntelliSense.

@thiagomajesk for formatting you can try the “YAB for eex/leex” extension which works fine for me.

5 Likes

Heaps thanks, mate! I will try your solution shortly.

Something else that bugs me is that “go to symbol in workplace” [cmd + t] does not work for function names. It works for Module names only. At the same time, functions are indexed in the context of a single module, and I can navigate to them using [cmd + shift + o]. Do you have that working yourself?

For me, go to symbol works but is not consistent. For example I am unable to go to “assign” which is defined in Phoenix.LiveView. But for my application files, it works fine. I believe it might be an issue with code from dependencies.

May I ask whether you have created an Issue for this in the ElixirLS GitHub Repo already? If not, maybe it would be a good idea to do so and fix this for everybody who downloaded the extension :slight_smile:

1 Like

@thiagomajesk for formatting you can try the “YAB for eex/leex” extension which works fine for me.

I’m aware of this extension, but it has a hard dependency on Ruby :grimacing:.

That’s tracked in this issue:

As you found the workaround is to compile ElixirLS on a newer version. I believe there’s an issue for compiling the release on the end-user’s machine but no one has done work on that yet.

Unfortunately, the eex/leex files still don’t have any IntelliSense.

Yes, that currently isn’t supported (but a patch would be welcome).

2 Likes