JakeBecker

JakeBecker

ElixirLS - the Elixir Language Server

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!

1144 53690 245

Most Liked

axelson

axelson

Scenic Core Team

Version 0.4.0 was released today! :confetti_ball:

(Note that there are some potentially breaking changes for VSCode users)
(Note: if you’re using the “ElixirLS Fork” version of the VSCode plugin you should switch back to ElixirLS)

Here are the highlights:

General:

Major changes:

Changes:

  • Add all core elixir apps to the Dialyzer PLT. (thanks Eric Entin) #225
  • Change “did not receive workspace/didChangeConfiguration” log level from warning to info (thanks Jason Axelson) #222
  • Automatically create a .gitignore file inside the .elixir-ls dir so that users do not need to manually add it to their gitignore (thanks Thanabodee Charoenpiriyakij) #232
  • Load all modules after first build (thanks Akash Hiremath) #227
    • This means that dialyzer is no longer needed for workspace symbol support :tada:

Bug Fixes:

  • Don’t return snippets to clients that don’t declare snippetSupport (such as vim) (thanks Jeffrey Xiao) #223

VSCode:

  • Better phoenix templates support (thanks Marlus Saraiva) #93
  • Add basic support for .html.leex files for Phoenix LiveView (thanks oskarkook) #82
  • Add filetype and watcher for .html.leex files for Phoenix LiveView (thanks Byron Hambly) #83

VSCode potentially breaking changes:

  • Change language id to be lowercase kebab-case in accordance with VSCode guidelines. This also fixes an issue displaying the elixir logo for html.eex files. (thanks Matt Furden) #87
    • This changes the language id’s EExeex and HTML (EEx)html-eex
    • If you have customized your emmet configuration configuration then you need to update it:
    • Open VSCode and hit Ctrl+Shift+P or Cmd+Shift+P and type "Preference: Open Settings (JSON)"
    • Add or edit your emmet.includedLanguages to include the new Language Id:
      "emmet.includeLanguages": {
        "html-eex": "html"
      }
      

Full changelog

I want to give a huge thanks to all the contributors to this release! :heart: As you can see from the changelog there are quite a few!

axelson

axelson

Scenic Core Team

Version 0.5.0 was released today! :confetti_ball:

Here are the highlights:

General:

Major changes:

Changes:

  • Support WorkspaceSymbols (go to symbol in workspace) without dialyzer being enabled (thanks Jason Axelson) #263
  • Add completions for @moduledoc false and @doc false (thanks Jason Axelson) #288
  • No longer always return a static list of keywords for completion (thanks Jason Axelson) #259

Bug Fixes:

Also numerous GitHub - elixir-lsp/elixir_sense: Provides context-aware information for code completion, documentation, go/jump to definition, signature info and more · GitHub changes, improvements, and bug fixes

VSCode Changes

Updating to the latest release should happen automatically

  • Major improvement: Support workspaces with multiple elixir projects (especially those where the Elixir project is not part in the root) (thanks Alessandro Tagliapietra) #70
    • Support per-folder configuration for many settings (makes the multi-workspace support more powerful) (thanks AJ Foster) #110
  • Major improvement: Improved support for phoenix templates (thanks Marlus Saraiva) #93
    • Shows errors in .eex and .leex files (instead of associated .ex file)
  • Improve syntax highlighting following pipes (thanks Dusty Pomerleau) #81
  • Activate extension whenever workspace contains elixir files (thanks Jason Axelson) #107
  • Make heredocs and most sigils auto-close when used with quotes and triple quotes (thanks Jarrod Davis) #101
  • Improve syntax highlighting following pipes (thanks Dusty Pomerleau) #81
  • Make % a dedicated punctuation scope in elixir syntax file (thanks Dusty Pomerleau) #72

I want to give a huge thanks to all the contributors to this release! :heart: As you can see from the changelog there are quite a few!

Full changelog

(Note: if you’re using the “ElixirLS Fork” version of the VSCode plugin you should switch back to ElixirLS)

JakeBecker

JakeBecker

Hi everyone! Long time no see!

If you’ve been using ElixirLS, you may have noticed that I haven’t really maintained it in a year or so. All my work for a while has been on hardware that doesn’t run Elixir, mainly 2x4s and drywall, and I told myself ElixirLS was on the backburner because I didn’t want to think of it as “abandoned”. But after a year of neglect, I’m ready to admit that I’m not going to be working on it in the near future.

I have excellent news though: While I’ve been away, a few proactive volunteers from the Elixir community started a fork and have put major work into actively maintaining it. I had long since routed my Github notifications somewhere they wouldn’t bother me, so I didn’t really realize how much work they’d been doing in my absence, and @axelson, @lukaszsamson, and other contributors have my gratitude and respect.

I’m retiring my Github repo in favor of theirs over at elixir-lsp/elixir-ls. They’ll continue publishing to the original VS Code extension, so if you’re using the original ElixirLS for VS Code, you can keep using it. If you’ve been using their fork, you can switch back to the original extension. Any issues or PRs should happen on the new repo. Starting an open-source project is more fun than maintaining one, so if you file an issue over on that repo, make sure to say thanks for their hard work.

I do hope to go back to coding Elixir at some point once my house has walls and toilets and everything. In the meantime, I’m happy the project is in good hands. Thanks for using ElixirLS!

Where Next?

Popular in Discussions Top

vans163
So useless benchmarks aside, Its possible to write a webserver that can serve 300k requests per second (perhaps more with optimizations)....
New
andre1sk
A big advantage to Elixir is all the distributed goodness but for many applications running on multiple nodes having integrated Etcd, Zoo...
New
Rustixir
Hi everyone, im working on find best language/framework/system for high concurrency, high performance and stable performance after wor...
New
laiboonh
Hi all, I am trying to convince my team to use liveview over the current react. What are some of the points where one should consider us...
New
Fl4m3Ph03n1x
Background A few days ago I was listening to The future of Elixir from Elixir Talks, with Dave Thomas (@pragdave ) and Brian Mitchell. I...
New
crispinb
On reading dhh’s latest The One Person Framework it strikes me that Phoenix with LiveView is already pretty much this. However, never hav...
New
AstonJ
I’ve just started the Phoenix part of the utterly brilliant online course by @pragdave. On generating the Phoenix app he uses the --no-ec...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
restack_oslo
Hello, Please pardon me for any faux paux. I am 46 and this is my first time on a forum of any kind. I wanted to to get answers from tho...
New
paulanthonywilson
I like Umbrella projects and pretty much always use them for personal Elixir stuff, especially Nerves things. But I don’t think this is ...
New

Other popular topics Top

danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29377 241
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39297 209
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement