ChrisAmelia

ChrisAmelia

Educational project

I was always intrigued by how IDEs provide smart completions when you press certain keys, how the diagnostics hit right, and all the mechanics they provide behind the scenes.

So I decided to dive into the process behind it: the Language Server Protocol. I also wanted to learn Elixir and ended up building an educational language server in Elixir.

While this is educational, I have implemented some basic functionalities regarding English writing:

  1. Shows the definition of the word under the cursor by calling vim.lsp.buf.hover() (default to K in Neovim).
  2. Sends an error diagnostic if the document contains VS Code.
  3. Suggests a list of words for completion.
  4. Suggests some code actions: replace VS Code with Neovim or censor it with VS C*de.

Any feedback, especially on the Elixir part, is welcome. I’m looking to get better in that language.

Architecture

  1. There are two GenServer: InputServer and LSPServer. They are both initialized in the module Application by a Supervisor.
                                    ┌──────────────┐ 
                               ┌───►│  InputServer │ 
                               │    └──────────────┘ 
                               │                     
                               │                     
                               │                     
  ┌─────────────┐  initialize  │                     
  │ Application ├──────────────┤                     
  │  Supervisor │              │                     
  └─────────────┘              │                     
                               │                     
                               │                     
                               │    ┌───────────┐    
                               └───►│ LSPServer │    
                                    └───────────┘    
  1. This is where the life cycle starts: InputServer listens on stdio.
    2.1. InputServer sends that message to LSPServer.
    2.2. LSPServer processes it and sends back a result to InputServer.
                                     
                                     
           message                   
  ┌──────┐         ┌─────────────┐   
  │client├────────►│ InputServer │   
  └──────┘         └───┬────▲────┘   
                       │    │ result 
                       │    │        
                       │    │        
               convey  │    │        
                    ┌──▼────┴───┐    
                    │ LSPServer │    
                    └───────────┘    
                                     
  1. InputServer sends the result back to the client and then loops back to listening on stdio.
                                                               
                                                               
                                              ready to listen  
                                            ┌──────────┐       
                                            │          │       
                                            │          │       
                                            ▼          │       
                               ┌───────────────┐       │       
   ┌────────┐  result          │               ├───────┘       
   │ client │◄─────────────────┤  InputServer  │               
   └────────┘                  │               │               
                               └───────────────┘               
                                                               
                                                               

Notes

I have encountered two challenges that I haven’t solved in the Elixir way.

When and how to properly shut down the application?

I have set two System.stop() at two different occasions, which I found redundant:

  • when the client sends the shutdown request,
  • when :eof is received after listening with IO.read(:stdio, :line).

Process still runs in the background if a crash happens

In the life cycle of InputServer, if a crash happens (example String.split(nil, "\n")),
the process is still alive even after having closed Neovim, probably a zombie?
The only fix I have found was finding the source of the issue by checking the logs and correcting it.

Where Next? Top

Trending in Discussions Top

cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
achempion
I’ve been using Emacs as my main code editor for more than a two years. It’s a custom build version although I’ve tried doom emacs and sp...
New
axelson
Hi there! :wave: @frigidcode and I (but mostly him) have been running an Elixir Book club, we’re almost done with Designing Elixir Syste...
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New

Other Trending Topics Top

ausimian
Wagyu is a user-mode WireGuard library for Elixir. It allows you to create an encrypted tunnel to another WireGuard peer and then tunnel...
New
GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
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
georgeguimaraes
Just published claude-code-elixir, a plugin marketplace for Claude Code with Elixir support. These are the plugins I’ve been using for my...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews