Your First Volar Language Server
In this guide, we will create a simple Volar language server and VS Code client. To keep things simple, it will look suspiciously like HTML, albeit with one twist: Only one
<style> tag will be allowed. We’ll call it HTML1.
💡 Interested in seeing the final product? Check out the starter project on GitHub.
- Visual Studio Code version 1.55 or higher.
- Node.js version 14 or higher.
We’ll first create a new project directory and initialize a new Node.js project.
In order to be able to have both the language server and the VS Code client in the same repository, a common pattern for language servers, we’ll create a new
packages directory that will contain both parts, this is effectively known as a monorepo.
Since this guide mainly focuses on creating a server we’ll start by creating the client so that we can get that out of the way. The client will be a VS Code extension, which necessitate a
package.json with a few specific fields. As such, update your
package.json to look like this:
We’ll also be installing a few dependencies from Volar and VS Code. Run the following command from the
packages/client folder to install them: