Crate async_lsp

source ·
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.

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 middleware client_monitor. Enabled by default.
  • omni-trait: Mega traits of all standard requests and notifications, namely LanguageServer and LanguageClient. Enabled by default.
  • stdio: Utilities to deal with pipe-like stdin/stdout communication channel for Language Servers. Enabled by default.
  • tracing: Integration with crate tracing and the tracing middleware. Enabled by default.
  • forward: Impl LspService for {Client,Server}Socket. This collides some method names but allows easy service forwarding. See examples/inspector.rs for a possible use case. Disabled by default.
  • tokio: Enable compatible methods for tokio runtime. Disabled by default.

Re-exports

Modules

  • client_monitorclient-monitor
    Stop the main loop when the Language Client process aborted unexpectedly.
  • Incoming request multiplexing limits and cancellation.
  • Catch panics of underlying handlers and turn them into error responses.
  • Dispatch requests and notifications to individual handlers.
  • Language Server lifecycle.
  • stdiostdio and Unix
    Utilities to deal with stdin/stdout communication channel for Language Servers.
  • tracingtracing
    Attach tracing::Spans over underlying handlers.

Structs

Enums

Traits

  • LanguageClientomni-trait
    The omnitrait defining all standard LSP requests and notifications supported by lsp_types for a Language Client.
  • LanguageServeromni-trait
    The omnitrait defining all standard LSP requests and notifications supported by lsp_types for a Language Server.
  • The core service abstraction, representing either a Language Server or Language Client.

Type Aliases