Expand description
Asynchronous Language Server Protocol (LSP) framework based on tower.
See project README for a general overview.
This project is centered at a core service trait LspService
for either Language Servers or
Language Clients. The main loop driver MainLoop
executes the service. The additional
features, called middleware, are pluggable can be layered using the tower_layer
abstraction. This crate defines several common middlewares for various mandatory or optional
LSP functionalities, see their documentations for details.
concurrency::Concurrency
: Incoming request multiplexing and cancellation.panic::CatchUnwind
: Turn panics into errors.tracing::Tracing
: Logger spans with methods instrumenting handlers.server::Lifecycle
: Server initialization, shutting down, and exit handling.client_monitor::ClientProcessMonitor
: Client process monitor.router::Router
: “Root” service to dispatch requests, notifications and events.
Users are free to select and layer middlewares to run a Language Server or Language Client. They can also implement their own middlewares for like timeout, metering, request transformation and etc.
§Usages
There are two main ways to define a Router
root service: one is via its
builder API, and the other is to construct via implementing the omnitrait LanguageServer
or
LanguageClient
for a state struct. The former is more flexible, while the latter has a
more similar API as tower-lsp
.
The examples for both builder-API and omnitrait, cross Language Server and Language Client, can
be seen under
examples
directory.
§Cargo features
client-monitor
: Client process monitor middlewareclient_monitor
. Enabled by default.omni-trait
: Mega traits of all standard requests and notifications, namelyLanguageServer
andLanguageClient
. Enabled by default.stdio
: Utilities to deal with pipe-like stdin/stdout communication channel for Language Servers. Enabled by default.tracing
: Integration with cratetracing
and thetracing
middleware. Enabled by default.forward
: ImplLspService
for{Client,Server}Socket
. This collides some method names but allows easy service forwarding. Seeexamples/inspector.rs
for a possible use case. Disabled by default.tokio
: Enable compatible methods fortokio
runtime. Disabled by default.
Re-exports§
pub use lsp_types;
Modules§
- client_
monitor client-monitor
- Stop the main loop when the Language Client process aborted unexpectedly.
- concurrency
- Incoming request multiplexing limits and cancellation.
- panic
- Catch panics of underlying handlers and turn them into error responses.
- router
- Dispatch requests and notifications to individual handlers.
- server
- Language Server lifecycle.
- stdio
stdio
and Unix - Utilities to deal with stdin/stdout communication channel for Language Servers.
- tracing
tracing
- Attach
tracing::Span
s over underlying handlers.
Structs§
- AnyEvent
- A dynamic runtime event.
- AnyNotification
- A dynamic runtime LSP notification.
- AnyRequest
- A dynamic runtime LSP request.
- Client
Socket - The socket for Language Server to communicate with the Language Client peer.
- Error
Code - A JSON-RPC error code.
- Main
Loop - Service main loop driver for either Language Servers or Language Clients.
- Response
Error - The error object in case a request fails.
- Server
Socket - The socket for Language Client to communicate with the Language Server peer.
Enums§
- Error
- Possible errors.
Traits§
- Language
Client omni-trait
- The omnitrait defining all standard LSP requests and notifications supported by
lsp_types
for a Language Client. - Language
Server omni-trait
- The omnitrait defining all standard LSP requests and notifications supported by
lsp_types
for a Language Server. - LspService
- The core service abstraction, representing either a Language Server or Language Client.
Type Aliases§
- Request
Id - The identifier of requests and responses.
- Result
- A convenient type alias for
Result
withE
=crate::Error
.