What's the feasibility of creating an Elixir language server?

A lot of times while coding I"m making stupid mistakes. An missing parenthesis here, a missing end there, an unused variable, an unused function, etc…

Elixir’s compiler is very good about surfacing these errors and warnings in a clear an concise way (most of the time) but right now it’s not real time. Some editors have plugins which have recreated some of this functionality but it’s a very inconsistent experience between editors. Intellisense/Autocomplete is another feature that’s extremely inconsistent between editors right now.

These issues have had me pondering the feasibility of creating a language server that editors and IDEs can hook into to utilize the existing Elixir compiler and modules to provide all this functionality across the board in real time. You could also then relatively easily hook into @doc/@moduledoc tags to provide more context for what people are trying to access or look at.

The biggest issue in my (uneducated) min is that there would need to be some way to tell the compiler to not look at an ex/exs file on disk, but instead use the content passed in by the language server (for warnings/errors without explicitly saving). You would also then need to signal that the in memory version should then be ignored and use the copy on disk (when user closes a file without saving).

Presumably there should be the possibility to get details of compile issues, hopefully without parsing the same strings that get printed to stdout.

I also wonder how much of the code this would need to call is considered “private” internal Elixir code that has a big potential to to break in non-backward compatible ways in normal bug fixing and refactoring efforts.

Anyone more knowledgeable have any thoughts on the feasibility of this type of project?

3 Likes

Something like that…

1 Like

Yeah, it seems that there is already work done in this in alchemist-server. I believe it was originally extracted from the Alchemist tooling for Emacs.

It’s already used in Emacs, Vim (alchemist.vim), and VS Code (vscode-elixir). Atom’s atom-elixir package says that it uses an extended, API-incompatible version of alchemist-server.

What editor(s) and plugins are you using currently? I’ve only used Atom and Spacemacs for Elixir projects and at the very least the autocomplete has been reliable. There are separate packages for linters, though (like linter-elixirc and linter-credo in Atom).

2 Likes

Maybe I am wrong but up to now alchemist-server is not a language-server yet. It does not follow the protocol @KallDrexx mentioned.

It should be possible though and I think it is a nice convention to follow :slight_smile:

3 Likes

[quote=“bobbypriambodo, post:3, topic:3559”]
Yeah, it seems that there is already work done in this in alchemist-server. I believe it was originally extracted from the Alchemist tooling for Emacs.

It’s already used in Emacs, Vim (alchemist.vim), and VS Code (vscode-elixir). Atom’s atom-elixir package says that it uses an extended, API-incompatible version of alchemist-server.

I currently us VS code, as I’ve had a terrible time trying to get Atom to work and not crash constantly, and I use it for my other language work anyway.

I assumed that this stuff was missing because the vscode plugin was more bare bones than it really is, so I guess the better option is to improve the alchemy server (or plugin) to provide support for the missing features., thanks.

1 Like