Rust tutorial on writing a lsp server?

There is no shortage of Rust tutorials on building new languages; but it is hard to use a language without decent IDE support.

Are there any Rust tutorials on writing a lsp server for a new language ?

1 Like

There aren't many tutorials on building IDE support for a language in general, and it can be harder than building a compiler.

But generally, writing an IDE plugin in Rust is done just like in any other language (unlike compilers, they don't usually have bytecode or cyclic IRs), and building a LSP server is done just like using any other language. There is the lsp-types crate that helps with the all around.

You can inspect the code of rust-analyzer, it is pretty well-written but uses advanced stuff like Salsa.

1 Like

I don't know about you, but I learned compilers on toy languages, not rustc. :slight_smile: Is there anything simpler than rust-analyzer that you would recommend ?

I don't know specifically of any tutorials, but there are some good examples,
besides the examples dir in tower-lsp

the nix-language-server small goes a bit beyond the tower examples in having mutable state for files, but i believe still on an older version of tower-lsp

a language server for the nano_rust.rs parser that comes with chumsky tower-lsp-boilerplate which uses quite a few lsp features, but still remains relatively small and readable...

That said matklad does have a youtube explaining rust-analyzer to help familiarize and get into the rust-analyzer code base.

I don't really know of any outright tutorials though

4 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.