JakeBecker

JakeBecker

TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support and debugger integration to VS Code, and can (in theory) be used by other IDEs, too. Cross-posting this from my new blog here.

I’ve been spoiled by good IDEs. Once you’ve gotten used to an IDE like RubyMine or IntelliJ IDEA, it’s hard to go back to just using text editors.

Elixir has an open-source IntelliJ plugin, IntelliJ Elixir, and it’s quite good. A few months ago, I started contributing to its development, adding ExUnit test support and debugger integration. It was fun to work on, but I got a bit frustrated with having to write Java. The IntelliJ Elixir codebase is all Java and it’s quite large — it includes an Elixir lexer and parser written in Java, among other code intelligence features.

There’s another approach that other editors are using — write the code insight logic in Elixir, and run a server in separate process that communicates with the editor or IDE. The original Elixir editor plugin that used this approach was Alchemist for Emacs, and the author published the Elixir code powering it as Alchemist Server. Another developer built upon Alchemist Server and created Elixir Sense which is being used in Atom and VS Code. With respect to IntelliJ Elixir, I’m convinced that the “language server” approach is the way to go because of the code reuse it enables.

It turns out, Microsoft has embraced this approach. They’ve published a JSON-based standard they’re calling the Language Server Protocol for IDE-agnostic language support, and it’s the standard way to write language plugins for VS Code. Red Hat is also backing the protocol and has added support for it to Eclipse Che. Microsoft also published a spec for a similar protocol for debugger integration, the VS Code debug protocol.

I’ve just released an early alpha of ElixirLS, a language server implementing these protocols for Elixir. It’s got debugger integration supporting line breakpoints, plus most of the standard editor features such as autocompletion and go-to-definition. It also reports build warnings and errors immediately as you type.

The server code is available here, and the associated VS Code extension is here.

I want to be clear that this is a very rough release. I’ve only tested it on OSX using Elixir 1.4, and it has significant known bugs. (The extension won’t even launch with Elixir 1.3, and most features don’t work properly for umbrella projects, for example.) I’m hoping to iron out the kinks in the coming versions, but right now, it can’t be considered stable. I’m hoping that the Elixir community might have some good ideas on how to improve it. If all you want is a stable editor for Elixir, stick with whatever you’re using now.

The best thing about having a standard protocol for IDE support is that it’s super easy to contribute to. You don’t have to know anything about VS Code or any other IDE. The spec is simple and well-documented — if you can write Elixir, you can contribute! If you’re interested in more of how it works, I’ve written a couple more blog posts on debugging Elixir in VS Code and on some of the compiler hacks I needed to enable reporting build warnings and errors as you type.

I hope other Elixir developers find it useful, or at least interesting. Give it a try, and happy coding!

Showing Posts 1 to 10

WolfDan

WolfDan

Awesome! I been looking for this long time ago! Waiting for more updates :smiley:

I tried to run it on Windows (seems like a few bunch of people here use windows), the installation don’t gives any problem but when I open any elixir file it simply dont work:

just to report ^^

NOTES: I have disabled all the existing plugins of elixir in my VS Code, so seems like your plugin highlight the sintaxis (if the plugin dont do that please tell me maybe I did wrong when I disabled the old plugins)

JakeBecker

JakeBecker OP

The plugin does do syntax highlighting (which is copied directly from the other VS Code Elixir plugin). I was able to reproduce that failure. I’ll see if I can debug it soon. Windows is unfortunately rather foreign to me though.

smpallen99

smpallen99

Any thoughts on how to integrate this with sublime 3? I tried VS Code for a month (full time), but ended up going back to sublime. I just could not get a workflow that worked as well as sublime.

ChaseGilliam

ChaseGilliam

I’m pretty excited about this. I mainly use atom, but if this worked well I’d make the switch.

outlog

outlog

looks great - fyi there is a google soc project for this thing Google Summer of Code so maybe talk with @michalmuskala about getting the most out of everybody’s time..

ssboisen

ssboisen

Very cool, are you familiar with langserver.org? It’s a community-driven source of knowledge for Language Server Protocol implementations. Many existing implementations exist for different languages and editors.

JakeBecker

JakeBecker OP

Hm, someone more familiar with Sublime would have to implement a client for it. If someone did so, though, they’d get very good support for a lot of languages for free. Hopefully someone volunteers to take it on :slight_smile:

Edit: Looks like there is a project implementing Sublime support: GitHub - sourcegraph/sublime-lsp: An LSP adapter for Sublime Text 3. · GitHub

JakeBecker

JakeBecker OP

Ooh, I didn’t realize it was part of gsoc or I’d have applied! I’ll try to get in touch with them. Thanks!

JakeBecker

JakeBecker OP

I posted to the Beam Community mailing list: Redirecting to Google Groups

edmz

edmz

Is it too much to ask for instructions on how to run it standalone?

There is an LSP implementation in emacs that I would like to try it with.

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 92995 915
New
AstonJ
The obligatory hello world thread! Who are you and where are you from? :stuck_out_tongue:
4616 55835 594
New
caslu
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
arcanemachine
I was working on an Ecto migration and I needed a timestamp. So, for the nth time, I looked up the different data types for timestamps, a...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
matt-savvy
Is there a word for the ~> symbol used in Version strings? Do you also just call it a Squiggle Arrow™ ?!
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
aseigo
ICal is a library for interacting with iCalendar data. It parses iCalendars into typed Elixir structs via ICal.from_ics, and can prepare ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews