BT

Microsoft Has Open Sourced the VS Code Language Server Protocol

| by Abel Avram Follow 5 Followers on Jul 09, 2016. Estimated reading time: 1 minute |

A note to our readers: You asked so we have developed a set of features that allow you to reduce the noise: you can get email and web notifications for topics you are interested in. Learn more about our new features.

Microsoft has open sourced the protocol used by VS Code’s editor to communicate with the various language servers supported.

Visual Studio Code is an IDE from Microsoft supporting over 150 languages. To be able to carry this out, the Monaco Editor included with the tool validates the code –syntax checking, error reporting, etc – and provides Intellisense and refactoring support through language servers. Usually, there is one such server for each programing language supported. The communication between Monaco and these servers is done through the Language Server Protocol (LSP), which Microsoft has recently open sourced.

Because code validation can be a resource-expensive operation, language servers are executed in separate processes. They can be written in various languages, exchanging information with the editor through a lightweight JSON-RPC-based protocol via stdin/stdout. The protocol was inspired by the V8 debugger protocol according to Erich Gamma, the computer scientist now working on Visual Studio for Microsoft.

Similarly to HTTP, LSP includes a header section followed by a JSON-RPC content section, as shown in the following snippet:

Content-Length: ...\r\n
\r\n
{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "textDocument/didOpen", 
    "params": {
        ...
    }
}

The header can contain two fields specifying the content length and type. The content is represented by a request sent to the language server or a response received from it. This section is used to send messages, notifications, and commands. Language servers can extend the features available for code validation by specifying the capabilities supported. Because it is possible to send multiple requests to different language servers at the same time, each packet includes an ID field so the editor can distinguish between replies.

The LSP decouples the editor from the language servers it uses, making it possible to use many such servers in one IDE or to reuse a language server in multiple IDEs supporting the protocol. Microsoft and other vendors already have created such servers for C++, CSS/LESS/SASS, JSON, PowerShell, Xtext, PHP and others. Eclipse Che has adopted LSP and plans to use it to add support for C/C++, C#, Go, JSON, R, TypeScript, RAML and XML. Red Hat will contribute a Java language server to Eclipse Che. There are SDKs for C#, Haxe, Java, and Node.js.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT