The Language Server Protocol (LSP) is an open protocol created & lead by Microsoft that defines a common language for programming language analyzers to speak. I’m extremely excited about it, and I believe that once your read more about it, you would too.
From the official LSP specification:
The Language Server protocol is used between a tool (the client) and a language smartness provider (the server) to integrate features like auto complete, go to definition, find all references and alike into the tool
Why?
LSP creates the opportunity to reduce the m-times-n complexity problem of providing a high level of support for any programming language in any editor, IDE, or client endpoint to a simpler m-plus-n problem.
Go | Java | python | JavaScript | ... | |
---|---|---|---|---|---|
Vim | |||||
Emacs | |||||
Atom | |||||
Sublime | |||||
VSCode | |||||
... |
For example, when Go came out, plugins were created for each major editor & IDE: Vim, Emacs, Atom, Sublime, VSCode, Eclipse, etc’. Instead of a community effort to create the best code analyzer, the community was focused on creating analyzers for each available tool.
Furthermore, when a new editor is created, it needs to support dozens of languages in order to gain traction - an impossible fit for small projects.
LSP allows language communities to concentrate their efforts on a single, high performing language server, while editor and client communities can concentrate on building a single, high performing, intuitive and idiomatic extension that can communicate with any language server to instantly provide deep language support.
State of LSP
Several companies have come together to support its growth, including Codenvy, Red Hat, Sourcegraph and of course Microsoft.
The protocol is becoming supported by a rapidly growing list of editor and language communities. All popular languages have a language server implementation: C#, Go, Java, JavaScript, python, Swift, C \ C++ and more.
There are already LSP clients for many Editors \ IDE’s: Eclipse Che, VSCode, neovim, Sublime, Atom, Emacs and more.
The quality of the clients & servers is varying, specifically for language clients. VSCode is already using LSP as its backend for language analysis, Neovim is already talking about making LSP a first class citizen, and I believe more will follow.
Further reading
- Language Server Protocol Specification
- Protocol History
- A Common Protocol for Languages
- How Sourcegraph scales with the Language Server Protocol