Elixir IDEs and developer tools

Hi all, I’m new here and I’d like to apologise if this question isn’t exactly original, however, I haven’t found a satisfactory answer to my questions, so I’m posting this here anyway.

I’m getting started with Elixir and I haven’t quite figured out what IDE to use with it. I’d like to understand what tools are other Elixir developers using and I’d also like to highlight problems that I ran into while setting up my development environment. We might not be able to resolve all of them, but perhaps we might be able to resolve at least one.

I come from an IntelliJ background and here is the summary of what I’ve tried and where I’ve experienced problems:

  • IntelliJ with the Elixir plugin: as I mentioned above, IntelliJ would be my preferred IDE, however even after installing the Elixir plugin and setting both Elixir and Erlang SDKs, IntelliJ isn’t complaining about anything but auto-completion and definition lookups don’t seem to work. I’ve found a number of related issues, like this one, but haven’t been able to resolve this problem.
  • RubyMine with the Elixir plugin: I thought this should be very similar to IntelliJ, but I ran into a different problem when using RubyMine, I got an error “Elixir Module SDK is not defined” and even though there is a button next to it that says “Setup Elixir Module SDK”, nothing happens when I click it. If I go into Preferences --> Languages & Frameworks --> Elixir --> SDKs and if I try to set an Elixir SDK, I get an error “Cannot save settings: please specify a different SDK name”. At least here I had an error to work with, but after about 20 minutes I’ve given up and decided to try option 3 (below)
  • VS Code with the Elixir extension: This option works the best and I’m actually beginning to like VS Code. My biggest and so far the only problem is refactoring. In IntelliJ (or related tools) it’s as easy as Ctrl+T and all uses and definitions of the thing you are trying to refactor are updated, whereas in VS Code this seems like a major hassle. I’ve found ways to change a definition within a file but not throughout the project. If anyone has any suggestions here, then please let me know

Thank you all in advance for reading!

1 Like

I use neovim + coc with elixir extension

For a non vim user, it’s rough at begining but you have everything you need

1 Like

Same here (although I’m actually using Vim + alchemist vim).
I found out that I needed way less setup/plugins to get everything I needed compared to my Ruby/RoR setup.

@crova and @rodesousa, thank you for sharing! I was hoping to get one of the JetBrains IDEs or VS Code working here, but if vim happens to be the objectively better option here, then I’ll consider switching further down the line. Either way, it’s good to know that there is a good solution out there even if I’m not a fan of it :slight_smile:

2 Likes

I’m pretty new to elixir as well, with a similar background as you (IntelliJ for most projects). I found that VSCode was (as you said) surprisingly nice. Refactoring is definitely a challenge, though I can’t say I have found it too much of an issue.

I work in a windows environment, though I prefer linux, and have found that WSL2 with alpine does everything I need. VSCode connects to it directly, and iex is much more pleasant (autocomplete works, pretty colors).

For me the biggest shift, coming from intellij and java and huge unwieldy codebases, is the simplicity. Building systems in Elixir (and they certainly feel and act like systems rather than plain old applications), somehow manages to organize complexity in a clean and manageable way. Having an IDE for Java is almost always necessary because there are often so many pieces flying around that it helps keep them all straight. With Elixir, it all just doesn’t seem so messy.

I hope this helps - your background definitely sounds a lot like mine, so I can understand the initial struggle to get comfortable with Elixir. But certainly it is worth every discomfort and mind-shift.

4 Likes

Great, thank you for sharing!

Your background does indeed seem similar to mine which means you’d probably understand how I ended up with a minor panic attack when I switched to a dynamic language with a fairly loose IDE :laughing: I have to agree that I haven’t found this to be a problem yet, I was just thinking about what happens further down the line because I would like to develop some stuff with Phoenix. Given the nature of the language, I can understand how my concerns may be exaggerated, so I’ll proceed with VS Code for now.

In VSCode I use CTRL + SHIFT + H to replace something in all files of the project, and then there is this tiny symbol next to the filenames that applies the change, it appears as soon as you select a file.

