BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Language Server Protocol Support for Visual Studio

Language Server Protocol Support for Visual Studio

This item in japanese

Bookmarks

A corner stone of Visual Studio Code is an open standard known as the Language Server Protocol (LSP). A language server is essentially a compiler/analyzer that runs in a separate process. It handles a variety of tasks including compiler error reporting, hover text, code completion (i.e. IntelliSense), etc.

The concept of a language server isn’t new; editors such as Vim and Emacs have long used them for code completion support. The first major C# implementation of the concept is known as OmniSharp. This language server supports VS Code, Sublime, Atom, Emacs, Vim, and Brackets.

Another VS Code language server was created for TypeScript. Unlike OmniSharp, which uses HTTP, the TypeScript language server “communicates through stdin/stdout with the server process and uses a JSON payload inspired by the V8 debugger protocol for requests and responses”.

With two language servers integrated with VS Code, Microsoft felt it necessary to develop a common standard to be shared by them and future languages. This led to the creation of the Language Server Protocol.

JSON-RPC is used by Language Server Protocol as the basic message format. Briefly, JSON-RPC is a lightweight alternative to SOAP. Like SOAP, it doesn’t mandate a transport layer and thus can work equally well over stdio, named pipes, sockets, etc.

Visual Studio itself does not natively support the Language Server Protocol. For that you need an adapter that allows the VS language services to communicate with an LSP client. Microsoft DevLabs is providing just such a client named simply Language Server Protocol Client.

You will also need a language specific extension. The Language Server Protocol Sample github repository demonstrates how one may be created.

For a more complex example, you can look at Adam Driscoll’s Visual Studio Language Server Protocol extension for PowerShell. Regarding its capabilities, Driscoll writes:

I believe that the future of language support comes from LSP clients. A unified language service shared between Visual Studio and Visual Studio Code will have great results on both tools. We still have a ways to go. The LSP doesn’t support debugging. It’s a different protocol. The LSP itself isn’t even complete within Visual Studio. There’s a chart in the documentation about it. I anticipate it will take some time before this is completely available in VS.

Rate this Article

Adoption
Style

BT