Vscode setup November 2020

It’s November 10, 2020. I would like to use vscode to work on two elixir 1.8 projects (one is an umbrella, one is not.)

I’m looking for this set of feature:

  • syntax highlighting
  • live display of obvious syntax errors (e.g using Foo.Bar{} instead of %Foo.Bar{})
  • autocomplete for obvious things (e.g, I’ve typed X times the name of the module Foo.Bar ; typing Foo. and someCtrl-Space-like shortcuts should complete the Bar` part
  • some sort of navigation between modules (clicking on a fully qualified function name like Foo.Bar.baz, defined only in a single Foo.Bar module, without any aliasing, should open the foo/bar.ex module on the right line.)
  • automatic indenting, but no automatic formatting (I run the formatter at commit time)
  • no automatic running of any application, test, etc… in the background
  • no “hidden” elixir beam running in the background and crashing all the time (it’s okay if it runs, but does not crash more than once per week.)

Is there any setup that makes this possible, sorta-out-of-the-box ?

I know there are half a dozen extension in the marketplace related to elixir, but it’s not clear:

  • which one to use
  • if several are needed, and if they are compatible or not
  • if using an external component (Elixir LS ?) is mandatory or not, if I can expect the vscode extensions to install them properly
  • if the “umbrella” structure is expected to break all of this.

If anyone is having such a workflow in November 2020, I’m interested.

Thanks.

In vscode ElixirLS (not the fork, that one is no longer needed) does all of those things at least in a best effort. The extension brings in the language server automatically, so no need for something external. Depending on the project it might however not be as stable as you want it to be, but imo it’s still the best solution out there. Others are older, less maintained and likely also less feature complete.

In regards to formatting: ElixirLS does allow formatting, but you can disable it via the vscode settings.

Thanks, do you have a URL / pointer / github link to the proper extension, then ? (I don’t want to mistakenly install “the fork”, or “the one that is no longer maintained”.) I’ll try to document the installation process / setup in this thread to clarify what’s working and what is still not.

https://marketplace.visualstudio.com/items?itemName=JakeBecker.elixir-ls

But also the fork has “fork” and “deprecated” written in capitals in it’s name :smiley: it should be rather obvious.

Ok. Is it compatible with mjmcloug.vscode-elixir , or should I uninstall this extension first ? (Yes, I’m cautious, but as you can probably guess, I’ve been bitten the last few times I tried those extensions.)

I’m not sure if it’s incompatible, but you shouldn’t really need both. Most of what it does was adopted into ElixirLS as well.

vscode-elixir is essentially unmaintained at this point. You should at least disable it while using ElixirLS, but I would recommend uninstalling.

So, after disabling vscode-elixir, restarting, installing jakebecker.elixir-ls, restarting, restarting just in case, reloading the projects, and, crucially, waiting for a few dozen seconds at least at first run:

  • syntax highlighting :white_check_mark:
  • live display of obvious syntax errors (e.g using Foo.Bar{} instead of %Foo.Bar{}) :white_check_mark:
  • autocomplete for obvious things (e.g, I’ve typed X times the name of the module Foo.Bar ; typing Foo. and someCtrl-Space-like shortcuts should complete the Bar` part :ballot_box_with_check:
    • Sorta work, but I still run into cases where a function name or variable defined in the very same function is not autocompleted
  • some sort of navigation between modules (clicking on a fully qualified function name like Foo.Bar.baz, defined only in a single Foo.Bar module, without any aliasing, should open the foo/bar.ex module on the right line.) :white_check_mark:
    • To my huge surprise, it also works between apps of an umbrella, I vividly remember it not working
  • automatic indenting, but no automatic formatting (I run the formatter at commit time) :ballot_box_with_check:
    • Does not really apply to vscode, which does not really autoindent (I was thinking of emacs), but at least the formatter does not run automagically by default, so my code is not screwed
  • no automatic running of any application, test, etc… in the background :question:
  • no “hidden” elixir beam running in the background and crashing all the time (it’s okay if it runs, but does not crash more than once per week.) :question:
    • There is a beam running in the background, but so that it has not obviously crashed.

So, all in all, i’m pretty satisfied (and suprised.)
I guess my previous experiences where with the wrong extension, or with the unmaintained one (or some specific part of my project that I have not run into again.)

Thanks !

ElixirLS is indeed incompatible with vscode-elixir

I would like to work on the stability of ElixirLS because that could be improved. Lowest hanging fruit in that area is around formatting.

Anyway, I’m glad you’re enjoying ElixirLS!