8 stories
today

At DevNation, Microsoft introduces open-source Language Server Protocol

Visual Studio Code (VS Code) is a universal code editor that works with any programming language. Currently, VS Code supports 150 programming languages available in the editor itself or through extensions available in the Visual Studio Marketplace. Everything that powers VS Code is open source and one of its more important parts adds support to VS Code by creating a “language server protocol.”.

Today, Microsoft, Red Hat, and Codenvy announced this new language server protocol at the DevNation conference in San Francisco. The JSON-based protocol is used by developers and programming language creators industry-wide. The new language server protocol assists programming language creators to improve usability for their language across a variety of development tools and operating systems. The language server protocol provides developers with a consistent editing experience using their favorite programming language, regardless of the tool they use, even if the tool isn’t VS Code.

Microsoft provides a basic idea of how this language server protocol works. VS Code provides the support needed for any programming language that is currently available industry-wide. Microsoft provides an example of how the new language server protocol would work in a developer editing session.

VS Code, Language Server Protocol

Language Server Protocol typical editing session

VS Code allows for interaction with multiple language servers, regardless of the programming language and programming tool that is used as long as it uses the same JSON-based protocol. Microsoft provides a step-by-step guide on how a typical editing session would play out over JSON-RPC:

  1. The user opens a file (referred to as a document) in the tool: The tool notifies the language server that a document is open (didOpen) and that the information about that document is maintained by the tool in memory.
  2. The user makes edits: The tool notifies the server about the document change (didChange) and the semantic information of the program is updated by the language server. As this happens, the language server analyses this information and notifies the tool with the errors and warnings (diagnostics) that are found.
  3. The user executes ‘Go To Definition’ on a symbol: The tool sends a definition request to the server. The server responds with a uri of the document that holds the definition and the rangeinside the document. Based on this information, the tool can open the corresponding document at the defining position.
  4. The user closes the document (file): A didClose notification is sent from the tool, informing the language server that the document is now no longer in memory and instead maintained by (i.e. stored on) the file system.

The specification for the language server protocol is available via GitHub, along with a history of the protocol. If you want to learn more about this language server protocol, you can view the DevNation keynote below.

https://www.youtube.com/watch?v=nxnIpgHQ-Gw

Otherwise, the language server protocol repo is available on GitHub. Additionally, the Language Server Walkthrough gives you an in-depth look at the source code of a language server example.

Further reading: , , , , ,

Do you use VS Code? How would the Language Server Protocol help you?