pro_lsp 0.3.0 copy "pro_lsp: ^0.3.0" to clipboard
pro_lsp: ^0.3.0 copied to clipboard

Unified LSP 3.18 Dart bindings and client/server API implementation

pro_lsp #

Unified LSP 3.18 Dart bindings and a typed server/client framework. pro_lsp is lightweight, transport-agnostic, and strictly type-safe — build Language Servers and Language Clients in Dart without hand-writing JSON-RPC plumbing.

import 'package:pro_lsp/pro_lsp.dart';

void main() async {
  final server = LspServer();

  server.general.onInitialize((params, context) async {
    return const InitializeResult(
      capabilities: ServerCapabilities(hoverProvider: .bool(true)),
      serverInfo: ServerInfo(name: 'my-dart-lsp', version: '1.0.0'),
    );
  });

  server.textDocument.onHover((params, context) async {
    return Hover(
      contents: HoverContents.markupContent(
        MarkupContent(kind: .markdown, value: '`${params.textDocument.uri}`'),
      ),
    );
  });

  // Blocks until the client exits. `shutdown`/`exit` are handled for you.
  await server.listen();
}

Never write to stdout from a stdio server. On stdio, stdout is the protocol channel — a stray print() corrupts the JSON-RPC stream. Log to stderr or a file, and set server.onError. See Building a server → Logging.


Why pro_lsp #

  • Complete LSP 3.18 surface, generated from the official Microsoft meta-model: Freezed structures (copyWith, value equality, JSON), extension type unions, and open/closed enums.
  • Typed, symmetric API — incoming messages are handlers (server.textDocument.onHover(...)); outgoing messages are senders (server.client.window.showMessage(...)). The client mirrors the server.
  • Lifecycle handled for you — an enforced state machine (uninitialized → initialized → shuttingDown → exited) with sensible shutdown/exit defaults.
  • Cancellation both ways via CancellationToken, plus timeout on outgoing requests.
  • Typed errors — everything surfaces as LspException; you never touch the transport's RpcException.
  • Pluggable & extensible — modular LspFeatures, middleware, and a built-in service container (DI).
  • Transport-agnostic framing over stdio, TCP, or any byte stream via LspByteStreamChannel.

Install #

dart pub add pro_lsp

Requires Dart SDK ^3.10 — the generated API uses recent language features, including dot-shorthands for enums and union factories (.bool(true), .markdown). Where the target type is known, you can drop the type name and start with ..


Documentation #

The full guide lives in doc/. Start there for concepts, end-to-end walkthroughs, and a per-method tutorial covering every LSP request and notification with "what / when / example".

Guides

Method reference (catalog)


License #

MIT — see LICENSE for details.

1
likes
160
points
870
downloads

Documentation

API reference

Publisher

verified publisherpro100.dev

Weekly Downloads

Unified LSP 3.18 Dart bindings and client/server API implementation

Repository (GitHub)
View/report issues

Topics

#lsp #language-server #ide #editor #protocol

License

MIT (license)

Dependencies

freezed_annotation, json_annotation, json_rpc_2, meta, stream_channel

More

Packages that depend on pro_lsp