LSP and Xtext Tutorial: Introduction
The Language Server Protocol (LSP), created by Microsoft, is one of the latest and greatest tools in the toolset of language engineers. As such, the maintainers of Xtext have implemented support for it. Since LSP is just a protocol, there are several ways to use it and also to consume it. One can for example, create an LSP server to be consumed by connecting to a standard TCP socket using a port and an address. One can also connect directly using standard input and output. On the other hand, there are several possible clients: one can use Eclipse, VS Code, or Theia. Each one can also use different ways to connect to the server.
There are several examples of how to do this. But while the examples show that it is possible, if you are only familiar with one or two of the technologies, it might be difficult to reproduce and understand the whole example. Indeed, to understand the VS Code example, it is required to have a basic understanding of the following technologies:
- Xtext (Java and Xtend)
- LSP (lsp4j)
- NPM (Node Package Manager)
- VS Code Extensions
Not only that is necessary, but one also needs to consider how all of these technologies interact to create a VS Code extension for a given DSL. The goal of this small series is to create an easy to follow path to recreate the examples provided by the documentation of Xtext. I try to reduce the technology footprint to the minimum to achieve maximum simplicity. I also assume that the reader already knows how to create a simple DSL using Xtext, and provide the steps from there to achieve a simple VS Code Extension. From the base of this tutorial we can proceed to more complex examples.
The next chapter of this tutorial is here: LSP and Xtext Tutorial: Creating the language