InfoQ Homepage News Microsoft Has Open Sourced the VS Code Language Server Protocol
Microsoft Has Open Sourced the VS Code Language Server Protocol
This item in japanese
Jul 09, 2016 1 min read
by
Write for InfoQ
Feed your curiosity. Help 550k+ globalsenior developers
each month stay ahead.Get in touch
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.
This content is in the Microsoft topic
Related Topics:
-
Related Editorial
-
Related Sponsors
-
Popular across InfoQ
-
AWS Introduces ECS Managed Instances for Containerized Applications
-
Producing a Better Software Architecture with Residuality Theory
-
GitHub Introduces New Embedding Model to Improve Code Search and Context
-
Google DeepMind Introduces CodeMender, an AI Agent for Automated Code Repair
-
Building Distributed Event-Driven Architectures across Multi-Cloud Boundaries
-
Elena Samuylova on Large Language Model (LLM)-Based Application Evaluation and LLM as a Judge
-
Related Content
The InfoQ Newsletter
A round-up of last week’s content on InfoQ sent out every Tuesday. Join a community of over 250,000 senior developers. View an example