2 Likes

Ah, it works, excellent! It looks like there are a bunch of plugins for this and VS Code internal capabilities some of which just don’t work while others only work with specific languages, but this command seems to have done the trick. Thanks for sharing! BTW, for anyone using a Mac it’s CMD+SHIFT+H

FYI - have had a lot of success with using the Elixir plugin for Rubymine. It’s a little awkward to set the SDK, but after that, it works well. Under Languages in Preferences, click the arrow to expand Elixir and show the SDK options for Elixir and Erlang. Click the + under each and you’ll have to set the path by navigating to the appropriate directory where you have installed each. In my case, using ASDF, it’s under ~/.asdf/installs/elixir/<your version here>. Do this for Elixir under SDKs and Erlang under Internal Erlang SDKs. After that, you should see this version of Elixir in the SDK selection for the language (i.e. with the drop-down collapsed).

I haven’t gotten to try Vscode yet. I see a lot of folks using it, but I also use RM for my day job, so it’s more about familiarity than anything for me. The debugger works well for Elixir too.

Personally, I use Doom Emacs with ElixirLS for development. But my general sense is that the majority of Elixir developers now use VSCode (and VSCode is significantly easier to get started with than Emacs). So VSCode is my general recommendation (with ElixirLS and not vscode-elixir since it is not maintained).

With Elixir, it is generally reasonable to use generic project-wide (and sometimes single-file) search and replace to refactor variable names. Or at least reasonable enough that no-one’s created tooling to do context-aware refactoring. But if someone were to implement refactoring in ElixirLS that would be much appreciated and could then be used across a large variety of editors.

3 Likes

Yeah, that’s what I tried originally, but that didn’t work. I get an error: “Cannot Save Settings: Please specify a different SDK name”. Based on quick research it means that the SDK is already set somewhere, but I’m not sure where. If I open an Elixir project, it warns me that there is no Elixir SDK and if I click on the corresponding button to “Set Elixir Module SDK” nothing happens.

Great, thanks for the info! ElixirLS is the extension that I’m using at the moment.

1 Like

I’ve had it installed for quite a while so maybe something broke recently. I did find this on the plugin’s issues list on GitHub. Instead of clicking OK, click Apply and then Cancel when mapping the paths…then it should let you pick the SDK from the dropdown.

Also if you started IntelliJ in the project directory and are using Rubymine or one of the other “small IDE’s”, delete the .idea directory from the project and retry in the small IDE. Sometimes the full Intellij puts things in that are not compatible with the small IDE’s like RubyMine.

Thanks for the suggestion! Unfortunately, I’ve already tried the “cancel” trick, it does allow me to keep the Elixir SDK in the settings, but I’m still getting the warning “Elixir Module SDK is not defined”. Here is a screenshot of this. I haven’t tried the other suggestion though: removing the .idea folder from the project. After doing that, the error has changed from “Elixir Module SDK is not defined” to “Elixir Facet SDK is not defined”.

You can try Onivim2 which gives you the best of vim and vscode. It is very fast, nice and neat. :wink:

3 Likes

I also use VSCode. Coming from Jet Brains IDEs I struggled sometimes with VSCode but I’ve downloaded an official Microsoft VSCode Cheatsheet like this for Windows: VSCode Cheatsheet and it really helped me to get some traction!

Oh, that’s very useful indeed, thanks for sharing!

Just to throw another Vim experience in the mix (hee hee): I use vim + ALE + Elixir-LS. Recently I have had issues with that causing massive CPU usage (maxing out one core). I tried disabling Dialyzer in the Elixir-LS config but this did not help. Using credo as the linter seems to have resolved this problem so far and seem snappier in general. Credo also provides more guidance for stylistic changes, which I find helpful.

1 Like

Are you using that at all times now for Elixir development? That is what I’m betting on eventually, but seems a few months away from being fully usable. I’m coming from neovim+alchemist and at least one thing it’s missing is the ability to kick off a unit test under cursor last I checked.

Thanks for sharing! nice pun, I bet it gets thrown around a lot here :slight_smile: