Language Server Protocol
Why LSP Exists
Before LSP, editor integrations for language tooling (completion, diagnostics, refactors) were bespoke. Every compiler or analyzer needed plug-ins for VS Code, Vim, IntelliJ, Sublime, etc., and each editor duplicated work to support many languages. This matrix of per-language, per-editor plug-ins slowed innovation and made advanced tooling inaccessible outside first-party IDEs.
The Language Server Protocol—initiated by Microsoft for VS Code and now standardized by the Open Source community—solves this coupling. It defines a JSON-RPC protocol so a single language server can speak to any compliant editor. Editors implement the client half once and gain tooling support for every language that implements the server half.
Problems It Solves
- Shared investment: Language teams implement the protocol once instead of maintaining multiple editor-specific plug-ins.
- Editor freedom: Developers choose tools without sacrificing language-aware features.
- Feature parity: Diagnostics, go-to-definition, workspace symbols, rename, and more behave consistently across environments.
- Incremental updates: The protocol is designed for streaming updates as the user types, enabling responsive experiences.
How LSP Works
- Transport: Client and server communicate over stdin/stdout pipes, TCP, or WebSockets. Messages use JSON-RPC 2.0 framed with
Content-Lengthheaders. - Initialization: Client sends
initializewith capabilities and workspace metadata. Server responds with supported features (ServerCapabilities). A follow-upinitializednotification signals readiness. - Document Synchronization: The client streams document lifecycle notifications (
didOpen,didChange,didSave,didClose) so the server maintains up-to-date views of open files. - Feature Requests: Once documents are synchronized, the client issues requests such as:
textDocument/completionfor completion items.textDocument/hoverfor inline info.textDocument/definitionandtextDocument/referencesfor navigation.textDocument/documentSymbolandworkspace/symbolfor structure searches.textDocument/codeAction,textDocument/rename,textDocument/semanticTokens, and more.
- Responses and Notifications: Servers send responses with payloads defined in the protocol. They can also push diagnostics (
textDocument/publishDiagnostics) or log messages asynchronously. - Shutdown: Clients request graceful shutdown via
shutdownfollowed byexit.
The protocol evolves through versioned specifications (currently 3.x). Beacon targets the subset required for an ergonomic Python workflow, while keeping the implementation modular so new methods can be added as needed.